Views
No views yet

rinna/japanese-gpt-neox-3.6b and has been finetuned to serve as an instruction-following conversational agent.rinna/japanese-gpt-neox-3.6b-instruction-sft, where a different data split is used for training.| this SFT vs. previous SFT | win | tie | loss |
|---|---|---|---|
| ChatGPT auto. evaluation | 55% | 0% | 45% |
ユーザー and システム."ユーザー" or "システム"), (2) a colon (":"), (3) a whitespace (" "), and (4) utterance text (e.g. "世界で一番高い山は?")."システム: " to acknowledge the model to generate a response."\n", a special newline symbol "<NL>" is used instead."<NL>"."<NL>".1prompt = [
2 {
3 "speaker": "ユーザー",
4 "text": "コンタクトレンズを慣れるにはどうすればよいですか?"
5 },
6 {
7 "speaker": "システム",
8 "text": "これについて具体的に説明していただけますか?何が難しいのでしょうか?"
9 },
10 {
11 "speaker": "ユーザー",
12 "text": "目が痛いのです。"
13 },
14 {
15 "speaker": "システム",
16 "text": "分かりました、コンタクトレンズをつけると目がかゆくなるということですね。思った以上にレンズを外す必要があるでしょうか?"
17 },
18 {
19 "speaker": "ユーザー",
20 "text": "いえ、レンズは外しませんが、目が赤くなるんです。"
21 }
22]
23prompt = [
24 f"{uttr['speaker']}: {uttr['text']}"
25 for uttr in prompt
26]
27prompt = "<NL>".join(prompt)
28prompt = (
29 prompt
30 + "<NL>"
31 + "システム: "
32)
33print(prompt)
34# "ユーザー: コンタクトレンズを慣れるにはどうすればよいですか?<NL>システム: これについて具体的に説明していただけますか?何が難しいのでしょうか?<NL>ユーザー: 目が痛いのです。<NL>システム: 分かりました、コンタクトレンズをつけると目がかゆくなるということですね。思った以上にレンズを外す必要があるでしょうか?<NL>ユーザー: いえ、レンズは外しませんが、目が赤くなるんです。<NL>システム: "1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4tokenizer = AutoTokenizer.from_pretrained("rinna/japanese-gpt-neox-3.6b-instruction-sft-v2", use_fast=False)
5model = AutoModelForCausalLM.from_pretrained("rinna/japanese-gpt-neox-3.6b-instruction-sft-v2")
6
7if torch.cuda.is_available():
8 model = model.to("cuda")
9
10token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
11
12with torch.no_grad():
13 output_ids = model.generate(
14 token_ids.to(model.device),
15 do_sample=True,
16 max_new_tokens=128,
17 temperature=0.7,
18 repetition_penalty=1.1,
19 pad_token_id=tokenizer.pad_token_id,
20 bos_token_id=tokenizer.bos_token_id,
21 eos_token_id=tokenizer.eos_token_id
22 )
23
24output = tokenizer.decode(output_ids.tolist()[0][token_ids.size(1):])
25output = output.replace("<NL>", "\n")
26print(output)
27"""わかりました。まずは、コンタクトレンズを長時間着用することによる目の乾燥を防ぐことができます。また、毎日同じ時間帯にコンタクトレンズを着用してみることもできます。そして、コンタクトレンズが目に合わないような場合は、新しいものを試してみる必要があります。</s>"""<UNK> tokens.--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--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-1buse_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>'1@misc{rinna-japanese-gpt-neox-3.6b-instruction-sft-v2,
2 title = {rinna/japanese-gpt-neox-3.6b-instruction-sft-v2},
3 author = {Zhao, Tianyu and Sawada, Kei},
4 url = {https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-sft-v2}
5}
6
7@inproceedings{sawada2024release,
8 title = {Release of Pre-Trained Models for the {J}apanese Language},
9 author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
10 booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
11 month = {5},
12 year = {2024},
13 pages = {13898--13905},
14 url = {https://aclanthology.org/2024.lrec-main.1213},
15 note = {\url{https://arxiv.org/abs/2404.01657}}
16}