英文

模型描述

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

更多使用该模型的资源:

使用目的和限制

Tk-Instruct可以通过遵循指令来执行许多自然语言处理任务。

使用方法

在对模型进行指示时,需要将任务定义、演示示例或解释添加到原始输入之前,并输入模型中。您可以按照以下方式轻松尝试Tk-Intruct模型:

>>> 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 数据集中的任务和指令进行训练,该数据集总共包含70多个广泛类别的1600多个任务。我们遵循官方的训练/测试划分。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},
}