XLNet 模型是在英语语言上进行预训练的。它由 Yang 等人在论文《XLNet: Generalized Autoregressive Pretraining for Language Understanding》中提出,并首次在此仓库中发布。
免责声明:发布 XLNet 的团队并未为此模型撰写模型卡片,因此本模型卡片由 Hugging Face 团队编写。
XLNet 是一种全新的无监督语言表示学习方法,它基于一种新颖的广义排列语言建模目标。此外,XLNet 采用 Transformer-XL 作为骨干模型,在涉及长上下文的语言任务中表现出卓越性能。总体而言,XLNet 在各种下游语言任务上取得了最先进(SOTA)的结果,包括问答、自然语言推理、情感分析和文档排序。
该模型主要用于在下游任务上进行微调。请查看模型中心,以寻找您感兴趣任务的微调版本。
请注意,此模型主要用于在需要使用整个句子(可能包含掩码)来做决策的任务上进行微调,例如序列分类、 token 分类或问答。对于文本生成等任务,您应考虑 GPT2 等模型。
以下是如何在 PyTorch 中使用此模型获取给定文本特征的示例:
from transformers import XLNetTokenizer, XLNetModel
tokenizer = XLNetTokenizer.from_pretrained('xlnet-base-cased')
model = XLNetModel.from_pretrained('xlnet-base-cased')
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state@article{DBLP:journals/corr/abs-1906-08237,
author = {Zhilin Yang and
Zihang Dai and
Yiming Yang and
Jaime G. Carbonell and
Ruslan Salakhutdinov and
Quoc V. Le},
title = {XLNet: Generalized Autoregressive Pretraining for Language Understanding},
journal = {CoRR},
volume = {abs/1906.08237},
year = {2019},
eprinttype = {arXiv},
eprint = {1906.08237},
timestamp = {Mon, 24 Jun 2019 17:28:45 +0200},
bibsource = {dblp computer science bibliography}
}