VOOZH about

URL: https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-ppo

⇱ rinna/japanese-gpt-neox-3.6b-instruction-ppo · Hugging Face


japanese-gpt-neox-3.6b-instruction-ppo

👁 rinna-icon

Overview

This repository provides a Japanese GPT-NeoX model of 3.6 billion parameters. The model is based on rinna/japanese-gpt-neox-3.6b-instruction-sft-v2 and has been aligned to serve as an instruction-following conversational agent.

Limitations

  • We found this verison of PPO model tends to generate repeated text more often than its SFT counterpart, and thus we set repetition_penalty=1.1 for better generation performance. (The same generation hyper-parameters are applied to the SFT model in aforementioned evaluation experiments.) You can also explore other hyperparameter combinations that yield higher generation randomness/diversity for better generation quality, e.g. temperature=0.9, repetition_penalty=1.0.

I/O Format

A special format has been adopted to construct inputs.

  • An input prompt is formatted as a conversation between ăƒŠăƒŒă‚¶ăƒŒ and ă‚·ă‚čテム.
  • Each input utterance consists of (1) its speaker ("ăƒŠăƒŒă‚¶ăƒŒ" or "ă‚·ă‚čテム"), (2) a colon (":"), (3) a whitespace (" "), and (4) utterance text (e.g. "侖界で侀ç•Șé«˜ă„ć±±ăŻïŒŸ").
  • The input prompt should be ended with "ă‚·ă‚čテム: " to acknowledge the model to generate a response.
  • Since the model's tokenizer does not recognize "\n", a special newline symbol "<NL>" is used instead.
  • All the newlines in input and output utterances should be replaced with "<NL>".
  • All the utterances in the input prompt should be separated by "<NL>".

Following is an example to construct an input from a conversation.

prompt = [
 {
 "speaker": "ăƒŠăƒŒă‚¶ăƒŒ",
 "text": "コンタクトレンă‚șă‚’æ…Łă‚Œă‚‹ă«ăŻă©ă†ă™ă‚Œă°ă‚ˆă„ă§ă™ă‹ïŒŸ"
 },
 {
 "speaker": "ă‚·ă‚čテム",
 "text": "ă“ă‚Œă«ă€ă„ăŠć…·äœ“çš„ă«èȘŹæ˜Žă—ăŠă„ăŸă ă‘ăŸă™ă‹ïŒŸäœ•ăŒé›Łă—ă„ăźă§ă—ă‚‡ă†ă‹ïŒŸ"
 },
 {
 "speaker": "ăƒŠăƒŒă‚¶ăƒŒ",
 "text": "盼が痛いぼです。"
 },
 {
 "speaker": "ă‚·ă‚čテム",
 "text": "ćˆ†ă‹ă‚ŠăŸă—ăŸă€ă‚łăƒłă‚żă‚ŻăƒˆăƒŹăƒłă‚șă‚’ă€ă‘ă‚‹ăšç›źăŒă‹ă‚†ăăȘă‚‹ăšă„ă†ă“ăšă§ă™ă­ă€‚æ€ăŁăŸä»„äžŠă«ăƒŹăƒłă‚șă‚’ć€–ă™ćż…èŠăŒă‚ă‚‹ă§ă—ă‚‡ă†ă‹ïŒŸ"
 },
 {
 "speaker": "ăƒŠăƒŒă‚¶ăƒŒ",
 "text": "いえ、レンă‚șăŻć€–ă—ăŸă›ă‚“ăŒă€ç›źăŒè”€ăăȘるんです。"
 }
]
prompt = [
 f"{uttr['speaker']}: {uttr['text']}"
 for uttr in prompt
]
prompt = "<NL>".join(prompt)
prompt = (
 prompt
 + "<NL>"
 + "ă‚·ă‚čテム: "
)
print(prompt)
# "ăƒŠăƒŒă‚¶ăƒŒ: コンタクトレンă‚șă‚’æ…Łă‚Œă‚‹ă«ăŻă©ă†ă™ă‚Œă°ă‚ˆă„ă§ă™ă‹ïŒŸ<NL>ă‚·ă‚čテム: ă“ă‚Œă«ă€ă„ăŠć…·äœ“çš„ă«èȘŹæ˜Žă—ăŠă„ăŸă ă‘ăŸă™ă‹ïŒŸäœ•ăŒé›Łă—ă„ăźă§ă—ă‚‡ă†ă‹ïŒŸ<NL>ăƒŠăƒŒă‚¶ăƒŒ: 盼が痛いぼです。<NL>ă‚·ă‚čテム: ćˆ†ă‹ă‚ŠăŸă—ăŸă€ă‚łăƒłă‚żă‚ŻăƒˆăƒŹăƒłă‚șă‚’ă€ă‘ă‚‹ăšç›źăŒă‹ă‚†ăăȘă‚‹ăšă„ă†ă“ăšă§ă™ă­ă€‚æ€ăŁăŸä»„äžŠă«ăƒŹăƒłă‚șă‚’ć€–ă™ćż…èŠăŒă‚ă‚‹ă§ă—ă‚‡ă†ă‹ïŒŸ<NL>ăƒŠăƒŒă‚¶ăƒŒ: いえ、レンă‚șăŻć€–ă—ăŸă›ă‚“ăŒă€ç›źăŒè”€ăăȘるんです。<NL>ă‚·ă‚čテム: "

