SemanticCache vector index algorithm is hardcoded to FLAT; no way to configure HNSW
维护者通常 4 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
调研方向
从 redisvl/extensions/cache/llm/schema.py:115 中的 SemanticCacheIndexSchema.from_params 开始,并检查 SemanticCache 构造函数,以追踪创建时如何传入索引设置。添加构造时配置,以设置向量算法及其 HNSW 参数,同时保留 FLAT 作为默认值;完成标准是新缓存可以选择 HNSW,而无需手动创建索引。
由索引模型根据 Issue 内容生成。
描述
Current behavior
SemanticCacheIndexSchema.from_params (redisvl/extensions/cache/llm/schema.py:115) hardcodes the vector field's algorithm to "flat":
{
"name": CACHE_VECTOR_FIELD_NAME,
"type": "vector",
"attrs": {
"dims": vector_dims,
"datatype": dtype,
"distance_metric": "cosine",
"algorithm": "flat",
},
},
There is no constructor argument on SemanticCache to override this. FLAT is exact KNN — fine to the low millions of entries, latency-degrading beyond that. For large multi-tenant deployments or per-tenant player-facing caches (10M–100M entries), HNSW is required. Today the only workaround is to bypass SemanticCache entirely and build the index manually.
Proposed API
SemanticCache(
name="cache",
redis_url=...,
vector_index_config={
"algorithm": "hnsw", # or "flat" (default)
"m": 16,
"ef_construction": 200,
"ef_runtime": 10,
},
)
A simpler form taking just algorithm: Literal["flat", "hnsw"] = "flat" plus a default HNSW parameter preset would also be acceptable for a first cut.
Compatibility notes
The algorithm is fixed at index creation; existing FLAT caches cannot be hot-swapped to HNSW. Customers wanting to switch must build a new cache (new name), re-warm, and cut over — same migration shape as a schema change. This is acceptable as long as the option exists at construction time.
Notes
Surfaced while writing a scoped semantic caching architecture spec for customers running large-scale, multi-tenant deployments.
- 主要语言
- Python
- 星标
- 432
- 派生
- 111
- 平均合并
- 5 天 22 小时
- 30 天内合并 PR
- 13
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
redis/redis-vl-python 的其他 Issue
-
bug index
难度 2/5 1-3 小时 新手友好度 84/100
redis/redis-vl-python#787 ·
维护者通常 4 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 77/100
redis/redis-vl-python#786 ·
维护者通常 4 天内回复
-
exists() depends on exact FT.INFO error wording; an unrecognised "missing index" message makes create() never create the index (regression from #672)可能已有人在做 @nandanadileep 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
redis/redis-vl-python#773 · 1 条评论 ·
维护者通常 4 天内回复
-
Vector field with index_missing=True cannot be created可能已有人在做 @RaphaelFakhri 于 10 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
redis/redis-vl-python#770 ·
维护者通常 4 天内回复
-
Add Python 3.15 support可能已有人在做 @vishal-bala 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
redis/redis-vl-python#757 · 1 条评论 · 1 个 reaction ·
维护者通常 4 天内回复
查看 redis/redis-vl-python 的全部 Issue
相似的 Issue
-
component:benchmark
难度 2/5 1-3 小时 新手友好度 76/100
agentic-os-org/ANOLISA#9177 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
distrochooser/distrochooser#520 ·
维护者通常 2 天内回复
-
Status: Needs confirmation Status: Needs triage
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
[BUG] Published Docker images lack the redis extra: HEADROOM_COMPRESS_SESSION_STORE stops startup可能已有人在做 @AlessandroSpallina 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
headroomlabs-ai/headroom#4513 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 65/100
codespell-project/codespell#4060 ·
维护者通常 1 天内回复