Edit model card

nlp-waseda/gpt2-small-japanese

This model is Japanese GPT-2 pretrained on Japanese Wikipedia and CC-100.

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++ 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:

>>> from transformers import pipeline, set_seed
>>> generator = pipeline('text-generation', model='nlp-waseda/gpt2-small-japanese')
>>> set_seed(42)
>>> generator("早稲田 大学 で 自然 言語 処理 を", max_length=30, do_sample=True, pad_token_id=2, num_return_sequences=5)
[{'generated_text': '早稲田 大学 で 自然 言語 処理 を 学び 、 帰国 後 、 早稲田 大学 理工 学部 に 入学 し ます 。 卒業 後 、 早稲田 大学 工学 研究 科 、'},
 {'generated_text': '早稲田 大学 で 自然 言語 処理 を 学び 、 アメリカ の 大学 で 学士 号 を 取得 、 修士 の 取得 で 博士 号 を 取得 。  2008 年'},
 {'generated_text': '早稲田 大学 で 自然 言語 処理 を 勉強 して い ます 。 学部 は 日本 語 学科 を 専攻 して い ます 。  英語 が 話せる と いう'},
 {'generated_text': '早稲田 大学 で 自然 言語 処理 を 専攻 して いた 。 2011 年 に 第 26 回 日本 化学 会 学生 委員 会 奨励 賞 ( 第 2 年次 審査'},
 {'generated_text': '早稲田 大学 で 自然 言語 処理 を 中心 と する 言語 学 研究 を 行って いる 。   東京 都 ・ 豊島 区 の お 見合い 相手 。'}]

Here is how to use this model to get the features of a given text in PyTorch:

from transformers import ReformerTokenizer, GPT2Model
tokenizer = ReformerTokenizer.from_pretrained('nlp-waseda/gpt2-small-japanese')
model = GPT2Model.from_pretrained('nlp-waseda/gpt2-small-japanese')
text = "早稲田 大学 で 自然 言語 処理 を"
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)

Training data

The GPT-2 model was pretrained on Japanese Wikipedia, dumped on 2022-03-20, and the Japanese portion of CC-100.

Training procedure

Preprocessing

The texts are normalized using zenhan, segmented into words using Juman++, and tokenized using SentencePiece. Juman++ 2.0.0-rc3 was used for pretraining.

The model was trained on 8 NVIDIA A100 GPUs.

Downloads last month
113

Datasets used to train nlp-waseda/gpt2-small-japanese

Collection including nlp-waseda/gpt2-small-japanese