英文

模型描述

Tk-Instruct是一系列的编码器-解码器Transformer模型,通过遵循上下文指令(明确的任务定义,k-shot示例,解释等)来解决各种自然语言处理(NLP)任务。这些模型是基于预训练的 T5 models 模型构建的,通过在总共收集的1600多个任务的70多个广泛类别中的众多任务和指令的微调,使得模型不仅可以处理训练任务,还可以推广到许多未见任务,而无需进一步参数更新。

更多使用模型的资源:

使用目的和限制

Tk-Instruct可以通过遵循指令来执行许多NLP任务。

如何使用

当向模型发出指令时,任务定义或演示示例或解释应在原始输入之前添加,并输入到模型中。您可以按照以下方式轻松尝试Tk-Instruct模型:

>>> from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

>>> tokenizer = AutoTokenizer.from_pretrained("allenai/tk-instruct-3b-def")
>>> model = AutoModelForSeq2SeqLM.from_pretrained("allenai/tk-instruct-3b-def")

>>> input_ids = tokenizer.encode(
        "Definition: return the currency of the given country. Now complete the following example - Input: India. Output:", 
        return_tensors="pt")
>>> output = model.generate(input_ids, max_length=10)
>>> output = tokenizer.decode(output[0], skip_special_tokens=True)   # model should output 'Indian Rupee'

>>> input_ids = tokenizer.encode(
        "Definition: negate the following sentence. Input: John went to school. Output:", 
        return_tensors="pt")
>>> output = model.generate(input_ids, max_length=10)
>>> output = tokenizer.decode(output[0], skip_special_tokens=True)   # model should output 'John did not go to shool.'

限制

我们仍在努力理解这些模型的行为,但以下是我们发现的几个问题:

  • 模型对指令通常很敏感。有时重新措辞指令会导致非常不同的输出结果。
  • 模型并不总是遵循指令。有时模型不会按照您的指令执行(例如,当您要求模型生成一个句子时,它可能仍会生成一个单词或一个很长的故事)。
  • 模型可能在某些任务上完全失败。

如果您发现严重问题或任何有趣的结果,欢迎与我们分享!

训练数据

Tk-Instruct使用 Natural Instructions benchmark 中的任务和指令进行训练,总共包含1600多个任务的70多个广泛类别。我们遵循官方的训练/测试分割。Tk-Instruct系列模型使用757个任务进行训练,而mTk-Instruct系列使用1271个任务进行训练(包括一些非英语任务)。

训练任务分为64个广泛类别,例如文本分类/问答/情感分析/摘要/语法错误检测/对话生成等。其他12个类别用于评估。

训练过程

我们的所有模型都是从T5模型或mT5模型初始化的。因为生成输出可以被视为一种语言建模形式,所以我们使用它们的 LM adapted version 。所有数据都被转化为文本到文本的格式,并且模型被微调以最大化输出序列的可能性。

我们的 released models 大小不同,每个模型在训练时都使用特定类型的指令编码进行初始化。例如,tk-instruct-3b-def-pos是从 t5-xl-lm-adapt 初始化的,在训练期间,它将任务定义和2个正面示例作为指令进行训练。尽管它们只使用一种类型的指令编码进行训练,但我们发现它们通常可以在测试时与其他类型的编码一起工作(详见我们的论文)。

BibTeX条目和引用信息

@article{wang2022benchmarking,
  title={Benchmarking Generalization via In-Context Instructions on 1,600+ Language Tasks},
  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},
  year={2022},
  archivePrefix={arXiv},
  eprint={2204.07705},
  primaryClass={cs.CL},
}