redis-vector
БесплатноБез исполняемых скриптовНе проверенRedis Stack vector search. FT.CREATE with VECTOR field, HNSW vs FLAT, hybrid with other field types, RedisVL Python library, Redis Enterprise scaling…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Redis Vector Search
When Redis Is the Right Choice
Redis is the correct default vector store when:
- Your stack already uses Redis for cache / session / queue.
- You need sub-10ms p95 on modest corpus sizes (< 10M vectors).
- Vectors live alongside hot transactional data (user profiles, product records).
- You want a single system for semantic cache and knowledge retrieval.
Redis is a poor fit for:
- Billions of vectors — RAM cost becomes prohibitive vs DiskANN stores.
- Long-term archival storage with infrequent reads.
- Analytics-style scans without ID-based access patterns.
Redis Stack vs OSS Redis
Vector search requires the search module (RediSearch 2.4+). It ships with:
- Redis Stack (local dev, Docker,
redis/redis-stack:latest) - Redis Enterprise (managed, scales horizontally)
- Redis Cloud (fully managed Enterprise)
Plain redis:latest OSS has no search module. Attempt FT.CREATE on it and you get "unknown command".
FT.CREATE with VECTOR Field
# pip install redis>=5
import redis
from redis.commands.search.field import VectorField, TagField, NumericField, TextField
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
r = redis.Redis(host="localhost", port=6379, decode_responses=False)
schema = (
VectorField(
"vector",
"HNSW",
{
"TYPE": "FLOAT32",
"DIM": 1024,
"DISTANCE_METRIC": "COSINE",
"M": 16,
"EF_CONSTRUCTION": 200,
"EF_RUNTIME": 10,
},
),
TagField("tenant_id"),
TagField("source"),
NumericField("created_at"),
TextField("text"),
)
r.ft("idx:docs").create_index(
fields=schema,
definition=IndexDefinition(prefix=["doc:"], index_type=IndexType.HASH),
)
The index watches any key starting with doc: — insert data with those prefixes and it gets indexed automatically.
HNSW vs FLAT
| Index | Use case | Build time | Memory | Recall |
|---|---|---|---|---|
| FLAT | < 10k vectors, exact search | Instant | 1x | 100% |
| HNSW | 10k - 10M vectors, approximate | Slow insert | ~1.2x | 95-99% |
Parameters:
M(default 16): connections per node. Higher = better recall, more RAM.EF_CONSTRUCTION(200): build-time search width. Higher = better index, slower ingest.EF_RUNTIME(10): query-time search width. Higher = better recall, slower query.
Tune EF_RUNTIME per query if different clients have different recall/latency needs — pass via $EF_RUNTIME in the query.
Insert via Hash Pattern
def insert(doc_id: str, vector: np.ndarray, tenant_id: str, source: str, text: str):
key = f"doc:{doc_id}"
r.hset(key, mapping={
"vector": vector.astype("float32").tobytes(),
"tenant_id": tenant_id,
"source": source,
"created_at": int(time.time()),
"text": text,
})
insert("d1", dense_vec, "acme", "kb", "OAuth uses refresh tokens.")
Vectors are stored as raw FLOAT32 bytes — not JSON, not base64.
Query
from redis.commands.search.query import Query
import numpy as np
q_bytes = q_vec.astype("float32").tobytes()
q = (
Query("(@tenant_id:{acme} @source:{kb|faq})=>[KNN 10 @vector $BLOB AS score]")
.sort_by("score")
.return_fields("score", "text", "source")
.paging(0, 10)
.dialect(2)
)
results = r.ft("idx:docs").search(q, query_params={"BLOB": q_bytes})
for doc in results.docs:
print(doc.score, doc.text)
The (...) pre-filter runs first (tag index), then KNN over the filtered subset — true pre-filtering.
Hybrid with Text + Vector
q = (
Query("@text:(oauth refresh token) @tenant_id:{acme}=>[KNN 10 @vector $BLOB AS score]")
.dialect(2)
)
@text:(...) uses Redis's built-in tokenizer + stemmer. Combine with KNN for a keyword-filtered semantic search.
For full hybrid retrieval (BM25 + vector fusion) use RedisVL's hybrid query below.
RedisVL (Higher-Level Client)
# pip install redisvl
from redisvl.index import SearchIndex
from redisvl.schema import IndexSchema
from redisvl.query import VectorQuery, FilterQuery
from redisvl.query.filter import Tag, Num
schema = IndexSchema.from_dict({
"index": {"name": "docs", "prefix": "doc:", "storage_type": "hash"},
"fields": [
{"name": "text", "type": "text"},
{"name": "tenant_id", "type": "tag"},
{"name": "created_at", "type": "numeric"},
{"name": "vector", "type": "vector",
"attrs": {"dims": 1024, "algorithm": "hnsw", "distance_metric": "cosine"}},
],
})
index = SearchIndex(schema, r)
index.create(overwrite=False)
filt = (Tag("tenant_id") == "acme") & (Num("created_at") > 1700000000)
q = VectorQuery(vector=q_vec.tolist(), vector_field_name="vector",
return_fields=["text", "source"], num_results=10, filter_expression=filt)
results = index.query(q)
RedisVL adds typed schemas, Pydantic-style filter expressions, and semantic cache / LLM session prim
Установить redis-vector в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditFAQ
Что делает скилл redis-vector?
Redis Stack vector search. FT.CREATE with VECTOR field, HNSW vs FLAT, hybrid with other field types, RedisVL Python library, Redis Enterprise scaling, pipelines for bulk ingest, TTL for ephemeral vectors (cache use case), Redis JSON + vectors pattern. USE WHEN: user mentions "Redis vector", "Redis Stack", "FT.CREATE", "RedisVL", "Redis HNSW", "Redis JSON vector", "semantic cache Redis" DO NOT USE FOR: other vector stores - use `vector-stores/*` siblings; embedding caching theory - use `rag/caching-retrieval`
Как установить скилл redis-vector?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл redis-vector запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
agent-skill-stack
Find, evaluate, and assemble the smallest compatible set of AI Agent Skills for an end-to-end natural-language goal. Use when a user wants Skills for a…
от GitHubbuild-evidence-map
Build an auditable evidence map for a contested technical choice, research synthesis, proposal review, or consequential decision. Use when Copilot must…
от GitHubpinecone-rag
Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions…
от GitHubqdrant-monitoring-debugging
Diagnoses Qdrant production issues using metrics and observability tools. Use when someone reports 'optimizer stuck', 'indexing too slow', 'memory too high'…
от GitHub