Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#602 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

@omribz156 đang làm issue này rồi.

Từ ngày 25/5/2026.

  • #619 của @omribz156 — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python, redis
Lĩnh vực
backend, databases

Hướng nghiên cứu

Bắt đầu với SemanticCacheIndexSchema.from_params trong redisvl/extensions/cache/llm/schema.py:115 và kiểm tra hàm khởi tạo của SemanticCache để theo dõi cách các thiết lập chỉ mục được truyền vào khi tạo. Thêm cấu hình tại thời điểm khởi tạo cho thuật toán vector và các tham số HNSW của nó, đồng thời giữ FLAT làm mặc định; hoàn tất khi các cache mới có thể chọn HNSW mà không cần tạo chỉ mục thủ công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
431
Fork
107
Merge trung bình
5 ngày 17 giờ
Pull request đã merge (30 ngày)
16

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của redis/redis-vl-python

Tất cả issue của redis/redis-vl-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.