11 Apr, 2026
1 commit
-
这次代码侧的核心变化是: - 删除了 `indexer/product_enrich.py`、`indexer/product_enrich_prompts.py` 及相关单测。 - 在 [api/routes/indexer.py](/data/saas-search/api/routes/indexer.py:55) 移除了 `/indexer/enrich-content` 路由;现在这个路径在本仓库 indexer 服务里会是 `404`,对应契约测试也已改成校验移除状态:[tests/ci/test_service_api_contracts.py](/data/saas-search/tests/ci/test_service_api_contracts.py:345)。 - 在 [api/routes/indexer.py](/data/saas-search/api/routes/indexer.py:183)、[indexer/document_transformer.py](/data/saas-search/indexer/document_transformer.py:109)、[indexer/incremental_service.py](/data/saas-search/indexer/incremental_service.py:587)、[indexer/spu_transformer.py](/data/saas-search/indexer/spu_transformer.py:223) 去掉了构建 doc 时自动补 `qanchors` / `enriched_*` 的本地 LLM 富化逻辑。现在 `build-docs` / `reindex` / `index` 只负责基础文档构建。 - 在 [config/schema.py](/data/saas-search/config/schema.py:316)、[config/loader.py](/data/saas-search/config/loader.py:824)、[config/env_config.py](/data/saas-search/config/env_config.py:37)、[config/config.yaml](/data/saas-search/config/config.yaml:32) 清掉了旧实现专用的 `product_enrich` 和 anchor cache 配置面。 重要文档也一起同步了,重点是把“能力已迁出、本仓库不再内置生成”写明确: - [README.md](/data/saas-search/README.md:113) - [docs/搜索API对接指南-00-总览与快速开始.md](</data/saas-search/docs/搜索API对接指南-00-总览与快速开始.md:108>) - [docs/搜索API对接指南-05-索引接口(Indexer).md](</data/saas-search/docs/搜索API对接指南-05-索引接口(Indexer).md:647>) - [docs/搜索API对接指南-07-微服务接口(Embedding-Reranker-Translation).md](</data/saas-search/docs/搜索API对接指南-07-微服务接口(Embedding-Reranker-Translation).md:441>) - [docs/工作总结-微服务性能优化与架构.md](</data/saas-search/docs/工作总结-微服务性能优化与架构.md:96>) - [docs/缓存与Redis使用说明.md](</data/saas-search/docs/缓存与Redis使用说明.md:186>) - [indexer/README.md](/data/saas-search/indexer/README.md:508) - [indexer/ANCHORS_AND_SEMANTIC_ATTRIBUTES.md](/data/saas-search/indexer/ANCHORS_AND_SEMANTIC_ATTRIBUTES.md:1) 验证做了两步: - `python3 -m compileall ...` 通过 - `source activate.sh && python -m pytest tests/ci/test_service_api_contracts.py -q` 通过,`31 passed` 剩下我认为仍有“旧信息”但暂时没动的,主要是历史记录类文档,不算当前对接口径: - [docs/issues/issue.md](/data/saas-search/docs/issues/issue.md:295) - [docs/issues/issue.txt](/data/saas-search/docs/issues/issue.txt:468) - [docs/issues/issue-2026-03-29-索引修改-done-0330.md](</data/saas-search/docs/issues/issue-2026-03-29-索引修改-done-0330.md:23>) - [docs/issues/issue-2026-04-04-增加多模态标注-TODO.md](</data/saas-search/docs/issues/issue-2026-04-04-增加多模态标注-TODO.md:1>) 另外,工作区里原本就有 `.env` 修改和未跟踪的 `AGENTS.md`,我没有动它们。
09 Apr, 2026
1 commit
-
- `/indexer/enrich-content` 路由`enriched_taxonomy_attributes` 与 `enriched_attributes` 一并返回 - 新增请求参数 `analysis_kinds`(可选,默认 `["content", "taxonomy"]`),允许调用方按需选择内容分析类型,为后续扩展和成本控制预留空间 - 重构缓存策略:将 `content` 与 `taxonomy` 两类分析的缓存完全隔离,缓存 key 包含 prompt 模板、表头、输出字段定义(即 schema 指纹),确保提示词或解析规则变更时自动失效 - 缓存 key 仅依赖真正参与 LLM 输入的字段(`title`、`brief`、`description`),`image_url`、`tenant_id`、`spu_id` 不再污染缓存键,提高缓存命中率 - 更新 API 文档(`docs/搜索API对接指南-05-索引接口(Indexer).md`),说明新增参数与返回字段 技术细节: - 路由层调整:在 `api/routes/indexer.py` 的 enrich-content 端点中,将 `product_enrich.enrich_products_batch` 返回的 `enriched_taxonomy_attributes` 字段显式加入 HTTP 响应体 - `analysis_kinds` 参数透传至底层 `enrich_products_batch`,支持按需跳过某一类分析(如仅需 taxonomy 时减少 LLM 调用) - 缓存指纹计算位于 `product_enrich.py` 的 `_get_cache_key` 函数,对每种 `AnalysisSchema` 独立生成;版本号通过 `schema.version` 或 prompt 内容哈希隐式包含 - 测试覆盖:新增 `analysis_kinds` 组合场景及缓存隔离测试
27 Mar, 2026
1 commit
19 Mar, 2026
1 commit
18 Mar, 2026
1 commit
17 Mar, 2026
4 commits
-
2. 抽象出可复用的 embedding Redis 缓存类(图文共用) 详细: 1. embedding 缓存改为 BF16 存 Redis(读回恢复 FP32) 关键行为(按你给的流程落地) 写入前:FP32 embedding →(normalize_embeddings=True 时)L2 normalize → 转 BF16 → bytes(2字节/维,大端) → redis.setex 读取后:redis.get bytes → BF16 → 恢复 FP32(np.float32 向量) 变更点 新增 embeddings/bf16.py 提供 float32_to_bf16 / bf16_to_float32 encode_embedding_for_redis():FP32 → BF16 → bytes decode_embedding_from_redis():bytes → BF16 → FP32 l2_normalize_fp32():按需归一化 修改 embeddings/text_encoder.py Redis value 从 pickle.dumps(np.ndarray) 改为 BF16 bytes 缓存 key 改为包含 normalize 标记:{prefix}:{n0|n1}:{query}(避免 normalize 开关不同却共用缓存) 修改 tests/test_embedding_pipeline.py cache hit 用例改为写入 BF16 bytes,并使用新 key:embedding:n1:cached-text 修改 docs/缓存与Redis使用说明.md embedding 缓存的 Key/Value 格式更新为 BF16 bytes + n0/n1 修改 scripts/redis/redis_cache_health_check.py embedding pattern 不再硬编码 embedding:*,改为读取 REDIS_CONFIG["embedding_cache_prefix"] value 预览从 pickle 解码改为 BF16 解码后展示 dim/bytes/dtype 自检 在激活环境后跑过 BF16 编解码往返 sanity check:bytes 长度、维度恢复正常;归一化向量读回后范数接近 1(会有 BF16 量化误差)。 2. 抽象出可复用的 embedding Redis 缓存类(图文共用) 新增 embeddings/redis_embedding_cache.py:RedisEmbeddingCache 统一 Redis 初始化(读 REDIS_CONFIG) 统一 BF16 bytes 编解码(复用 embeddings/bf16.py) 统一过期策略:写入 setex(expire_time),命中读取后 expire(expire_time) 滑动过期刷新 TTL 统一异常/坏数据处理:解码失败或向量非 1D/为空/含 NaN/Inf 会删除该 key 并当作 miss 已接入复用 文本 embeddings/text_encoder.py 用 self.cache = RedisEmbeddingCache(key_prefix=..., namespace="") key 仍是:{prefix}:{query} 图片 embeddings/image_encoder.py 用 self.cache = RedisEmbeddingCache(key_prefix=..., namespace="image") key 仍是:{prefix}:image:{url_or_path}