Views
No views yet
We envision interesting applications of Transformer-XL in the fields of text generation, unsupervised feature learning, image and speech modeling.
best model trained the Wikitext-103 dataset. We seed the our Transformer-XL with a context of at most 512 consecutive tokens randomly sampled from the test set of Wikitext-103. Then, we run Transformer-XL to generate a pre-defined number of tokens (500 or 1,000 in our case). For each generation step, we first find the top-40 probabilities of the next-step distribution and sample from top-40 tokens based on the re-normalized distribution. To help reading, we detokenize the context, the generated text and the reference text.
Similar to but different from enwik8, text8 con- tains 100M processed Wikipedia characters cre- ated by lowering case the text and removing any character other than the 26 letters a through z, and space. Due to the similarity, we simply adapt the best model and the same hyper-parameters on en- wik8 to text8 without further tuning.
| Method | enwiki8 | text8 | One Billion Word | WT-103 | PTB (w/o finetuning) |
|---|---|---|---|---|---|
| Transformer-XL. | 0.99 | 1.08 | 21.8 | 18.3 | 54.5 |
1@misc{https://doi.org/10.48550/arxiv.1901.02860,
2 doi = {10.48550/ARXIV.1901.02860},
3
4 url = {https://arxiv.org/abs/1901.02860},
5
6 author = {Dai, Zihang and Yang, Zhilin and Yang, Yiming and Carbonell, Jaime and Le, Quoc V. and Salakhutdinov, Ruslan},
7
8 keywords = {Machine Learning (cs.LG), Computation and Language (cs.CL), Machine Learning (stat.ML), FOS: Computer and information sciences, FOS: Computer and information sciences},
9
10 title = {Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context},
11
12 publisher = {arXiv},
13
14 year = {2019},
15
16 copyright = {Creative Commons Attribution Non Commercial Share Alike 4.0 International}
17}from transformers import TransfoXLTokenizer, TransfoXLModel
import torch
tokenizer = TransfoXLTokenizer.from_pretrained("zpbrent/newInfect")
model = TransfoXLModel.from_pretrained("zpbrent/newInfect")
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
print(outputs)