Text2Text Generation
Transformers
PyTorch
English
t5
text-generation-inference
Inference Endpoints
Files changed (1) hide show
  1. README.md +78 -0
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ datasets:
5
+ - natural instructions v2.0
6
+ ---
7
+
8
+ # Model description
9
+
10
+ Tk-Instruct is a series of encoder-decoder Transformer models that are trained to solve various NLP tasks by following in-context instructions (plain language task definitions, k-shot examples, explanations, etc). Built upon the pre-trained [T5 models](https://arxiv.org/abs/1910.10683), they are fine-tuned on a large number of tasks & instructions that are collected in the [Natural Instructions benchmark](https://github.com/allenai/natural-instructions), which contains 1600+ tasks in 70+ broach categories in total. This enables the model to not only process the training tasks, but also generalize to many unseen tasks without further parameter update.
11
+
12
+ More resources for using the model:
13
+ - **Code repository**: [Tk-Instruct](https://github.com/yizhongw/Tk-Instruct)
14
+ - **Official Website**: [Natural Instructions](https://instructions.apps.allenai.org/)
15
+ - **All released models**: [allenai/tk-instruct](https://huggingface.co/models?search=allenai/tk-instruct)
16
+
17
+ ## Intended uses & limitations
18
+
19
+ Tk-Instruct can be used to do many NLP tasks by following instructions.
20
+
21
+ ### How to use
22
+
23
+ When instructing the model, task definition or demonstration examples or explanations should be prepended to the original input and fed into the model. You can easily try Tk-Instruct models as follows:
24
+
25
+ ```python
26
+ >>> from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
27
+
28
+ >>> tokenizer = AutoTokenizer.from_pretrained("allenai/tk-instruct-3b-def")
29
+ >>> model = AutoModelForSeq2SeqLM.from_pretrained("allenai/tk-instruct-3b-def")
30
+
31
+ >>> input_ids = tokenizer.encode(
32
+ "Definition: return the currency of the given country. Now complete the following example - Input: India. Output:",
33
+ return_tensors="pt")
34
+ >>> output = model.generate(input_ids, max_length=10)
35
+ >>> output = tokenizer.decode(output[0], skip_special_tokens=True) # model should output 'Indian Rupee'
36
+
37
+ >>> input_ids = tokenizer.encode(
38
+ "Definition: negate the following sentence. Input: John went to school. Output:",
39
+ return_tensors="pt")
40
+ >>> output = model.generate(input_ids, max_length=10)
41
+ >>> output = tokenizer.decode(output[0], skip_special_tokens=True) # model should output 'John did not go to shool.'
42
+ ```
43
+
44
+ ### Limitations
45
+
46
+ We are still working on understanding the behaviors of these models, but here are several issues we have found:
47
+ - Models are generally sensitive to the instruction. Sometimes rewording the instruction can lead to very different output.
48
+ - Models are not always compliant to the instruction. Sometimes the model don't follow your instruction (e.g., when you ask the model to generate one sentence, it might still generate one word or a long story).
49
+ - Models might totally fail on some tasks.
50
+
51
+ If you find serious issues or any interesting result, you are welcome to share with us!
52
+
53
+ ## Training data
54
+
55
+ Tk-Instruct is trained using the tasks & instructions in [Natural Instructions benchmark](https://github.com/allenai/natural-instructions), which contains 1600+ tasks in 70+ broach categories in total. We follow the official train/test split. Tk-Instruct model series were trained using 757 tasks, and mTk-Instruct series were trained using 1271 tasks (including some non-English tasks). The training tasks are in 64 broad categories, such as text categorization / question answering / sentiment analysis / summarization / grammar error detection / dialogue generation / etc. The other 12 categories are selected for evaluation.
56
+
57
+
58
+ ## Training procedure
59
+
60
+ All our models are initialized from either T5 models or mT5 models. Because generating the output can be regarded as a form of language modeling, we used their [LM adapted version](https://github.com/google-research/text-to-text-transfer-transformer/blob/main/released_checkpoints.md#lm-adapted-t511lm100k). All data is converted into a text-to-text format, and models are fine-tuned to maximize the likelihood of the output sequence.
61
+
62
+ Our [released models](https://huggingface.co/models?search=allenai/tk-instruct) are in different sizes, and each of them was trained with a specific type of instruction encoding. For instance, `tk-instruct-3b-def-pos` was initialized from [t5-xl-lm-adapt](https://huggingface.co/google/t5-xl-lm-adapt), and it saw task definition & 2 positive examples as the instruction during training time.
63
+ Although they are trained with only one type of instruction encodings, we found they can usually work with other type of encodings at test time (see more in our paper).
64
+
65
+
66
+ ### BibTeX entry and citation info
67
+ ```bibtex
68
+ @article{wang2022benchmarking,
69
+ title={Benchmarking Generalization via In-Context Instructions on 1,600+ Language Tasks},
70
+ author={Yizhong Wang and Swaroop Mishra and Pegah Alipoormolabashi and Yeganeh Kordi and Amirreza Mirzaei and A. Arunkumar and Arjun Ashok and Arut Selvan Dhanasekaran and Atharva Naik and David Stap and Eshaan Pathak and Giannis Karamanolakis and Haizhi Gary Lai and Ishan Purohit and Ishani Mondal and Jacob Anderson and Kirby Kuznia and Krima Doshi and Maitreya Patel and Kuntal Kumar Pal and M. Moradshahi and Mihir Parmar and Mirali Purohit and Neeraj Varshney and Phani Rohitha Kaza and Pulkit Verma and Ravsehaj Singh Puri and Rushang Karia and Shailaja Keyur Sampat and Savan Doshi and Siddharth Deepak Mishra and Sujan C. Reddy and Sumanta Patro and Tanay Dixit and Xu-dong Shen and Chitta Baral and Yejin Choi and Hannaneh Hajishirzi and Noah A. Smith and Daniel Khashabi},
71
+ year={2022},
72
+ archivePrefix={arXiv},
73
+ eprint={2204.07705},
74
+ primaryClass={cs.CL},
75
+ }
76
+ ```
77
+
78
+