英文

模型描述

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

更多使用该模型的资源:

预期用途与限制

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 中的任务和指令进行训练,该数据集总共包含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},
}