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
  splits:
  - name: train
    num_bytes: 20156792
    num_examples: 82612
  download_size: 12371690
  dataset_size: 20156792
task_categories:
- text-generation
language:
- en
tags:
- SFT
size_categories:
- 10K<n<100K
pretty_name: self_instruct (eng)
---

# Self instruct

- Source: https://github.com/yizhongw/self-instruct
- Num examples: 82,612
- Language: English

```python
from datasets import load_dataset

load_dataset("tdtunlp/self_instruct_en")
```

- Format for Instruction task

```python
def preprocess(
    sample, 
    instruction_key="### Instruction:",
    input_key="Input:",
    response_key="<|endofprompt|>",
    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:
Make a list of 10 ways to help students improve their study skills.
<|endofprompt|>
1. Make a schedule for studying and stick to it.
2. Study in the same place every time.
3. Set goals for yourself.
4. Take breaks when you need them.
5. Don't cram before an exam.
6. Get enough sleep.
7. Eat healthy food.
8. Exercise regularly.
9. Find a study partner.
10. Reward yourself after completing a task.
<|endoftext|>
"""
```