From db371fb0088c143998a8e54cb580395e16d5b045 Mon Sep 17 00:00:00 2001 From: wangzhihong Date: Thu, 4 Jul 2024 20:05:39 +0800 Subject: [PATCH] Update README_zh-CN.md --- ecosystem/README_zh-CN.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ecosystem/README_zh-CN.md b/ecosystem/README_zh-CN.md index 8ba4b7a..b2ff57a 100644 --- a/ecosystem/README_zh-CN.md +++ b/ecosystem/README_zh-CN.md @@ -265,7 +265,33 @@ from lazyllm import TrainableModule, WebModule m = TrainableModule('internlm2-chat-7b').trainset('/patt/to/your_data.json') WebModule(m).update().wait() ``` +值的一提的是,无论您用InternLM系列的任何一个模型,都可以使用LazyLLM进行推理和微调,您都无需考虑模型的切分策略,也无需考虑模型的特殊token。
+如果您想搭建自己的RAG应用,那么您无需像使用LangChain一样先启动服务推理服务,再配置ip和端口去启动应用程序。参考如下代码,您可以借助LazyLLM,使用InternLM系列的模型,十行代码搭建高度定制的RAG应用,且附带文档管理服务: -如果您按照[LazyLLM搭建RAG应用](https://github.com/LazyAGI/LazyLLM/blob/main/README.CN.md)提供的教程操作,就可以借助LazyLLM,使用internLM系列的模型,十行代码搭建高度定制的RAG应用,且附带文档管理服务。 +
+点击获取import和prompt + +```python + +import os +import lazyllm +from lazyllm import pipeline, parallel, bind, _0, Document, Retriever, Reranker + +prompt = '你将扮演一个人工智能问答助手的角色,完成一项对话任务。在这个任务中,你需要根据给定的上下文以及问题,给出你的回答。' +``` +
+ +```python +documents = Document(dataset_path='/file/to/yourpath', embed=TrainableModule('bge-large-zh-v1.5')) +with pipeline() as ppl: + with parallel().sum as ppl.prl: + prl.retriever1 = Retriever(documents, parser='CoarseChunk', similarity_top_k=6) + prl.retriever2 = Retriever(documents, parser='SentenceDivider', similarity='chinese_bm25', similarity_top_k=6) + ppl.reranker = Reranker(types='ModuleReranker', model='bge-reranker-large') | bind(ppl.input, _0) + ppl.post_processer = lambda nodes: f'《{nodes[0].metadata["file_name"].split(".")[0]}》{nodes[0].get_content()}' if len(nodes) > 0 else '未找到' + ppl.formatter = (lambda ctx, query: dict(context_str=ctx, query_str=query)) | bind(query=ppl.input) + ppl.llm = lazyllm.TrainableModule('internlm2-chat-7b').prompt(lazyllm.ChatPrompter(prompt, extro_keys=['context_str'])) +mweb = lazyllm.WebModule(ppl, port=23456).start().wait() +``` LazyLLM官方文档: https://lazyllm.readthedocs.io/