Skip to content

Commit f887cff

Browse files
committed
update README and create-search-app.sh
1 parent d54b508 commit f887cff

File tree

5 files changed

+89
-8
lines changed

5 files changed

+89
-8
lines changed

Chinese.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Module 'LLM' loaded from /path/to/libredis-llm.so
211211

212212
#### Search Application
213213

214-
创建一个search(查询)应用,让它基于vector store中保存的数据来回答问题
214+
创建一个search(查询)应用,让它基于vector store中保存的私有数据来回答问题
215215

216216
- 调用LLM.CREATE-LLM创建一个LLM模型
217217
- 调用LLM.CREATE-VECTOR-STORE创建一个带LLM支持的vector store
@@ -232,6 +232,8 @@ Module 'LLM' loaded from /path/to/libredis-llm.so
232232
"The author of redis-llm is sewenew."
233233
```
234234

235+
[这里](https://github.com/sewenew/redis-llm/tree/main/examples/search-application)包含了基于Redis命令文档和redis-plus-plus文档构建私有数据检索的例子。
236+
235237
#### Chat Application
236238

237239
创建一个chat(聊天)应用,该应用能帮助LLM记住很长的聊天历史。

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- [Terminology](#terminology)
1616
- [LLM](#llm)
1717
- [Prompt](#prompt)
18-
- [Vector Store](#vector-store-2)
18+
- [Vector Store](#vector-store-1)
1919
- [Application](#application)
2020
- [Commands](#commands)
2121
- [LLM.CREATE-LLM](#llmcreate-llm)
@@ -211,7 +211,7 @@ Create a *hello world* application with LLM and prompt template (You must call L
211211

212212
#### Search Application
213213

214-
Create a search application which can answer questions based on data stored in the vector store.
214+
Create a search application which can answer questions based on your private data stored in the vector store.
215215

216216
- Call LLM.CREATE-LLM to create an LLM model.
217217
- Call LLM.CREATE-VECTOR-STORE to create a vector store with LLM support.
@@ -232,6 +232,8 @@ Create a search application which can answer questions based on data stored in t
232232
"The author of redis-llm is sewenew."
233233
```
234234

