Skip to content

Pull out threshold optimizers and cleanup README #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- main

env:
POETRY_VERSION: "1.8.3"
POETRY_VERSION: "2.0.1"

jobs:
check:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.8.3"
POETRY_VERSION: "2.0.1"

jobs:
build:
Expand Down
32 changes: 7 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.8.3"
POETRY_VERSION: "2.0.1"

jobs:
service-tests:
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: ${{ env.PYTHON_VERSION }}
cache: pip

- name: Install Poetry
Expand All @@ -52,7 +52,6 @@ jobs:
- name: Install dependencies
run: |
poetry install --all-extras
poetry run pip install ranx

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
Expand All @@ -79,7 +78,7 @@ jobs:
make test-all

test:
name: Python ${{ matrix.python-version }} - ${{ matrix.connection }} - redis-py ${{ matrix.redis-py-version }} [redis ${{ matrix.redis-version }}]
name: Python ${{ matrix.python-version }} - redis-py ${{ matrix.redis-py-version }} [redis ${{ matrix.redis-version }}]
runs-on: ubuntu-latest
needs: service-tests
env:
Expand All @@ -89,7 +88,6 @@ jobs:
matrix:
# 3.11 tests are run in the service-tests job
python-version: ["3.9", "3.10", 3.12, 3.13]
connection: ["hiredis", "plain"]
redis-py-version: ["5.x", "6.x"]
redis-version: ["6.2.6-v9", "latest", "8.0.1"]

Expand Down Expand Up @@ -117,18 +115,12 @@ jobs:
- name: Install dependencies
run: |
poetry install --all-extras
poetry run pip install ranx

# Install right redis version based on redis py
if [[ "${{ matrix.redis-py-version }}" == "5.x" ]]; then
poetry add "redis>=5.0.0,<6.0.0"
poetry run pip install "redis>=5.0.0,<6.0.0"
else
poetry add "redis>=6.0.0,<7.0.0"
fi

# Install hiredis if selected
if [[ "${{ matrix.connection }}" == "hiredis" ]]; then
poetry add hiredis
poetry run pip install "redis>=6.0.0,<7.0.0"
fi

- name: Set Redis image name
Expand All @@ -145,21 +137,15 @@ jobs:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}

- name: Run tests
if: matrix.connection == 'plain' && matrix.redis-py-version == '6.x' && matrix.redis-version == 'latest'
env:
HF_HOME: ${{ github.workspace }}/hf_cache
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
run: |
make test

- name: Run tests (alternate)
if: matrix.connection != 'plain' || matrix.redis-py-version != '6.x' || matrix.redis-version != 'latest'
run: |
make test

- name: Run notebooks
if: matrix.connection == 'plain' && matrix.redis-py-version == '6.x' && matrix.redis-version == 'latest'
if: matrix.redis-py-version == '6.x' && matrix.redis-version == 'latest'
env:
HF_HOME: ${{ github.workspace }}/hf_cache
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
Expand All @@ -177,11 +163,7 @@ jobs:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
docker run -d --name redis -p 6379:6379 redis/redis-stack-server:latest
if [[ "${{ matrix.python-version }}" > "3.9" ]]; then
make test-notebooks
else
poetry run test-notebooks --ignore ./docs/user_guide/09_threshold_optimization.ipynb --ignore ./docs/user_guide/release_guide/0_5_1_release.ipynb
fi
make test-notebooks

