任务
基于 LlamaIndex 构建自己的 RAG 知识库,寻找一个问题 A 在使用 LlamaIndex 之前InternLM2-Chat-1.8B模型不会回答,借助 LlamaIndex 后 InternLM2-Chat-1.8B 模型具备回答 A 的能力。
实践
步骤一:启动虚拟环境,安装 Llamaindex
conda activate your_env_name
pip install einops
pip install protobuf
pip install llama-index==0.10.38 llama-index-llms-huggingface==0.2.0 "transformers[torch]==4.41.1" "huggingface_hub[inference]==0.23.1" huggingface_hub==0.23.1 sentence-transformers==2.7.0 sentencepiece==0.2.0
步骤二:下载 Sentence Transformer 模型;下载 NLTK 相关资源
步骤三:LlamaIndex HuggingFaceLLM
运行脚本
python llamaindex_internlm.py
回答的效果并不好,并不是我们想要的xtuner。
步骤四: LlamaIndex RAG
创建RAG知识库
借助RAG技术后,就能获得我们想要的答案了
步骤五:LlamaIndex web