diff --git a/dataset/README b/dataset/README index 6c78bcaa..8ea8bc55 100644 --- a/dataset/README +++ b/dataset/README @@ -62,6 +62,8 @@ python dataset/qa_dataset.py generate \ --output_dir ./dataset/samples ``` +The script uses `gpt-5.6-sol` by default. + ### 3. View Results Display the generated QA pairs with their context: @@ -270,4 +272,4 @@ Feel free to submit issues and enhancement requests! ## License -MIT License - feel free to use this tool for your research and projects. \ No newline at end of file +MIT License - feel free to use this tool for your research and projects. diff --git a/dataset/README_zh.md b/dataset/README_zh.md index 2c4e5b0d..ad1efceb 100644 --- a/dataset/README_zh.md +++ b/dataset/README_zh.md @@ -73,6 +73,8 @@ python dataset/qa_dataset.py generate \ --output_dir ./dataset/samples ``` +脚本默认使用 `gpt-5.6-sol`。 + ### 3. 查看结果 展示生成的问答对及其上下文: @@ -281,4 +283,4 @@ python dataset/qa_dataset.py show \ ## 许可证 -MIT许可证 - 可自由用于研究和项目。 \ No newline at end of file +MIT许可证 - 可自由用于研究和项目。 diff --git a/dataset/qa_dataset.py b/dataset/qa_dataset.py index df4ee522..393d848b 100644 --- a/dataset/qa_dataset.py +++ b/dataset/qa_dataset.py @@ -33,6 +33,9 @@ import pandas as pd import openai +DEFAULT_QA_MODEL = "gpt-5.6-sol" + + def read_parquet(path): return pd.read_parquet(path) @@ -145,7 +148,7 @@ class QAAnsweringSystem: return "\n\n".join(context_parts) - def answer_question(self, qid: str, model: str = "gpt-4o-2024-05-13") -> str: + def answer_question(self, qid: str, model: str = DEFAULT_QA_MODEL) -> str: """ Use OpenAI API to answer question based on qid context diff --git a/dataset/tests/test_qa_dataset_default_model.py b/dataset/tests/test_qa_dataset_default_model.py new file mode 100644 index 00000000..d8c3e81a --- /dev/null +++ b/dataset/tests/test_qa_dataset_default_model.py @@ -0,0 +1,38 @@ +"""Regression test for the QA dataset model default.""" + +import importlib.util +from pathlib import Path +from types import SimpleNamespace +import unittest +from unittest.mock import Mock, patch + +import pandas as pd + + +SOURCE = Path(__file__).resolve().parents[1] / "qa_dataset.py" + + +class QADatasetDefaultModelTests(unittest.TestCase): + def test_default_model_reaches_openai_client(self): + spec = importlib.util.spec_from_file_location("qa_dataset_under_test", SOURCE) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + + client = Mock() + client.chat.completions.create.return_value = SimpleNamespace( + choices=[SimpleNamespace(message=SimpleNamespace(content="answer"))] + ) + queries = pd.DataFrame([{"id": "q1", "text": "question"}]) + corpus = pd.DataFrame([{"id": "p1", "text": "context"}]) + qrels = pd.DataFrame([{"qid": "q1", "pid": "p1"}]) + + with patch.object(module.openai, "Client", return_value=client): + system = module.QAAnsweringSystem(queries, corpus, qrels) + self.assertEqual(system.answer_question("q1"), "answer") + + request = client.chat.completions.create.call_args.kwargs + self.assertEqual(request["model"], "gpt-5.6-sol") + + +if __name__ == "__main__": + unittest.main()