Downloads · 30 days
811
9% of all-time downloads
okazaki-lab/japanese-gpt2-medium-unidic
japanese-gpt2-medium-unidic is a text generation model from okazaki-lab. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as cc-by-sa-4.0.
This is a medium-sized Japanese GPT-2 model using BERT-like tokenizer.
Downloads · 30 days
811
9% of all-time downloads
All-time downloads
8.9K
Public
Parameters
362M
2.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.bin1.4 GB · 50%
How the weights are stored.
F32337M · 93%
From the Hugging Face model README
This is a medium-sized Japanese GPT-2 model using BERT-like tokenizer.
Reversed version is published here.
The model depends on PyTorch, fugashi with unidic-lite, and Hugging Face Transformers.
pip install torch torchvision torchaudio
pip install fugashi[unidic-lite]
pip install transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained('okazaki-lab/japanese-gpt2-medium-unidic')
model = AutoModelForCausalLM.from_pretrained('okazaki-lab/japanese-gpt2-medium-unidic')
text = '今日はいい天気なので、'
bos = tokenizer.convert_tokens_to_ids(['[BOS]']) # [32768]
input_ids = bos + tokenizer.encode(text)[1:-1] # [CLS] and [SEP] generated by BERT Tokenizer are removed
input_ids = torch.tensor(input_ids).unsqueeze(0)
output = model.generate(
input_ids,
do_sample=True,
max_new_tokens=30,
top_k=50,
top_p=0.95,
repetition_penalty=1.0,
num_return_sequences=1,
pad_token_id=0,
eos_token_id=32769,
)[0]
print(tokenizer.decode(output))
Transformer-based Language Model
We used a codebase provided by rinna Co., Ltd. for training.
The model was trained on Japanese CC-100 and Japanese Wikipedia (2022/01/31). We employed 8 A100 GPUs for 17 days. The perplexity on the validation set is 9.80.
Our tokenizer is based on the one provided by Tohoku NLP Group. The texts are tokenized by MeCab and then WordPiece.
The vocabulary size is 32771 (32768 original tokens + 2 special tokens + 1 unused token).
Creative Commons Attribution-ShareAlike 4.0
Copyright (c) 2021, Tohoku University
Copyright (c) 2023, Tokyo Institute of Technology