InstructTemplate¶
- class torchtune.data.InstructTemplate[source]¶
Interface for instruction templates. Each template should include the template prompt with placeholders for the data inputs.
- abstract classmethod format(sample: Mapping[str, Any], column_map: Optional[Dict[str, str]] = None) str [source]¶
Format the prompt template with the given arguments.
- Parameters:
sample (Mapping[str, Any]) – a single data sample with various fields
column_map (Optional[Dict[str, str]]) – a mapping from the expected placeholder names in the template to the column names in the sample. If None, assume these are identical. Note: if the sample output is not named as “output” in the dataset, you always need to map it to “output” in column_map.
- Returns:
The formatted prompt