docs:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ redisvl/
├── redis/ # Redis client utilities
├── schema/ # Index schema definitions
└── utils/ # Utilities (vectorizers, rerankers, optimization)
├── optimize/ # Threshold optimization
├── rerank/ # Result reranking
└── vectorize/ # Embedding providers integration
```
Expand Down
125 changes: 74 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
<div align="center" dir="auto">
<img width="300" src="https://github.com/raw/redis/redis-vl-python/main/docs/_static/Redis_Logo_Red_RGB.svg" style="max-width: 100%" alt="Redis">
<h1>🔥 Vector Library</h1>
<div align="center">
<img width="300" src="https://github.com/raw/redis/redis-vl-python/main/docs/_static/Redis_Logo_Red_RGB.svg" alt="Redis">
<h1>Redis Vector Library</h1>
<p><strong>The AI-native Redis Python client</strong></p>
</div>


<div align="center" style="margin-top: 20px;">
<span style="display: block; margin-bottom: 10px;">The *AI-native* Redis Python client</span>
<br />

<div align="center">

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![Language](https://img.shields.io/github/languages/top/redis/redis-vl-python)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
![GitHub last commit](https://img.shields.io/github/last-commit/redis/redis-vl-python)
[![pypi](https://badge.fury.io/py/redisvl.svg)](https://pypi.org/project/redisvl/)
![PyPI - Downloads](https://img.shields.io/pypi/dm/redisvl)
[![GitHub stars](https://img.shields.io/github/stars/redis/redis-vl-python)](https://github.com/redis/redis-vl-python/stargazers)

</div>
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
![Language](https://img.shields.io/github/languages/top/redis/redis-vl-python)
![GitHub last commit](https://img.shields.io/github/last-commit/redis/redis-vl-python)

**[Documentation](https://docs.redisvl.com)** • **[Recipes](https://github.com/redis-developer/redis-ai-resources)** • **[GitHub](https://github.com/redis/redis-vl-python)**

<div align="center">
<div display="inline-block">
<a href="https://github.com/redis/redis-vl-python"><b>Home</b></a>&nbsp;&nbsp;&nbsp;
<a href="https://docs.redisvl.com"><b>Documentation</b></a>&nbsp;&nbsp;&nbsp;
<a href="https://github.com/redis-developer/redis-ai-resources"><b>Recipes</b></a>&nbsp;&nbsp;&nbsp;
</div>
<br />
</div>

---

# Introduction
## Introduction

Redis Vector Library is the ultimate Python client designed for AI-native applications harnessing the power of [Redis](https://redis.io).
Redis Vector Library (RedisVL) is the production-ready Python client for AI applications built on Redis. **Lightning-fast vector search meets enterprise-grade reliability.**

[redisvl](https://pypi.org/project/redisvl/) is your go-to client for:
<div align="center">

- Lightning-fast information retrieval & vector similarity search
- Real-time RAG pipelines
- Agentic memory structures
- Smart recommendation engines
| **🎯 Core Capabilities** | **🚀 AI Extensions** | **🛠️ Dev Utilities** |
|:---:|:---:|:---:|
| **[Index Management](#index-management)**<br/>*Schema design, data loading, CRUD ops* | **[Semantic Caching](#semantic-caching)**<br/>*Reduce LLM costs & boost throughput* | **[CLI](#command-line-interface)**<br/>*Index management from terminal* |
| **[Vector Search](#retrieval)**<br/>*Similarity search with metadata filters* | **[LLM Memory](#llm-memory)**<br/>*Agentic AI context management* | **Async Support**<br/>*Async indexing and search for improved performance* |
| **[Hybrid Queries](#retrieval)**<br/>*Vector + text + metadata combined* | **[Semantic Routing](#semantic-routing)**<br/>*Intelligent query classification* | **[Vectorizers](#vectorizers)**<br/>*8+ embedding provider integrations* |
| **[Multi-Query Types](#retrieval)**<br/>*Vector, Range, Filter, Count queries* | **[Embedding Caching](#embedding-caching)**<br/>*Cache embeddings for efficiency* | **[Rerankers](#rerankers)**<br/>*Improve search result relevancy* |

</div>

### **Built for Modern AI Workloads**

- **RAG Pipelines** → Real-time retrieval with hybrid search capabilities
- **AI Agents** → Short term & long term memory and semantic routing for intent-based decisions
- **Recommendation Systems** → Fast retrieval and reranking


# 💪 Getting Started

## Installation

Install `redisvl` into your Python (>=3.8) environment using `pip`:
Install `redisvl` into your Python (>=3.9) environment using `pip`:

```bash
pip install redisvl
```
> For more detailed instructions, visit the [installation guide](https://docs.redisvl.com/en/stable/overview/installation.html).

## Setting up Redis
## Redis

Choose from multiple Redis deployment options:

Expand All @@ -71,7 +73,7 @@ Choose from multiple Redis deployment options:
# Overview


## 🗃️ Redis Index Management
## Index Management
1. [Design a schema for your use case](https://docs.redisvl.com/en/stable/user_guide/01_getting_started.html#define-an-indexschema) that models your dataset with built-in Redis and indexable fields (*e.g. text, tags, numerics, geo, and vectors*). [Load a schema](https://docs.redisvl.com/en/stable/user_guide/01_getting_started.html#example-schema-creation) from a YAML file:
```yaml
index:
Expand Down Expand Up @@ -147,7 +149,7 @@ and [fetch](https://docs.redisvl.com/en/stable/user_guide/01_getting_started.htm
john = index.fetch("john")
```

## 🔍 Retrieval
## Retrieval

Define queries and perform advanced searches over your indices, including the combination of vectors, metadata filters, and more.

Expand Down Expand Up @@ -186,7 +188,7 @@ Define queries and perform advanced searches over your indices, including the co
> Read more about building [advanced Redis queries](https://docs.redisvl.com/en/stable/user_guide/02_hybrid_queries.html).


## 🔧 Utilities
## Dev Utilities

### Vectorizers
Integrate with popular embedding providers to greatly simplify the process of vectorizing unstructured data for your index and queries:
Expand Down Expand Up @@ -222,19 +224,13 @@ embeddings = co.embed_many(
### Rerankers
[Integrate with popular reranking providers](https://docs.redisvl.com/en/stable/user_guide/06_rerankers.html) to improve the relevancy of the initial search results from Redis

### Threshold Optimization
[Optimize distance thresholds for cache and router](https://docs.redisvl.com/en/stable/user_guide/09_threshold_optimization.html) with the utility `ThresholdOptimizer` classes.

**Note:** only available for `python > 3.9`.



## 💫 Extensions
## Extensions
We're excited to announce the support for **RedisVL Extensions**. These modules implement interfaces exposing best practices and design patterns for working with LLM memory and agents. We've taken the best from what we've learned from our users (that's you) as well as bleeding-edge customers, and packaged it up.

*Have an idea for another extension? Open a PR or reach out to us at [email protected]. We're always open to feedback.*

### LLM Semantic Caching
### Semantic Caching
Increase application throughput and reduce the cost of using LLM models in production by leveraging previously generated knowledge with the [`SemanticCache`](https://docs.redisvl.com/en/stable/api/cache.html#semanticcache).

```python
Expand Down Expand Up @@ -264,9 +260,41 @@ print(response[0]["response"])

> Learn more about [semantic caching]((https://docs.redisvl.com/en/stable/user_guide/03_llmcache.html)) for LLMs.

### LLM Memory History
### Embedding Caching
Reduce computational costs and improve performance by caching embedding vectors with their associated text and metadata using the [`EmbeddingsCache`](https://docs.redisvl.com/en/stable/api/cache.html#embeddingscache).

```python
from redisvl.extensions.cache.embeddings import EmbeddingsCache
from redisvl.utils.vectorize import HFTextVectorizer

# Initialize embedding cache
embed_cache = EmbeddingsCache(
name="embed_cache",
redis_url="redis://localhost:6379",
ttl=3600 # 1 hour TTL
)

# Initialize vectorizer with cache
vectorizer = HFTextVectorizer(
model="sentence-transformers/all-MiniLM-L6-v2",
cache=embed_cache
)

# First call computes and caches the embedding
embedding = vectorizer.embed("What is machine learning?")

# Subsequent calls retrieve from cache (much faster!)
cached_embedding = vectorizer.embed("What is machine learning?")
```
```stdout
>>> Cache hit! Retrieved from Redis in <1ms
```

Improve personalization and accuracy of LLM responses by providing user message history as context. Manage access to message history data using recency or relevancy, *powered by vector search* with the [`MessageHistory`](https://docs.redisvl.com/en/stable/api/message_history.html).
> Learn more about [embedding caching](https://docs.redisvl.com/en/stable/user_guide/10_embeddings_cache.html) for improved performance.

### LLM Memory

Improve personalization and accuracy of LLM responses by providing user conversation context. Manage access to memory data using recency or relevancy, *powered by vector search* with the [`MessageHistory`](https://docs.redisvl.com/en/stable/api/message_history.html).

```python
from redisvl.extensions.message_history import SemanticMessageHistory
Expand Down Expand Up @@ -298,10 +326,10 @@ history.get_relevant("weather", top_k=1)
```stdout
>>> [{"role": "user", "content": "what is the weather going to be today?"}]
```
> Learn more about [LLM message history]((https://docs.redisvl.com/en/stable/user_guide/07_message_history.html)).
> Learn more about [LLM memory]((https://docs.redisvl.com/en/stable/user_guide/07_message_history.html)).


### LLM Semantic Routing
### Semantic Routing
Build fast decision models that run directly in Redis and route user queries to the nearest "route" or "topic".

```python
Expand Down Expand Up @@ -337,7 +365,7 @@ router("Hi, good morning")
```
> Learn more about [semantic routing](https://docs.redisvl.com/en/stable/user_guide/08_semantic_router.html).

## 🖥️ Command Line Interface
## Command Line Interface
Create, destroy, and manage Redis index configurations from a purpose-built CLI interface: `rvl`.

```bash
Expand All @@ -355,25 +383,20 @@ Commands:

## 🚀 Why RedisVL?

In the age of GenAI, **vector databases** and **LLMs** are transforming information retrieval systems. With emerging and popular frameworks like [LangChain](https://github.com/langchain-ai/langchain) and [LlamaIndex](https://www.llamaindex.ai/), innovation is rapid. Yet, many organizations face the challenge of delivering AI solutions **quickly** and at **scale**.
Redis is a proven, high-performance database that excels at real-time workloads. With RedisVL, you get a production-ready Python client that makes Redis's vector search, caching, and session management capabilities easily accessible for AI applications.

Enter [Redis](https://redis.io) – a cornerstone of the NoSQL world, renowned for its versatile [data structures](https://redis.io/docs/data-types/) and [processing engines](https://redis.io/docs/interact/). Redis excels in real-time workloads like caching, session management, and search. It's also a powerhouse as a vector database for RAG, an LLM cache, and a chat session memory store for conversational AI.

The Redis Vector Library bridges the gap between the AI-native developer ecosystem and Redis's robust capabilities. With a lightweight, elegant, and intuitive interface, RedisVL makes it easy to leverage Redis's power. Built on the [Redis Python](https://github.com/redis/redis-py/tree/master) client, `redisvl` transforms Redis's features into a grammar perfectly aligned with the needs of today's AI/ML Engineers and Data Scientists.
Built on the [Redis Python](https://github.com/redis/redis-py/tree/master) client, RedisVL provides an intuitive interface for vector search, LLM caching, and conversational AI memory - all the core components needed for modern AI workloads.


## 😁 Helpful Links

For additional help, check out the following resources:
- [Getting Started Guide](https://docs.redisvl.com/en/stable/user_guide/01_getting_started.html)
- [API Reference](https://docs.redisvl.com/en/stable/api/index.html)
- [Example Gallery](https://docs.redisvl.com/en/stable/examples/index.html)
- [Redis AI Recipes](https://github.com/redis-developer/redis-ai-resources)
- [Official Redis Vector API Docs](https://redis.io/docs/interact/search-and-query/advanced-concepts/vectors/)


## 🫱🏼‍🫲🏽 Contributing

Please help us by contributing PRs, opening GitHub issues for bugs or new feature ideas, improving documentation, or increasing test coverage. [Read more about how to contribute!](CONTRIBUTING.md)

## 🚧 Maintenance
Expand Down
1 change: 0 additions & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ reranker
cache
message_history
router
threshold_optimizer
```

26 changes: 0 additions & 26 deletions docs/api/threshold_optimizer.rst

This file was deleted.

Loading