File size: 6,721 Bytes
7dcb51d 6ab6c0a 7dcb51d 7d6fae3 7dcb51d b3325e2 7dcb51d 7200fa8 b3325e2 6ab6c0a b3325e2 7200fa8 6ab6c0a 7200fa8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
---
language:
- en
- multilingual
- de
- it
- es
- fr
tags:
- instruction-tuning
- text-generation-inference
- text2text-generation
widget:
- text: Write an essay about meditation. [EOI]
example_title: Essay Generation
- text: Give me 5 steps to clean my room. [EOI]
example_title: How-to Instructions
- text: How are the continents formed? [EOI]
example_title: Question-Answering
- text: >-
Prompt: A man draws a gun in a dark alley and asks for your wallet. You
begrudgingly obey. He throws it on the ground, shoots it till it screeches,
and turns to you; 'you are safe now'. Write a story about given prompt.
[EOI]
example_title: Story Generation
- text: >-
Write directions of a cooking recipe with these ingredients: chicken breast,
carrots, green peas, celery, butter, onion, flour, salt, black pepper,
celery seed, chicken broth, milk, unbaked pie crusts [EOI]
example_title: Recipe Generation
- text: >-
Schreiben Sie einen Blogbeitrag über die Vorteile des Lesens von Büchern.
[EOI]
example_title: German Essay Generation
inference:
parameters:
top_p: 0.9
do_sample: true
max_length: 50
datasets:
- akoksal/LongForm
---
## LongForm-LLaMA-7B-diff
The LongForm dataset is created by leveraging English corpus examples with reverse instructions. We select a diverse set of human-written documents from existing corpora such as C4 and Wikipedia and generate instructions for the given documents via LLMs. Then, we extend these examples with structured corpora examples such as Stack Exchange and WikiHow and task examples such as question answering, email writing, grammar error correction, story/poem generation, and text summarization.
Github Repo: https://github.com/akoksal/LongForm
### For OPT and LLaMA models: Use [EOI] to indicate the end of instruction.
LongForm-**T5-XL**: https://huggingface.co/akoksal/LongForm-T5-XL
LongForm-**OPT-2.7B**: https://huggingface.co/akoksal/LongForm-OPT-2.7B
LongForm-**OPT-6.7B**: https://huggingface.co/akoksal/LongForm-OPT-6.7B
## How to Load
### We present the diff between LongForm-LLaMA-7B and LLaMA-7B because of the license constraints. Please load the pretrained 7B model, add [EOI] token, and add model weights.
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
# 1. Original LLaMA path
original_llama_path = "/mounts/data/corp/huggingface/llama/llama-7b"
# 2. Add [EOI] token to the tokenizer
tokenizer = AutoTokenizer.from_pretrained(original_llama_path)
tokenizer.add_tokens(["[EOI]"])
# 3. Add the pretrained llama with this diff
base_model = AutoModelForCausalLM.from_pretrained(original_llama_path)
base_model.resize_token_embeddings(len(tokenizer))
longform_model_diff = AutoModelForCausalLM.from_pretrained("akoksal/LongForm-LLaMA-7B-diff")
longform_model = AutoModelForCausalLM.from_pretrained("akoksal/LongForm-LLaMA-7B-diff") # will change this to the actual model
# Add diff with base model
for name, param in base_model.named_parameters():
longform_model.state_dict()[name].copy_(param + longform_model_diff.state_dict()[name])
del base_model, longform_model_diff
# 4. Example
instruction = "Write an essay about meditation. [EOI]"
torch.manual_seed(42)
input_ids = tokenizer(instruction, return_tensors="pt").input_ids
target_ids = longform_model.generate(input_ids, do_sample=True, max_new_tokens=50, top_p=0.9)
tokenizer.decode(target_ids[0], skip_special_tokens=True)
# Output:
# > Write an essay about meditation. [EOI] There are a few types of meditation\
# but it essentially involves quieting the mind. The most common form of\
# meditation is where you sit down for a period of time and focus on your\
# breathing. Your goal is to be able to observe and
```
## Evaluation
We provide in-depth evaluation of LongForm models and baselines in the paper. We present the METEOR scores of models in out-of-domain datasets. In all tasks, Recipe Generation (RGen), long-form question answering (ELI5), short story generation (WritingPrompts/WP), LongForm models outperform prior instruction-tuned models.
| | **All** | **Recipe Generation** | **ELI5** | **Writing Prompts** |
|-----------------------|---------|-----------------------------------|----------|---------------------|
| **T0++** | 10.9 | 18.7 | 3.8 | 10.2 |
| **Tk-Instruct** | 6.3 | 12.9* | 3.6 | 2.4 |
| **Flan-T5** | 10.6 | 20.9* | 3.5 | 7.4 |
| **Alpaca-LLaMA-7B** | 14.6 | 19.5 | 12.5 | 11.8 |
| **OPT-30B** | 11.1 | 18.6 | 12.2 | 2.6 |
| [**LongForm-T5-XL**](https://huggingface.co/akoksal/LongForm-T5-XL) | 16.3 | 20.2 | 18.3 | 10.6 |
| [**LongForm-OPT-2.7B**](https://huggingface.co/akoksal/LongForm-OPT-2.7B) | 17.8 | 15.5 | 17.9 | **19.9** |
| [**LongForm-OPT-6.7B**](https://huggingface.co/akoksal/LongForm-OPT-6.7B) | 17.7 | 16.9 | 17.2 | 19.0 |
| [**LongForm-LLaMA-7B**](https://huggingface.co/akoksal/LongForm-LLaMA-7B-diff)‡ | **19.7** | **21.7** | **18.6** | 18.9 |
Smaller versions of LongForm-OPT models are also available:
- [**LongForm-OPT-1.3B**](https://huggingface.co/akoksal/LongForm-OPT-1.3B)
- [**LongForm-OPT-350M**](https://huggingface.co/akoksal/LongForm-OPT-350M)
- [**LongForm-OPT-125M**](https://huggingface.co/akoksal/LongForm-OPT-125M)
‡: We can just release the difference between LongForm-LLaMA-7B and pretrained LLaMA-7B publicly due to restrictions of LLaMA models.
## Limitations
The LongForm dataset and models mainly focus on long text generation and have limitations regarding structured prediction tasks in NLP. Additionally, we observe that LongForm models may present hallucination problems similar to those found in LLMs.
## License
The LongForm project is subject to a MIT License with custom limitations for restrictions imposed by OpenAI (for the instruction generation part), as well as the license of language models (OPT, LLaMA, and T5). The WikiHow subset of LongForm-C is subject to the license proposed by WikiHow.
## Citation
```
@misc{koksal2023longform,
title={LongForm: Effective Instruction Tuning with Reverse Instructions},
author={Abdullatif Köksal and Timo Schick and Anna Korhonen and Hinrich Schütze},
year={2023},
eprint={2304.08460},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
``` |