235+
Check [this](https://github.com/sewenew/redis-llm/tree/main/examples/search-application) for examples on building a private data searcher on Redis commands and redis-plus-plus.
236+
235237
#### Chat Application
236238

237239
Create a chat application which help LLM remember a long conversation history.

examples/search-application/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# create search application
2+
3+
You can use redis-llm to create a search application which can answer questions based on your private data stored in the vector store. Normally, you need to run the following steps:
4+
5+
- Call LLM.CREATE-LLM to create an LLM model.
6+
- Call LLM.CREATE-VECTOR-STORE to create a vector store with LLM support.
7+
- Call LLM.ADD to add your private data to the store.
8+
- Call LLM.CREATE-SEARCH to create a search application with LLM and vector store.
9+
- Call LLM.RUN to ask questions on your private data.
10+
11+
I splitted [Redis' commands documentation](https://github.com/redis/redis-doc/tree/master/commands), and [redis-plus-plus (C++ Redis client)'s README.md](https://github.com/sewenew/redis-plus-plus/blob/master/README.md) into segmentations. For each segmentation, I saved it into a file, and called OpenAI embedding API (model: text-embedding-ada-002) to generate their embeddings. These data and embeddings are located at *examples/search-application/embeddings.zip*. You can unzip it to add into vector store.
12+
13+
```
14+
unzip embeddings.zip
15+
```
16+
17+
```
18+
ls embeddings
19+
data redis-cmds-embedding redis-plus-plus-doc-embeddings
20+
```
21+
22+
You can find all segmentation files under *data* directory. *redis-cmds-embedding* and *redis-plus-plus-doc-embeddings* are embeddings files. Each embedding file contains pre-generated embeddings. Each line of the file contains data file name and data embedding, separated with "\t".
23+
24+
You can use *examples/search-application/create-search-app.sh* script to run create LLM model and vector store, add pre-genereated embeddings to the store, and create a search application. The following is the usage:
25+
26+
```Shell
27+
create-search-app.sh embedding-file data-path store-key llm-key openai-api-key search-key
28+
```
29+
30+
- *embedding-file*: Path to embedding file. e.g. examples/search-application/embeddings/redis-plus-plus-doc-embeddings
31+
- *data-path*: Path to data directory, e.g. examples/search-application/embeddings/data.
32+
- *store-key*: Redis key for the created vector store.
33+
- *llm-key*: Redis key for the created LLM model.
34+
- *openai-api-key*: Your OpenAI API key.
35+
- *search-key*: Redis key for the created search application.
36+
37+
Ensure you've already installed `redis-cli`, and launched Redis server on localhost with redis-llm module loaded:
38+
39+
```
40+
redis-cli module list
41+
1) 1) "name"
42+
2) "LLM"
43+
3) "ver"
44+
4) (integer) 1
45+
```
46+
47+
## Create a search application to ask question on Redis commands' documentation
48+
49+
Run the following command to load Redis documenation and embeddings:
50+
51+
```
52+
cd /path/to/redis-llm/examples/search-application
53+
54+
sh create-search-app.sh embeddings/redis-cmds-embedding embeddings/data redis-cmd-store openai-model $YOUR-OPENAI-API-KEY redis-cmd-searcher
55+
```
56+
57+
Ask questions on how to use Redis commands:
58+
59+
```
60+
redis-cli llm.run redis-cmd-searcher 'How to run set command?'
61+
```
62+
63+
## Create a search application to ask question on redis-plus-plus' documentation
64+
65+
Run the following command to load redis-plus-plus' documenation and embeddings:
66+
67+
```
68+
cd /path/to/redis-llm/examples/search-application
69+
70+
sh create-search-app.sh embeddings/redis-plus-plus-doc-embeddings embeddings/data redis-plus-plus-doc-store openai-model $YOUR-OPENAI-API-KEY redis-plus-plus-searcher
71+
```
72+
73+
Ask questions on redis-plus-plus:
74+
75+
```
76+
redis-cli llm.run redis-plus-plus-searcher 'Who is the author of redis-plus-plus?'
77+
```

docker/create-search-app.sh renamed to examples/search-application/create-search-app.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ redis_cli=redis-cli
2020

2121
if [ $# != 6 ]
2222
then
23-
echo "Usage: create-search-app.sh embedding-file data-path store-key openai-key openai-api-key search-key"
23+
echo "Usage: create-search-app.sh embedding-file data-path store-key llm-key openai-api-key search-key"
2424
exit -1
2525
fi
2626

2727
embedding_file=$1
2828
data_path=$2
2929
store_key=$3
30-
openai_key=$4
30+
llm_key=$4
3131
openai_api_key=$5
3232
search_key=$6
3333

34-
$redis_cli llm.create-llm "$openai_key" --params "{\"api_key\":\"$openai_api_key\"}"
35-
$redis_cli llm.create-vector-store "$store_key" --llm "$openai_key"
34+
$redis_cli llm.create-llm "$llm_key" --params "{\"api_key\":\"$openai_api_key\"}"
35+
$redis_cli llm.create-vector-store "$store_key" --llm "$llm_key"
3636

3737
while read line; do
3838
key=$(echo "$line" | cut -f1)
@@ -41,4 +41,4 @@ while read line; do
4141
cat $path | $redis_cli -x llm.add "$store_key" --embedding "$embedding"
4242
done <"$embedding_file"
4343

44-
$redis_cli llm.create-search "$search_key" --llm "$openai_key" --vector-store "$store_key"
44+
$redis_cli llm.create-search "$search_key" --llm "$llm_key" --vector-store "$store_key"
File renamed without changes.

0 commit comments

Comments
 (0)