Closed liulian3564 closed 2 months ago
config_dict里面的data_dir
对应的就是所有数据集存放的文件夹,然后设置dataset_name
为对应的数据集名称就可以。
比如data_dir
设置为dataset/
, dataset_name
设置为new_dataset
,那新的数据集应该放在dataset/new_dataset/
下面,类似于: dataset/new_dataset/train.jsonl
.. 格式需要与定义的一致。
您好,之前我用的您给的“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)
只需要在config dict里面指定dataset_name为wiki_qa即可,这会自动覆盖yaml文件里面的设置。
已经把config_dict 里加了dataset_name,还是报错
File "D:\FLASHRAG\example.py", line 42, in
检查一下你的那个dataset文件里面有没有test.jsonl文件。如果没有的话得改一下用的split
是由test.json文件的,老师。AttributeError: 'NoneType' object has no attribute 'question'。wiki_qa里是由question的呀,我刚看了这个json文件,他为什么会说没有呢
我们huggingface上提供的数据文件都是jsonl
格式的,参考: https://huggingface.co/datasets/ignore/FlashRAG_datasets/viewer/wiki_qa。
用json
格式的数据集会有问题,需要处理成能够读取的形式。
是jsonl,不好意思。图中是我的文件路径。感谢!!!
wiki_qa里面的文件需要改成test.jsonl
想问一下我想修改数据集的话,需要还修改哪些代码呢? 我好像没找到哪里有导入数据集路径的地方。谢谢!