AlpacaToMessages¶
- class torchtune.data.AlpacaToMessages(train_on_input: bool = True, column_map: Optional[Dict[str, str]] = None)[source]¶
Message transform class for Alpaca-style datasets with “instruction”, “input”, and “output” (or equivalent fields specified in column_map) columns. User messages are formed from the instruction + input columns and assistant messages are formed from the output column. Prompt templating is conditional on the presence of the “input” column, and thus is handled directly in this transform class instead of a dedicated
PromptTemplate
class due to this custom logic.- Parameters:
train_on_input (bool) – Whether the model is trained on the user prompt or not. Default is True.
column_map (Optional[Dict[str, str]]) – a mapping to change the expected “instruction”, “input”, and “output” column names to the actual column names in the dataset. Default is None, keeping the default column names.