Shortcuts

AlpacaInstructTemplate

class torchtune.data.AlpacaInstructTemplate[source]

Prompt template for Alpaca-style datasets. Template prompt changes slightly depending on if there’s an instruction + input or just an instruction.

classmethod format(sample: Mapping[str, Any], column_map: Optional[Dict[str, str]] = None) str[source]

Generate prompt from instruction and input.

Parameters:
  • sample (Mapping[str, Any]) – a single data sample with instruction

  • 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.

Returns:

The formatted prompt

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources