diff --git a/docs/en/Cookbook/rag.md b/docs/en/Cookbook/rag.md index f00e3153..d6735198 100644 --- a/docs/en/Cookbook/rag.md +++ b/docs/en/Cookbook/rag.md @@ -120,7 +120,7 @@ Now that we have two different retrieval functions returning results in differen # Part8 reranker = Reranker(name="ModuleReranker", - model="bge-reranker-large", + model=lazyllm.OnlineEmbeddingModule(type="rerank"), topk=1) ``` @@ -179,7 +179,7 @@ retriever2 = lazyllm.Retriever(doc=documents, # Part8 reranker = lazyllm.Reranker(name='ModuleReranker', - model="bge-reranker-large", + model=lazyllm.OnlineEmbeddingModule(type="rerank"), topk=1) # Part3 @@ -251,7 +251,7 @@ with lazyllm.pipeline() as ppl: topk=3) ppl.reranker = lazyllm.Reranker(name='ModuleReranker', - model="bge-reranker-large", + model=lazyllm.OnlineEmbeddingModule(type="rerank"), topk=1) | bind(query=ppl.input) ppl.formatter = ( diff --git a/docs/zh/Cookbook/rag.md b/docs/zh/Cookbook/rag.md index f6b26fdb..429e3a22 100644 --- a/docs/zh/Cookbook/rag.md +++ b/docs/zh/Cookbook/rag.md @@ -179,7 +179,7 @@ retriever2 = lazyllm.Retriever(doc=documents, # Part8 reranker = lazyllm.Reranker(name='ModuleReranker', - model="bge-reranker-large", + model=lazyllm.OnlineEmbeddingModule(type="rerank"), topk=1) # Part3 @@ -250,7 +250,7 @@ with lazyllm.pipeline() as ppl: topk=3) ppl.reranker = lazyllm.Reranker(name='ModuleReranker', - model="bge-reranker-large", + model=lazyllm.OnlineEmbeddingModule(type="rerank"), topk=1) | bind(query=ppl.input) ppl.formatter = ( diff --git a/lazyllm/docs/tools.py b/lazyllm/docs/tools.py index 65ea5b2f..8a0df141 100644 --- a/lazyllm/docs/tools.py +++ b/lazyllm/docs/tools.py @@ -290,12 +290,12 @@ >>> import lazyllm >>> from lazyllm.tools import Document, Reranker, Retriever >>> m = lazyllm.OnlineEmbeddingModule() ->>> documents = Document(dataset_path='rag_master', embed=m, manager=False) +>>> documents = Document(dataset_path='/path/to/user/data', embed=m, manager=False) >>> retriever = Retriever(documents, group_name='CoarseChunk', similarity='bm25', similarity_cut_off=0.01, topk=6) ->>> reranker = Reranker(name='ModuleReranker', model='bg-reranker-large', topk=1) +>>> reranker = Reranker(name='ModuleReranker', model='bge-reranker-large', topk=1) >>> ppl = lazyllm.ActionModule(retriever, reranker) >>> ppl.start() ->>> print(ppl("query")) +>>> print(ppl("user query")) ''') # ---------------------------------------------------------------------------- # @@ -346,19 +346,19 @@ >>> import lazyllm >>> from lazyllm.tools import Retriever, Document, SentenceSplitter >>> m = lazyllm.OnlineEmbeddingModule() ->>> documents = Document(dataset_path='your_doc_path', embed=m, manager=False) +>>> documents = Document(dataset_path='/path/to/user/data', embed=m, manager=False) >>> rm = Retriever(documents, group_name='CoarseChunk', similarity='bm25', similarity_cut_off=0.01, topk=6) >>> rm.start() ->>> print(rm("query")) +>>> print(rm("user query")) >>> m1 = lazyllm.TrainableModule('bge-large-zh-v1.5').start() ->>> document1 = Document(dataset_path='your_doc_path', embed={'online':m , 'local': m1}, manager=False) +>>> document1 = Document(dataset_path='/path/to/user/data', embed={'online':m , 'local': m1}, manager=False) >>> document1.create_node_group(name='sentences', transform=SentenceSplitter, chunk_size=1024, chunk_overlap=100) >>> retriever = Retriever(document1, group_name='sentences', similarity='cosine', similarity_cut_off=0.4, embed_keys=['local'], topk=3) ->>> print(retriever("query")) ->>> document2 = Document(dataset_path='your_doc_path', embed={'online':m , 'local': m1}, manager=False) +>>> print(retriever("user query")) +>>> document2 = Document(dataset_path='/path/to/user/data', embed={'online':m , 'local': m1}, manager=False) >>> document2.create_node_group(name='sentences', transform=SentenceSplitter, chunk_size=512, chunk_overlap=50) >>> retriever2 = Retriever([document1, document2], group_name='sentences', similarity='cosine', similarity_cut_off=0.4, embed_keys=['local'], topk=3) ->>> print(retriever2("query")) +>>> print(retriever2("user query")) ''') # ---------------------------------------------------------------------------- # @@ -430,15 +430,16 @@ add_example('LLMParser.transform', ''' >>> import lazyllm ->>> from lazyllm.tools import LLMParser, TrainableModule ->>> llm = TrainableModule("internlm2-chat-7b") ->>> m = lazyllm.TrainableModule("bge-large-zh-v1.5") +>>> from lazyllm.tools import LLMParser +>>> llm = lazyllm.TrainableModule("internlm2-chat-7b").start() +>>> m = lazyllm.TrainableModule("bge-large-zh-v1.5").start() >>> summary_parser = LLMParser(llm, language="en", task_type="summary") >>> keywords_parser = LLMParser(llm, language="en", task_type="keywords") ->>> documents = Document(dataset_path='your_doc_path', embed=m, manager=False) ->>> rm = Retriever(documents, group_name='CoarseChunk', similarity='bm25', similarity_cut_off=0.01, topk=6) ->>> summary_result = summary_parser.transform(rm[0]) ->>> keywords_result = keywords_parser.transform(rm[0]) +>>> documents = lazyllm.Document(dataset_path="/path/to/your/data", embed=m, manager=False) +>>> rm = lazyllm.Retriever(documents, group_name='CoarseChunk', similarity='bm25', topk=6) +>>> doc_nodes = rm("test") +>>> summary_result = summary_parser.transform(doc_nodes[0]) +>>> keywords_result = keywords_parser.transform(doc_nodes[0]) ''') # ---------------------------------------------------------------------------- #