akoksal commited on
Commit
7dcb51d
1 Parent(s): 1c83092

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +109 -0
README.md ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - multilingual
5
+ - de
6
+ - it
7
+ - es
8
+ - fr
9
+ tags:
10
+ - instruction-tuning
11
+ - text-generation-inference
12
+ - text2text-generation
13
+ widget:
14
+ - text: Write an essay about meditation. [EOI]
15
+ example_title: Essay Generation
16
+ - text: Give me 5 steps to clean my room. [EOI]
17
+ example_title: How-to Instructions
18
+ - text: How are the continents formed? [EOI]
19
+ example_title: Question-Answering
20
+ - text: >-
21
+ Prompt: A man draws a gun in a dark alley and asks for your wallet. You
22
+ begrudgingly obey. He throws it on the ground, shoots it till it screeches,
23
+ and turns to you; 'you are safe now'. Write a story about given prompt.
24
+ [EOI]
25
+ example_title: Story Generation
26
+ - text: >-
27
+ Write directions of a cooking recipe with these ingredients: chicken breast,
28
+ carrots, green peas, celery, butter, onion, flour, salt, black pepper,
29
+ celery seed, chicken broth, milk, unbaked pie crusts [EOI]
30
+ example_title: Recipe Generation
31
+ - text: >-
32
+ Schreiben Sie einen Blogbeitrag über die Vorteile des Lesens von Büchern.
33
+ [EOI]
34
+ example_title: German Essay Generation
35
+ inference:
36
+ parameters:
37
+ top_p: 0.9
38
+ do_sample: true
39
+ max_length: 50
40
+ datasets:
41
+ - akoksal/LongForm
42
+ ---
43
+ ## LongForm-LLaMA-7B-diff
44
+ The LongForm dataset is created by leveraging English corpus examples with augmented 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.
45
+
46
+ Github Repo: https://github.com/akoksal/LongForm
47
+
48
+ ### For OPT and LLaMA models: Use [EOI] to indicate the end of instruction.
49
+
50
+ LongForm-**T5-XL**: https://huggingface.co/akoksal/LongForm-T5-XL
51
+
52
+ LongForm-**OPT-2.7B**: https://huggingface.co/akoksal/LongForm-OPT-2.7B
53
+
54
+ LongForm-**OPT-6.7B**: https://huggingface.co/akoksal/LongForm-OPT-6.7B
55
+
56
+ ## How to Load
57
+ ### 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.
58
+ ```python
59
+ import torch
60
+ from transformers import AutoTokenizer, AutoModelForCausalLM
61
+
62
+ # 1. Original LLaMA path
63
+ original_llama_path = "/mounts/data/corp/huggingface/llama/llama-7b"
64
+
65
+ # 2. Add [EOI] token to the tokenizer
66
+ tokenizer = AutoTokenizer.from_pretrained(original_llama_path)
67
+ tokenizer.add_tokens(["[EOI]"])
68
+
69
+ # 3. Add the pretrained llama with this diff
70
+ base_model = AutoModelForCausalLM.from_pretrained(original_llama_path)
71
+ base_model.resize_token_embeddings(len(tokenizer))
72
+ longform_model_diff = AutoModelForCausalLM.from_pretrained("akoksal/LongForm-LLaMA-7B-diff")
73
+ longform_model = AutoModelForCausalLM.from_pretrained("akoksal/LongForm-LLaMA-7B-diff") # will change this to the actual model
74
+
75
+ # Add diff with base model
76
+ for name, param in base_model.named_parameters():
77
+ longform_model.state_dict()[name].copy_(param + longform_model_diff.state_dict()[name])
78
+
79
+ # 4. Example
80
+ instruction = "Write an essay about meditation. [EOI]"
81
+ torch.manual_seed(42)
82
+ input_ids = tokenizer(instruction, return_tensors="pt").input_ids
83
+ target_ids = longform_model.generate(input_ids, do_sample=True, max_new_tokens=50, top_p=0.9)
84
+ tokenizer.decode(target_ids[0], skip_special_tokens=True)
85
+ # Output:
86
+ # > Write an essay about meditation. [EOI] There are a few types of meditation\
87
+ # but it essentially involves quieting the mind. The most common form of\
88
+ # meditation is where you sit down for a period of time and focus on your\
89
+ # breathing. Your goal is to be able to observe and
90
+ ```
91
+
92
+ ## Evaluation
93
+ 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.
94
+ | | **All** | **Recipe Generation** | **ELI5** | **Writing Prompts** |
95
+ |-----------------------|---------|-----------------------------------|----------|---------------------|
96
+ | **T0++** | 10.9 | 18.7 | 3.8 | 10.2 |
97
+ | **Tk-Instruct** | 6.3 | 12.9* | 3.6 | 2.4 |
98
+ | **Flan-T5** | 10.6 | 20.9* | 3.5 | 7.4 |
99
+ | **Alpaca-LLaMA-7B** | 14.6 | 19.5 | 12.5 | 11.8 |
100
+ | **OPT-30B** | 11.1 | 18.6 | 12.2 | 2.6 |
101
+ | [**LongForm-T5-XL**](https://huggingface.co/akoksal/LongForm-T5-XL) | 16.3 | 20.2 | 18.3 | 10.6 |
102
+ | [**LongForm-OPT-2.7B**](https://huggingface.co/akoksal/LongForm-OPT-2.7B) | 17.8 | 15.5 | 17.9 | **19.9** |
103
+ | [**LongForm-OPT-6.7B**](https://huggingface.co/akoksal/LongForm-OPT-6.7B) | 17.7 | 16.9 | 17.2 | 19.0 |
104
+ | [**LongForm-LLaMA-7B**](https://huggingface.co/akoksal/LongForm-LLaMA-7B-diff)‡ | **19.7** | **21.7** | **18.6** | 18.9 |
105
+
106
+ ‡: We can just release the difference between LongForm-LLaMA-7B and pretrained LLaMA-7B publicly due to restrictions of LLaMA models.
107
+
108
+ ## Limitations
109
+ 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.