qaap
1.0.0

pip install -r requirements.txtmain.pyでOpenai APIキーを設定しますTimeQA実験を実行します
python main.py
--prompt_file timeqa.json
--given_context 1
--dataset timeqa
--data_file test_hard.jsonl
--max_slice_length 512
--slice_stride 384
--return_search_passage content
--model_name gpt-3.5-turbo
--resume_id -1
TempquestionsとTimeQuestionsの実験を実行します
python main.py
--prompt_file timequestions.json
--given_context 0
--dataset tempquestion
--data_file test.jsonl
--max_slice_length 512
--slice_stride 384
--return_search_passage content
--model_name gpt-3.5-turbo
--resume_id -1
出力は次のように見えます
0 Joachim Löw was the coach of which team between Jan 1997 and Aug 1997?
'''python
query = {"subject": "Joachim Löw", "relation": "coach of", "object": None, "time": {"start": datetime(1997, 1, 1), "end": datetime(1997, 8, 31)}}
answer_key = "object"
'''
Search:
'''python
entities_to_search = ["Joachim Löw"]
'''
--------------------------------------------------
Generate a background document from Wikipedia to answer the given question:Joachim Löw is a German football coach and former player. He was the head coach of VfB Stuttgart from July 1996 to October 1998.
Extract information relevant to the query:
'''python
information.append({"subject": "Joachim Löw", "relation": "coach of", "object": "VfB Stuttgart", "time": {"start": datetime(1996, 7, 1), "end": datetime(1998, 10, 31)}})
'''
**************************************************
Extract information relevant to the query:
'''python
information.append({"subject": "Joachim Löw", "relation": "coach of", "object": None, "time": {"start": datetime(1997, 1, 1), "end": datetime(1997, 8, 31)}})
'''
...
calc_metrics_with_check_and_match.pyでfile_path設定して実行します。
この作業では、時間制限のあるQAに焦点を当てています。ただし、フレームワークを変更して、他の制約付きベースのQAタスクに一般化することができます。重要なのは、制約をPythonクラスとして定義することです。Pythonクラスは、制約がどの程度満たされているかを測定し、 calc_metrics_with_check_and_match.pyのmatch関数を再定義できるはずです。
gpt-3.5-turbo-0301ですべての実験を実行します。ただし、 gpt-3.5-turbo-0613やgpt-3.5-turbo-1106のような更新されたバージョンは異なる動作をしていることがわかりました。
QAAPが面白いか便利だと思うなら、紙を引用してこのレポを主演させてください、ありがとう! [email protected]にお気軽にお問い合わせいただくか、質問がある場合は問題を開きます。
@article { zhu2023qaap ,
title = { Question Answering as Programming for Solving Time-Sensitive Questions } ,
author = { Zhu, Xinyu and Yang, Cheng and Chen, Bei and Li, Siheng and Lou, Jian-Guang and Yang, Yujiu } ,
journal = { arXiv preprint arXiv:2305.14221 } ,
year = { 2023 }
}