fix(dataset): use supported default QA model (#3965)
parent
402f69832e
commit
0ec945fe5d
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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许可证 - 可自由用于研究和项目。
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
Loading…
Reference in New Issue