Skip to content

Commit 9b870ca

Browse files
author
Sam Partee
authored
Update README (#84)
1 parent dfc9939 commit 9b870ca

File tree

2 files changed

+27
-180
lines changed

2 files changed

+27
-180
lines changed

README.md

Lines changed: 22 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -42,202 +42,44 @@ RedisVL provides a client library that enables you to harness the power and flex
4242
RedisVL has a host of powerful features designed to streamline your vector database operations.
4343

4444
1. **Index Management**: RedisVL allows for indices to be created, updated, and deleted with ease. A schema for each index can be defined in yaml or directly in python code and used throughout the lifetime of the index.
45+
- [Getting Started with SearchIndex](https://www.redisvl.com/user_guide/getting_started_01.html)
46+
- [``rvl`` Command Line Interface](https://www.redisvl.com/user_guide/cli.html)
4547

46-
2. **Embedding Creation**: RedisVL integrates with OpenAI, HuggingFace, and GCP VertexAI to simplify the process of vectorizing unstructured data. *Image support coming soon. Submit a PR for new vectorizers.*
48+
2. **Embedding Creation**: RedisVLs [Vectorizers](https://www.redisvl.com/user_guide/vectorizers_04.html) integrate with common embedding model services to simplify the process of vectorizing unstructured data.
49+
- [OpenAI](https://www.redisvl.com/api/vectorizer.html#openaitextvectorizer)
50+
- [HuggingFace](https://www.redisvl.com/api/vectorizer.html#hftextvectorizer)
51+
- [GCP VertexAI](https://www.redisvl.com/api/vectorizer.html#vertexaitextvectorizer)
4752

48-
3. **Vector Search**: RedisVL provides robust search capabilities that enable you to query vectors synchronously and asynchronously. Hybrid queries that utilize tag, geographic, numeric, and other filters like full-text search are also supported.
53+
3. **Vector Search**: RedisVL provides robust search capabilities that enable you quickly define complex search queries with flexible abstractions.
54+
- [VectorQuery](https://www.redisvl.com/api/query.html#vectorquery) - Flexible vector queries with filters
55+
- [RangeQuery](https://www.redisvl.com/api/query.html#rangequery) - Vector search within a defined range
56+
- [CountQuery](https://www.redisvl.com/api/query.html#countquery) - Count the number of records given attributes
57+
- [FilterQuery](https://www.redisvl.com/api/query.html#filterquery) - Filter records given attributes
4958

50-
4. **Powerful Abstractions**
51-
- **Semantic Caching**: `LLMCache` is a semantic caching interface built directly into RedisVL. It allows for the caching of generated output from LLMs like GPT-3 and others. As semantic search is used to check the cache, a threshold can be set to determine if the cached result is relevant enough to be returned. If not, the model is called and the result is cached for future use. This can increase the QPS and reduce the cost of using LLM models in production.
59+
3. **[Hybrid (Filtered) queries](https://www.redisvl.com/user_guide/hybrid_queries_02.html)** that utilize tag, geographic, numeric, and other filters like full-text search are also supported.
5260

61+
4. **Semantic Caching**: [`LLMCache`](https://www.redisvl.com/user_guide/llmcache_03.html) is a semantic caching interface built directly into RedisVL. Semantic caching is a popular technique to increase the QPS and reduce the cost of using LLM models in production.
5362

54-
## Installation
63+
5. [**JSON Storage**](https://www.redisvl.com/user_guide/hash_vs_json_05.html): RedisVL supports storing JSON objects, including vectors, in Redis.
5564

56-
Please note that this library is still under heavy development, and while you can quickly try RedisVL and deploy it in a production environment, the API may be subject to change at any time.
65+
## Installation
5766

5867
Install `redisvl` using `pip`:
5968

6069
```bash
6170
pip install redisvl
6271
```
6372

64-
This library supports the use of hiredis, so you can also install by running:
65-
66-
```bash
67-
pip install redisvl[hiredis]
68-
```
69-
70-
Then make sure to have [Redis](https://redis.io) accessible with Search & Query features enabled on [Redis Cloud](https://redis.com/try-free) or locally in docker with [Redis Stack](https://redis.io/docs/getting-started/install-stack/docker/):
71-
72-
```bash
73-
docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
74-
```
75-
76-
This will also spin up the [Redis Insight GUI](https://redis.com/redis-enterprise/redis-insight/) at `http://localhost:8001`.
77-
78-
79-
80-
## Example Usage
81-
82-
### Index Management
83-
84-
Indices can be defined through yaml specification, or json, that correspond directly to the Redis index, field names and arguments in `redis-py`. Take this example `idx.yaml` file:
85-
86-
```yaml
87-
index:
88-
name: user_index
89-
prefix: users
90-
91-
fields:
92-
# define tag fields
93-
tag:
94-
- name: user
95-
- name: job
96-
- name: credit_store
97-
# define numeric fields
98-
numeric:
99-
- name: age
100-
# define vector fields
101-
vector:
102-
- name: user_embedding
103-
dim: 3
104-
algorithm: hnsw
105-
distance_metric: cosine
106-
```
107-
108-
This would correspond to a dataset that looked something like:
109-
110-
| user | age | job | credit_score | user_embedding |
111-
|-------|-----|------------|--------------|-----------------------------------|
112-
| john | 1 | engineer | high | \x3f\x8c\xcc\x3f\x8c\xcc?@ |
113-
| mary | 2 | doctor | low | \x3f\x8c\xcc\x3f\x8c\xcc?@ |
114-
| joe | 3 | dentist | medium | \x3f\xab\xcc?\xab\xcc?@ |
115-
116-
117-
With the YAML schema, the RedisVL library can be used to create the index, load vectors and perform vector searches:
118-
```python
119-
120-
from redisvl.index import SearchIndex
121-
from redisvl.query import VectorQuery
122-
123-
# initialize the index and connect to local Redis
124-
index = SearchIndex.from_schema("idx.yaml")
125-
index.connect("redis://localhost:6379")
126-
127-
# create the index in Redis
128-
index.create(overwrite=True)
129-
130-
# load data into the index in Redis (list of dicts)
131-
index.load(data)
132-
133-
query = VectorQuery(
134-
vector=[0.1, 0.1, 0.5],
135-
vector_field_name="user_embedding",
136-
return_fields=["user", "age", "job", "credit_score"],
137-
num_results=3,
138-
)
139-
results = index.query(query)
140-
141-
```
142-
143-
### Redis Filter Expressions
144-
145-
RedisVL supports a variety of filter types, including tag, numeric, geographic, and full text search to create *Filter Expressions*. Filter expressions can be used to create hybrid queries which allow you to combine multiple complex data types (i.e. text and vector search) into a single query.
146-
147-
```python
148-
from redisvl.index import SearchIndex
149-
from redisvl.query import VectorQuery
150-
from redisvl.query.filter import Tag, Num, Geo, GeoRadius, Text
73+
For more instructions, see the [installation guide](https://www.redisvl.com/overview/installation.html).
15174

152-
# exact tag match
153-
is_sam = Tag("user") == "Sam"
75+
## Getting Started
15476

155-
# numeric range
156-
is_over_10 = Num("age") > 10
77+
To get started with RedisVL, check out the
78+
- [Getting Started Guide](https://www.redisvl.com/user_guide/getting_started_01.html)
79+
- [API Reference](https://www.redisvl.com/api/index.html)
80+
- [Example Gallery](https://www.redisvl.com/examples/index.html)
15781

158-
# geographic radius
159-
works_in_sf = Geo("location") == GeoRadius(37.7749, -122.4194, 10)
160-
161-
# full text search with fuzzy match
162-
is_engineer = Text("job") % "enginee*"
163-
164-
filter_expression = is_sam & is_over_10 & works_in_sf & is_engineer
165-
166-
query = VectorQuery(
167-
vector=[0.1, 0.1, 0.5],
168-
vector_field_name="user_embedding",
169-
return_fields=["user", "age", "job", "credit_score"],
170-
num_results=3,
171-
filter_expression=filter_expression,
172-
)
173-
results = index.query(query)
174-
175-
```
176-
177-
### Interoperability with core Redis Clients
178-
The purpose of RedisVL is **NOT** to fully replace your usage of the trusted Redis client libraries. It's simply here to make your life easier getting started and building generative AI applications on top of Redis. With that in mind, the RedisVL query interface and filter expressions can be ported and used with clients like `redis-py`.
179-
180-
Take the example filter expression from above:
181-
```python
182-
print(str(filter_expression))
183-
```
184-
185-
This prints the RediSearch hybrid filter expression:
186-
```
187-
'(((@user:{Sam} @age:[(10 +inf]) @location:[37.774900 -122.419400 10 km]) @job:enginee*)'
188-
```
189-
190-
Take the fully formed vector query from above:
191-
```python
192-
print(str(query))
193-
```
194-
195-
This prints the full RediSearch query, including hybrid filters and VSS:
196-
```
197-
'(((@user:{Sam} @age:[(10 +inf]) @location:[37.774900 -122.419400 10 km]) @job:enginee*)=>[KNN 3 @user_embedding $vector AS vector_distance] RETURN 5 user age job credit_score vector_distance SORTBY vector_distance ASC DIALECT 2 LIMIT 0 3'
198-
```
199-
200-
> Both of these query strings and expressions can be used with the core RediSearch API.
201-
202-
For example, use the RedisVL `query` object with the standard `redis-py` client:
203-
```python
204-
import redis
205-
206-
r = redis.Redis.from_url("redis://localhost:6379")
207-
208-
results = r.ft("user_index").search(query.query, query.params)
209-
```
210-
211-
### Semantic cache
212-
213-
The ``LLMCache`` Interface in RedisVL can be used as follows.
214-
215-
```python
216-
from redisvl.llmcache.semantic import SemanticCache
217-
218-
cache = SemanticCache(
219-
redis_url="redis://localhost:6379",
220-
threshold=0.9, # semantic similarity threshold
221-
)
222-
223-
# check if the cache has a result for a given query
224-
cache.check("What is the capital of France?")
225-
[ ]
226-
227-
# store a result for a given query
228-
cache.store("What is the capital of France?", "Paris")
229-
230-
# cache will now have the query
231-
cache.check("What is the capital of France?")
232-
["Paris"]
233-
234-
# cache will still return the result if the query is similar enough
235-
cache.check("Question -- What really is the capital of France?")
236-
["Paris"]
237-
```
238-
<<<<<<< HEAD
239-
=======
24082

24183
## Contributing
84+
24285
Please help us by contributing PRs or opening GitHub issues for desired behaviors or discovered bugs. [Read more about how to contribute to RedisVL!](CONTRIBUTING.md)
243-
>>>>>>> 2ef8e43 (update contributing and reade)

docs/overview/installation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ If you use ZSH, remember to escape the brackets:
2929
$ pip install redisvl\[all\]
3030
```
3131

32+
This library supports the use of hiredis, so you can also install by running:
33+
34+
```bash
35+
pip install redisvl[hiredis]
36+
```
3237

3338
## Install RedisVL from Source
3439

0 commit comments

Comments
 (0)