Redis Vector Library (RedisVL)

repository·main·Indexed 19 days ago

https://github.com/redis/redis-vl-python

An AI-native Python client library and CLI for using Redis as a vector database. RedisVL facilitates the creation of RAG pipelines, AI agents, and recommendation systems through features including index schema management, vector and hybrid search, semantic caching, embedding caching, semantic message history, and semantic routing. It also includes a CLI (rvl) and a Model Context Protocol (MCP) server for exposing Redis indexes to compatible clients.

Tokens
85.1K
Snippets
254
Records
366
Agent score
62%

What's inside redisvl

  1. Use RedisVL for Agent Context and RAG

    main

    RedisVL can be used to power AI agents by providing them with relevant information through several mechanisms:

    • Retrieval-Augmented Generation (RAG): Use vector search and hybrid queries to retrieve context for LLMs.
    • Memory: Implement persistent message history across different user sessions.
    • Context Engineering: Curate the optimal context window by combining vector embeddings, complex metadata filtering, and reranking techniques.
  2. Optimize AI workloads with Semantic Caching and Routing

    main

    To reduce latency and costs in AI applications, RedisVL provides specialized tools:

    • Semantic Caching: Use SemanticCache to cache LLM responses based on the semantic meaning of queries rather than exact string matches.
    • Embeddings Caching: Use EmbeddingsCache to avoid redundant and expensive calls to embedding models by caching previously computed vectors.
    • Semantic Routing: Use SemanticRouter to direct queries to the appropriate handler based on their semantic intent.
  3. Implement Semantic and Hybrid Search

    main

    RedisVL enables search experiences that go beyond simple keyword matching:

    • Semantic Search: Perform vector queries combined with complex metadata filtering.
    • Hybrid Search: Combine traditional keyword search with vector search for improved accuracy.
    • SQL Translation: Use the SQLQuery interface to interact with your data using familiar SQL syntax.
  4. LLM Extensions and Caching

    main

    RedisVL provides several extensions to enhance LLM workflows:

    • Semantic Caching: Use Cache LLM Responses to reduce costs and latency by caching semantic matches of LLM queries.
    • Managed Caching: Integrate with LangCache as a managed semantic cache service.
    • Message History: Use Manage LLM Message History to maintain persistent chat history with relevancy-based retrieval.
    • Intent Routing: Use SemanticRouter to classify user intents and route queries to different handlers or models.
  5. Build Personalization and Recommendation Systems

    main

    Drive user engagement using vector-based recommendation patterns:

    • User Similarity: Find similar users or items using vector search.
    • Real-Time Ranking: Combine vector similarity with metadata filtering and reranking to provide highly relevant results.
    • Multi-Signal Matching: Use MultiVectorQuery to search across multiple embedding fields simultaneously.
  6. Storage and Index Migration

    main

    Manage how data is stored and how to evolve your schema:

    • Storage Formats: Choose between Hash and JSON formats, specifically considering how to handle nested data.
    • Index Migration: Use the migrator helper, wizard, plan, apply, and validate workflow to move indices.
    • Advanced Migration: Perform vector quantization with support for crash-safe resume, rollback, and a guided wizard flow.
  7. Querying and Filtering Data

    main

    RedisVL supports advanced querying capabilities:

    • Complex Filtering: Combine multiple filter types including tag, numeric, geo, and text filters in a single query.
    • Advanced Query Types: Implement hybrid search, multi-vector search, range queries, and specialized text queries.
    • SQL Translation: Use the Write SQL Queries for Redis functionality to translate standard SQL syntax into Redis-compatible query syntax.
  8. Available Vectorizers in redisvl

    main

    RedisVL provides several vectorizer classes to convert text into embeddings using various providers.

    Supported Providers

    • HuggingFace: HFTextVectorizer
    • OpenAI: OpenAITextVectorizer
    • Azure OpenAI: AzureOpenAITextVectorizer
    • Google Cloud: GoogleGenAIVectorizer (Recommended) and VertexAIVectorizer (Deprecated)
    • Cohere: CohereTextVectorizer
    • AWS Bedrock: BedrockVectorizer
    • Voyage AI: VoyageAIVectorizer
    • Mistral AI: MistralAITextVectorizer
    • Custom: CustomVectorizer for user-defined logic.
  9. What is RedisVL MCP and when to use it

    main

    RedisVL MCP (Model Context Protocol) is an MCP server that exposes existing Redis Search indexes as a stable, deterministic tool interface for AI applications and agent frameworks.

    Use RedisVL MCP when:

    • You want multiple AI assistants to share a single, approved retrieval surface.
    • You want search behavior (like vector vs. fulltext) to be fixed by deployment configuration rather than client-side logic.
    • You need a controlled read-only or read-write boundary for AI agents.
    • You want to reuse existing Redis indexes without reimplementing query logic in every client.

    Use direct RedisVL Python calls when:

    • Your application needs to own the index lifecycle (creation/deletion).
    • You need to construct complex, dynamic queries manually.
    • You require full access to all RedisVL features directly in Python.