task_categories:text-generation size_categories:10K<n<100K language:en SFT region:us
---
dataset_info:
  features:
  - name: instruction
    dtype: string
  - name: input
    dtype: string
  - name: output
    dtype: string
  - name: text
    dtype: string
  splits:
  - name: train
    num_bytes: 46071779.64893658
    num_examples: 51848
  download_size: 24154901
  dataset_size: 46071779.64893658
task_categories:
- text-generation
language:
- en
tags:
- SFT
size_categories:
- 10K<n<100K
---
# Alpaca-Cleaned

- Source: https://huggingface.co/datasets/yahma/alpaca-cleaned
- Num examples: 51,848
- Language: English

```python
from datasets import load_dataset

load_dataset("tdtunlp/alpaca_en")
```

- Format for Instruction task

```python
def preprocess(
    sample, 
    instruction_key="### Instruction:",
    input_key="Input:",
    response_key="### Response:",
    end_key="<|endoftext|>"
):
    
    instruction = sample['instruction']
    input = sample['input']
    response = sample['output']
    
    if input:
        return {'text': """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
{instruction_key}
{instruction}
{input_key}
{input}
{response_key}
{response}
{end_key}""".format(
    instruction_key=instruction_key,
    instruction=instruction,
    input_key=input_key,
    input=input,
    response_key=response_key,
    response=response,
    end_key=end_key,
)}
    else:
        return {'text': """Below is an instruction that describes a task. Write a response that appropriately completes the request.
{instruction_key}
{instruction}
{response_key}
{response}
{end_key}""".format(
    instruction_key=instruction_key,
    instruction=instruction,
    response_key=response_key,
    response=response,
    end_key=end_key,
)}
"""
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Give three tips for staying healthy.
### Response:
1.Eat a balanced diet and make sure to include plenty of fruits and vegetables. 
2. Exercise regularly to keep your body active and strong. 
3. Get enough sleep and maintain a consistent sleep schedule.
<|endoftext|>
"""
```