Preference pairs
Use preference pairs to train a model to prefer one answer over another. See Datasets for dataset formats and registration.
Use preference datasets for DPO. For evaluations, supply chat examples instead.
Each line is one JSON object with a prompt array, a chosen answer, a rejected answer and an optional tools list. The messages take the same form as in a chat row. The following example is one pair whose chosen answer calls a tool:
{"tools":[{"type":"function","function":{
"name":"get_weather",
"description":"Look up the current weather for a city",
"parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}],
"prompt":[
{"role":"system","content":"You are a weather assistant."},
{"role":"user","content":"What is the weather in Wellington?"}
],
"chosen":{"role":"assistant","content":"","tool_calls":[{"id":"call_1","type":"function",
"function":{"name":"get_weather","arguments":{"city":"Wellington"}}}]},
"rejected":{"role":"assistant","content":"It is sunny everywhere today."}}
The prompt is the conversation the answers reply to, so it ends with a user message or with the tool messages that answer its last calls. An assistant message in the prompt may carry text and tool_calls together. Each answer is one assistant message and follows the rules of a chat row’s answer: it may carry text and tool_calls together, and its calls need no tool message.
Each answer must be a non-empty assistant message, and the chosen and rejected answers must differ. Use text only. Registration names the line and reason if a pair is invalid.
A dataset holds chat rows or preference pairs. Use --format preference-jsonl-v1 to declare preference pairs. Otherwise, registration infers the format from the first non-blank line, in examples-00000.jsonl for a ZIP file of shards. Do not mix the two formats. The registry datasets register command reports how many pairs it registered.