# stanford_alpaca

> Code and documentation to train Stanford's Alpaca models, and generate the data

- Type: agent or tool
- Field: ML & AI
- Repository: https://github.com/tatsu-lab/stanford_alpaca
- GitHub stars: 30221
- Licence: Apache-2.0
- Language: Python
- Last push: 2024-07-17
- Page: https://imutechz.in/agents/stanford_alpaca

## What it is
Stanford Alpaca is a research repository for building instruction-following LLaMA models. It provides the 52K instruction-following dataset, data generation pipeline using text-davinci-003, fine-tuning code, and weight recovery tools. The model is fine-tuned from a 7B LLaMA base on data generated via a modified Self-Instruct approach. All components are licensed for non-commercial research use only.

## Features
- 52K unique instruction-following examples in JSON format
- Data generation pipeline using OpenAI's text-davinci-003
- Fine-tuning code for LLaMA 7B model
- Weight diff recovery to reconstruct Alpaca weights
- Prompt templates for training and inference
- Self-Instruct based generation with aggressive batch decoding

## Best for
- Reproducing the Alpaca instruction-tuning research
- Generating instruction-following datasets with LLMs
- Fine-tuning LLaMA models on instruction data
- Studying Self-Instruct methodology variations

## Pros
- Complete reproducible pipeline from data to model
- Open dataset with 52K diverse instructions
- Clear documentation and prompt templates
- Apache 2.0 code license for research flexibility

## Cons
- Non-commercial license (CC BY NC 4.0) for data and weights
- Requires OpenAI API key for data generation
- Base LLaMA weights not included (separate access needed)

## Install
```
pip install -r requirements.txt
```

## Usage
```
python -m generate_instruction generate_instruction_following_data
```

Tags: instruction-tuning, llama, alpaca, self-instruct, dataset, fine-tuning, research, nlp
