StackExchangedPairedTemplate¶
- class torchtune.data.StackExchangedPairedTemplate[source]¶
Prompt template for preference datasets similar to StackExchangedPaired.
Question: <YOUR QUESTION HERE> Answer:
- classmethod format(sample: Mapping[str, Any], column_map: Optional[Dict[str, str]] = None) str [source]¶
Generate prompt from instruction and input.
- Parameters:
Examples
>>> # Simple question >>> StackExchangedPairedTemplate.format(sample={"question": "What is the capital of France?"}) Question: What is the capital of France?\n\nAnswer:
>>> # Question with column map where the 'question' key is actually named 'prompt' in the given sample >>> StackExchangedPairedTemplate.format( ... sample={"prompt": "What is the capital of France?"}, ... column_map={"question": "prompt"} ... ) Question: What is the capital of France?\n\nAnswer:
- Returns:
The formatted prompt