RUC-NLPIR / FlashRAG

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

您好,我已经跑通了您readme里面新手指导给的玩具数据集,但是我替换了模型,换成了小量级的Qwen1.5-0.5B-Chat。 #46

Closed liulian3564 closed 2 months ago

liulian3564 commented 3 months ago

想问一下我想修改数据集的话,需要还修改哪些代码呢? 我好像没找到哪里有导入数据集路径的地方。谢谢!

ignorejjj commented 3 months ago

config_dict里面的data_dir对应的就是所有数据集存放的文件夹,然后设置dataset_name为对应的数据集名称就可以。

比如data_dir设置为dataset/, dataset_name设置为new_dataset,那新的数据集应该放在dataset/new_dataset/下面,类似于: dataset/new_dataset/train.jsonl.. 格式需要与定义的一致。

liulian3564 commented 3 months ago

您好,之前我用的您给的“nq”数据集,现在想换成“wiki_qa”。我通过检索,想把所有的nq换成“wiki_qa”,想问一下,yaml里面的“nq”也要改吗?太感谢了!!!! 以下是我的脚本和报错: from flashrag.config import Config from flashrag.utils import get_dataset from flashrag.pipeline import SequentialPipeline from flashrag.prompt import PromptTemplate

data_dir='FlashRAG/examples/quick_start/dataset/wiki_qa' index_path='flashrag/examples/quick_start/indexes/e5_Flat.index' corpus_path='flashrag/examples/quick_start/indexes/general_knowledge.jsonl' retriever_path='e5-base-v2' generator_name='Qwen1.5-0.5B-Chat' generator_path='Qwen1.5-0.5B-Chat'

config_dict = { 'data_dir': data_dir, 'index_path': index_path, 'corpus_path': corpus_path, 'model2path': {'e5': retriever_path, generator_name: generator_path}, 'generator_model': generator_name, 'retrieval_method': 'e5', 'metrics': ['em','f1','sub_em'], 'retrieval_topk': 1, 'save_intermediate_data': True, 'generation_params': {'do_sample': False}, }

config = Config(config_dict = config_dict)

all_split = get_dataset(config) test_data = all_split['test'] print('fdfff') pipeline = SequentialPipeline(config) print('fdfff')

prompt_templete = PromptTemplate( config, system_prompt = "Answer the question based on the given document. Only give me the answer and do not output any other words.\nThe following are given documents.\n\n{reference}", user_prompt = "Question: {question}\nAnswer:" ) pipeline = SequentialPipeline(config, prompt_template=prompt_templete)

output_dataset = pipeline.run(test_data, do_eval=True) print("---generation output---") print(output_dataset.pred) fe3d2977b40ef44b884b7bce3c25769

ignorejjj commented 3 months ago

只需要在config dict里面指定dataset_name为wiki_qa即可,这会自动覆盖yaml文件里面的设置。

liulian3564 commented 3 months ago

已经把config_dict 里加了dataset_name,还是报错 File "D:\FLASHRAG\example.py", line 42, in output_dataset = pipeline.run(test_data, do_eval=True) File "D:\FLASHRAG\FlashRAG\flashrag\pipeline\pipeline.py", line 78, in run input_query = dataset.question AttributeError: 'NoneType' object has no attribute 'question' 麻烦您看一下,谢谢您

ignorejjj commented 3 months ago

检查一下你的那个dataset文件里面有没有test.jsonl文件。如果没有的话得改一下用的split

liulian3564 commented 3 months ago

是由test.json文件的,老师。AttributeError: 'NoneType' object has no attribute 'question'。wiki_qa里是由question的呀,我刚看了这个json文件,他为什么会说没有呢

ignorejjj commented 3 months ago

我们huggingface上提供的数据文件都是jsonl格式的,参考: https://huggingface.co/datasets/ignore/FlashRAG_datasets/viewer/wiki_qa。 用json格式的数据集会有问题,需要处理成能够读取的形式。

liulian3564 commented 3 months ago

b4ae475d01b9af9d78d0758fc18319a 65cce87bbd9beabd93fddac10a1d0e7 f36c0774ef4cc659fe38378ff5868e2 是jsonl,不好意思。图中是我的文件路径。感谢!!!

ignorejjj commented 3 months ago

wiki_qa里面的文件需要改成test.jsonl