RUC-NLPIR / FlashRAG

⚡FlashRAG: A Python Toolkit for Efficient RAG Research
https://arxiv.org/abs/2405.13576
MIT License
891 stars 69 forks source link

关于模型更换问题 #41

Closed oooo111 closed 1 week ago

oooo111 commented 2 weeks ago

作者你好,如果我想使用Llama3 70B的模型 ,需要更改哪些参数

ignorejjj commented 2 weeks ago

config.yaml文件里面的model2path里面加上模型名称和对应的路径,然后再generaotr_model里面填上模型名称即可。

oooo111 commented 2 weeks ago

model2path: e5: "intfloat/e5-base-v2" bge: "intfloat/e5-base-v2" contriever: "facebook/contriever" llama2-7B-chat: "meta-llama/Llama-2-7b-chat-hf" llama2-7B: "meta-llama/Llama-2-7b-hf" llama2-13B: "meta-llama/Llama-2-13b-hf" llama2-13B-chat: "meta-llama/Llama-2-13b-chat-hf" llama3-70B-instruct: "/p300s/apod/caoyr/LLM+AI/Llama3-70B-Chinese-Chat"

generator_model: "llama3-70B-instruct" # name or path of the generator model 然后我在终端运行python simple_pipeline.py 把--model_path换成我对应模型就行了是嘛

ignorejjj commented 2 weeks ago

是的。但是默认的prompt模板是英文和文档都是英文,如果要改成中文可以参考: 中文demo

oooo111 commented 2 weeks ago

感谢你的帮助

oooo111 commented 2 weeks ago

作者你好,我想请问你一个问题,我构建了一个QA的数据库,但是retrieval检索到的top k document基本与我的Query和answer的关联度很低,我想请问可能的原因是什么?

ignorejjj commented 2 weeks ago

用的是什么模型和数据库?

oooo111 commented 2 weeks ago

我自己构建的一个植物数据库,大概1400条数据。 其中检索的模型使用e5 语言模型用llama 8B 其它配置相同,使用的是simple pipeline

ignorejjj commented 2 weeks ago

e5和llama只支持英文,是不是语言问题

oooo111 commented 2 weeks ago

我的数据库都是英文构建的,使用的也是英文的语言模型和e5 后面更改过来了

oooo111 commented 2 weeks ago

如果是生成的内容不太理想,可以考虑将8B的换成70B吗?

ignorejjj commented 2 weeks ago

如果检索质量很差,换生成模型也很难做好。能否提供一下构建index的代码和设置?

oooo111 commented 2 weeks ago

构建index代码就是用库里面的index_builder.py 配置几乎还是用框架里的没变 直接用框架里面的生成的index

检索库的类型类似: {"id": 0, "Title": "Please explain what 1000-grain weight means.", "content": "The 1000-grain weight mean is Weight of the 1000-dehulled grains having pericarp (seed coat).\n"} {"id": 1, "Title": "Please explain what ear length means.", "content": "The ear length mean is An ear infructescence morphology trait (TO:0000976) that is the length of an ear infructescence (PO:0025597) from base to tip.\n"}

oooo111 commented 2 weeks ago

python index_builder.py \ --retrieval_method ---- \ --model_path ---- \ --corpus_path ./indexes/x.jsonl \ --save_dir indexes_x \ --use_fp16 \ --max_length 200 \ --batch_size 32 \ --pooling_method mean \ --faiss_type Flat

ignorejjj commented 2 weeks ago

设置上看起来没问题,就是数据库文本偏短,可以用bm25试试。

oooo111 commented 1 week ago

请问如果使用simple——pipeline 怎么更改成bm25 谢谢

oooo111 commented 1 week ago

我下载了BM25模型并保存 然后再basic_config中改成retrieval_method: "BM25"

python index_builder.py \ --retrieval_method BM25 \ --model_path /p300s/apod/caoyr/LLM+AI/FlashRAG-main/BM25/ \ --corpus_path ./indexes/GWAS.jsonl \ --save_dir indexes_GWAS_BM25/ \ --use_fp16 \ --max_length 200 \ --batch_size 32 \ --pooling_method mean \ --faiss_type Flat

但是报错AttributeError: 'Index_Builder' object has no attribute 'have_contents'

ignorejjj commented 1 week ago

修复了一个小问题,拉取最新代码然后用下面的命令:

python -m flashrag.retriever.index_builder \
    --retrieval_method bm25 \
    --corpus_path ./indexes/GWAS.jsonl \
    --save_dir indexes_GWAS_BM25/
oooo111 commented 1 week ago

作者你好,请问如果仅仅使用simple_pipeline.py 构建RAG,这种类型是属于Native RAG类型吗

ignorejjj commented 1 week ago

是的,其他方法可以参考: https://github.com/RUC-NLPIR/FlashRAG/blob/main/docs/reproduce_experiment.md

oooo111 commented 1 week ago

{"id": 0, "Title": "Please explain what arachidic acid content means.", "content": "Please explain what arachidic acid content means.\nThe arachidic acid content mean is Measures the arachidic acid content in a plant or plant part.\n"}

这种QA类型的数据能够适配到其它所有的方法吗

ignorejjj commented 1 week ago

不一定,得自己测试

oooo111 commented 1 week ago

感谢作者对我这个刚入门的小白指点,我在你附近有时间去你们学校请你吃饭哈哈。