Alpaca Dataset Loader #
Parses Stanford Alpaca-format JSON datasets for instruction finetuning.
Format #
[
{
"instruction": "Give three tips for staying healthy.",
"input": "",
"output": "1. Eat a balanced diet..."
},
...
]
Prompt Template #
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{instruction}
### Input:
{input}
### Response:
{output}
The model is trained with teacher forcing: the loss is computed only on the output tokens (after "### Response:\n").
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Format an Alpaca example into the standard prompt template
Equations
- One or more equations did not get rendered due to their size.
Instances For
Format the full sequence (prompt + output) for training
Equations
Instances For
def
Hesper.Training.AlpacaDataset.tokenizeExample
(encode : String → Array Nat)
(ex : Example)
(eosToken : Nat)
(maxSeqLen : Nat := 512)
:
Tokenize an Alpaca example using the provided encode function.
@param encode Tokenizer encode function (String → Array Nat) @param example The Alpaca example @param eosToken End-of-sequence token ID @param maxSeqLen Maximum sequence length (truncate if longer) @return TokenizedExample with prompt boundary marked
Equations
- One or more equations did not get rendered due to their size.
Instances For
Print dataset statistics
Equations
- One or more equations did not get rendered due to their size.