Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

SemanticCache vector index algorithm is hardcoded to FLAT; no way to configure HNSW

未关闭
#602 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

@omribz156 已经在做这个了。

开始于 2026年5月25日。

  • #619 来自 @omribz156 —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
冷清
技术栈
python, redis
领域
backend, databases

调研方向

从 redisvl/extensions/cache/llm/schema.py:115 中的 SemanticCacheIndexSchema.from_params 开始,并检查 SemanticCache 构造函数,以追踪创建时如何传入索引设置。添加构造时配置,以设置向量算法及其 HNSW 参数,同时保留 FLAT 作为默认值;完成标准是新缓存可以选择 HNSW,而无需手动创建索引。

由索引模型根据 Issue 内容生成。

描述

cache enhancement

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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

redis/redis-vl-python 的其他 Issue

查看 redis/redis-vl-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。