fix(dataset): use supported default QA model (#3965)

main
xxxxx 2026-10-07 23:54:36 +08:00 committed by GitHub
parent 402f69832e
commit 0ec945fe5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 3 deletions

View File

@ -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.
MIT License - feel free to use this tool for your research and projects.

View File

@ -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许可证 - 可自由用于研究和项目。
MIT许可证 - 可自由用于研究和项目。

View File

@ -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

View File

@ -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()