Skip to main content

AlpacaItem

Represents an instruction-response item in the Alpaca format. Appropripate for both cases where input field is empty, or populated. Provides parsing from string format using the class method from_string(). Parameters:
  • instruction (str): The instruction/question/prompt
  • input (str): Input context or examples (put empty string if none)
  • output (str): The response/answer to the instruction

no_section_markers

Ensures fields don’t contain section markers like ’### Response:‘

from_string

Creates an AlpacaItem from a formatted string. Parameters:
  • text: String in either of these formats: With input: ### Instruction: {instruction} ### Input: {input} ### Response: {response} Without input: ### Instruction: {instruction} ### Response: {response}
Returns: AlpacaItem: Parsed instance

to_string

Returns: str: Formatted string representation with sections markers