How to use the model

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("rinna/japanese-gpt-neox-3.6b-instruction-ppo", use_fast=False)
model = AutoModelForCausalLM.from_pretrained("rinna/japanese-gpt-neox-3.6b-instruction-ppo")

if torch.cuda.is_available():
 model = model.to("cuda")

token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")

with torch.no_grad():
 output_ids = model.generate(
 token_ids.to(model.device),
 do_sample=True,
 max_new_tokens=128,
 temperature=0.7,
 repetition_penalty=1.1,
 pad_token_id=tokenizer.pad_token_id,
 bos_token_id=tokenizer.bos_token_id,
 eos_token_id=tokenizer.eos_token_id
 )

output = tokenizer.decode(output_ids.tolist()[0][token_ids.size(1):])
output = output.replace("<NL>", "\n")
print(output)
"""それは、コンタクトレンă‚șăŒç›źă«ćˆă‚ăȘă„ăŸă‚ă«è”·ă“ă‚‹ă“ăšăŒă‚ă‚ŠăŸă™ă€‚ăƒŹăƒłă‚șăŒç›źăźèĄšéąă«é•·æ™‚é–“è§Šă‚Œç¶šă‘ă‚‹ă“ăšăŒćŽŸć› ăšăȘă‚‹ă“ăšăŒă‚ă‚ŠăŸă™ă€‚ăŸăŸă€ă‚łăƒłă‚żă‚ŻăƒˆăƒŹăƒłă‚șăŒæ±šă‚ŒăŠă„ă‚‹ćŻèƒœæ€§ă‚‚ă‚ă‚ŠăŸă™ă€‚ă‚łăƒłă‚żă‚ŻăƒˆăƒŹăƒłă‚șă‚±ăƒŒă‚čă‚’ćźšæœŸçš„ă«æŽ—æ”„ă—ăŸă‚Šă€ă‚łăƒłă‚żă‚ŻăƒˆăƒŹăƒłă‚șă‚’æ­Łă—ăăƒ•ă‚Łăƒƒăƒˆă•ă›ă‚‹ă‚ˆă†ă«ă—ăŸă‚Šă™ă‚‹ă“ăšăŒćœčç«‹ăĄăŸă™ă€‚</s>"""

Tokenization

The model uses a sentencepiece-based tokenizer.

  • The tokenizer has a vocabulary size of 32,000.
  • It uses sentencepiece's byte fallback feature to decompose unknown text pieces into UTF-8 byte pieces and to avoid producing <UNK> tokens.
  • sentencepiece's --add_dummy_prefix option was turned off so that a leading whitespace will not be prepended automatically.
     print(tokenizer.tokenize("ćŸèŒ©ăŻçŒ«ă§ă‚ă‚‹"))
     # ['ćŸ', '茩', 'は', '猫', 'である']
     # instead of ['▁', 'ćŸ', '茩', 'は', '猫', 'である'] as in rinna/japanese-gpt-1b
    
  • sentencepiece's --remove_extra_whitespaces option was turned off so that leading, trailing, and duplicate whitespaces are reserved.
     print(tokenizer.tokenize(" ćŸèŒ©ăŻ çŒ«ă§ă‚ă‚‹ "))
     # ['▁', '▁', 'ćŸ', '茩', 'は', '▁', '▁', '猫', 'である', '▁', '▁', '▁']
     # instead of ['▁', 'ćŸ', '茩', 'は', '▁猫', 'である'] as in rinna/japanese-gpt-1b
    
  • Don't forget to set use_fast=False to make the above features function correctly.
     good_tokenizer = AutoTokenizer.from_pretrained("rinna/japanese-gpt-neox-3.6b", use_fast=False)
     bad_tokenizer = AutoTokenizer.from_pretrained("rinna/japanese-gpt-neox-3.6b")
    
     print(good_tokenizer.decode(good_tokenizer.encode("გამარჯობა ćŸèŒ©ăŻ çŒ«ă§ă‚ă‚‹ ")))
     # 'გამარჯობა ćŸèŒ©ăŻ çŒ«ă§ă‚ă‚‹ </s>'
     print(bad_tokenizer.decode(bad_tokenizer.encode("გამარჯობა ćŸèŒ©ăŻ çŒ«ă§ă‚ă‚‹ ")))
     # 'გამარ[UNK]ობა ćŸèŒ©ăŻ çŒ«ă§ă‚ă‚‹ </s>'
    

How to cite

@misc{rinna-japanese-gpt-neox-3.6b-instruction-ppo,
 title = {rinna/japanese-gpt-neox-3.6b-instruction-ppo},
 author = {Zhao, Tianyu and Sawada, Kei},
 url = {https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-ppo}
}

@inproceedings{sawada2024release,
 title = {Release of Pre-Trained Models for the {J}apanese Language},
 author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
 booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
 month = {5},
 year = {2024},
 pages = {13898--13905},
 url = {https://aclanthology.org/2024.lrec-main.1213},
 note = {\url{https://arxiv.org/abs/2404.01657}}
}

Licenese

The MIT license

Downloads last month
742
Safetensors
Model size
4B params
Tensor type
BF16
·
BOOL
·

Model tree for rinna/japanese-gpt-neox-3.6b-instruction-ppo

Finetuned
(2)
this model

Dataset used to train rinna/japanese-gpt-neox-3.6b-instruction-ppo

Spaces using rinna/japanese-gpt-neox-3.6b-instruction-ppo 3

Collection including rinna/japanese-gpt-neox-3.6b-instruction-ppo

Papers for rinna/japanese-gpt-neox-3.6b-instruction-ppo