62 lines
3.3 KiB
Markdown
62 lines
3.3 KiB
Markdown
---
|
||
language:
|
||
- ja
|
||
license: cc-by-sa-4.0
|
||
datasets:
|
||
- wikipedia
|
||
- cc100
|
||
widget:
|
||
- text: "早稲田 大学 で 自然 言語 処理 を"
|
||
---
|
||
|
||
# nlp-waseda/gpt2-xl-japanese
|
||
|
||
This is Japanese GPT2 with approximately 1.5B parameters pretrained on Japanese Wikipedia and CC-100
|
||
The model architecture of the model are based on [Radford+ 2019](https://paperswithcode.com/paper/language-models-are-unsupervised-multitask).
|
||
|
||
## Intended uses & limitations
|
||
|
||
You can use the raw model for text generation or fine-tune it to a downstream task.
|
||
|
||
Note that the texts should be segmented into words using [Juman++](https://github.com/ku-nlp/jumanpp) in advance.
|
||
|
||
### How to use
|
||
|
||
You can use this model directly with a pipeline for text generation. Since the generation relies on some randomness, we set a seed for reproducibility:
|
||
|
||
```python
|
||
from transformers import pipeline, set_seed
|
||
generator = pipeline('text-generation', model='nlp-waseda/gpt2-xl-japanese')
|
||
# If you use gpu.
|
||
# generator = pipeline('text-generation', model='nlp-waseda/gpt2-xl-japanese', device=0)
|
||
|
||
set_seed(42)
|
||
generator("早稲田 大学 で 自然 言語 処理 を", max_length=30, do_sample=True, pad_token_id=2, num_return_sequences=5)
|
||
[{'generated_text': '早稲田 大学 で 自然 言語 処理 を 勉強 して いる 大学生 です. 自然 言語 処理 や 音声 認識, 機械 学習 等 に 興味 が あり, 特に 画像'},
|
||
{'generated_text': '早稲田 大学 で 自然 言語 処理 を 学んで いる と ある 方 と お 会い して き ました. 今日 は お 話 する 時間 が 少なかった のです が,'},
|
||
{'generated_text': '早稲田 大学 で 自然 言語 処理 を 研究 して いる が 、 それ を 趣味 と は 思わず 、 会社 を 作る ため の 手段 と とらえて いる ようです 。'},
|
||
{'generated_text': '早稲田 大学 で 自然 言語 処理 を 専門 的に 学ぶ サークル です 。 日本 語 教育 センター で 日本 語 を 勉強 した 中国 の 人 たち と 交流 する'},
|
||
{'generated_text': '早稲田 大学 で 自然 言語 処理 を 専攻 した 時 に 、 数学 の 知識 ・ プログラミング 言語 の 知識 が 身 に ついて いた の は 、 とても 役'}]
|
||
```
|
||
|
||
```python
|
||
from transformers import AutoTokenizer, GPT2Model
|
||
tokenizer = AutoTokenizer.from_pretrained('nlp-waseda/gpt2-xl-japanese')
|
||
model = GPT2Model.from_pretrained('nlp-waseda/gpt2-xl-japanese')
|
||
text = "早稲田 大学 で 自然 言語 処理 を"
|
||
encoded_input = tokenizer(text, return_tensors='pt')
|
||
output = model(**encoded_input)
|
||
```
|
||
|
||
### Preprocessing
|
||
|
||
The texts are normalized using [neologdn](https://github.com/ikegami-yukino/neologdn), segmented into words using [Juman++](https://github.com/ku-nlp/jumanpp), and tokenized by [BPE](https://huggingface.co/docs/tokenizers/api/models#tokenizers.models.BPE). Juman++ 2.0.0-rc3 was used for pretraining.
|
||
|
||
The model was trained on 8 NVIDIA A100 GPUs.
|
||
|
||
|
||
# Acknowledgments
|
||
|
||
This work was supported by Joint Usage/Research Center for Interdisciplinary Large-scale Information Infrastructures (JHPCN) through General Collaboration Project no. jh221004, "Developing a Platform for Constructing and Sharing of Large-Scale Japanese Language Models".
|
||
|
||
For training models, we used the [mdx](https://mdx.jp/): a platform for the data-driven future. |