|
|
--- |
|
|
license: cc-by-4.0 |
|
|
language: |
|
|
- ja |
|
|
- en |
|
|
pipeline_tag: text-generation |
|
|
inference: false |
|
|
tags: |
|
|
- llama-2 |
|
|
--- |
|
|
|
|
|
日本語でtrainingしたllama2 |
|
|
|
|
|
model size: 417.12M |
|
|
|
|
|
trainingは以下のscript参照 |
|
|
https://github.com/Lightning-AI/lit-gpt/tree/main |
|
|
|
|
|
## use |
|
|
|
|
|
```python |
|
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained("if001/sentencepiece_ja", trust_remote_code=True) |
|
|
model = AutoModelForCausalLM.from_pretrained("if001/llama2_ja_small") |
|
|
|
|
|
import torch |
|
|
from transformers import GenerationConfig |
|
|
|
|
|
prompt="あのイーハトーヴォのすきとおった風、" |
|
|
|
|
|
inputs = tokenizer(prompt, return_tensors="pt") |
|
|
input_ids = inputs["input_ids"] |
|
|
|
|
|
generation_config = GenerationConfig( |
|
|
temperature=0.8, |
|
|
top_p=0.95, |
|
|
top_k=50, |
|
|
num_beams=1, |
|
|
do_sample=True, |
|
|
repetition_penalty=1.2, |
|
|
pad_token_id= tokenizer.pad_token_id, |
|
|
# pad_token_id=tokenizer.unk_token_id, |
|
|
eos_token_id=tokenizer.eos_token_id |
|
|
) |
|
|
with torch.no_grad(): |
|
|
generation_output = model.generate( |
|
|
input_ids=input_ids, |
|
|
generation_config=generation_config, |
|
|
return_dict_in_generate=True, |
|
|
output_scores=True, |
|
|
max_new_tokens=64, |
|
|
) |
|
|
s = generation_output.sequences[0] |
|
|
output = tokenizer.decode(s) |
|
|
print(output) |
|
|
|
|
|
> あの イ ー ハ トー ヴォ の すき と おった 風 、 人の 声 とも 似 あ わぬ 歌 である 。 この 音楽 が われわれ を 最も 愛 し むる 時に その 音楽 は 「 われ 」 に 勝 るもの となった のである 。 |
|
|
``` |
|
|
|
|
|
## dataset |
|
|
英語と日本語のデータセットを使用 |
|
|
|
|
|
``` |
|
|
total tokens: 8.64B |
|
|
|
|
|
wikipedia_ja: 844.65M |
|
|
wikipedia_en: 3.80B |
|
|
open-text-books: 60.17M |
|
|
oscar: 3.85B |
|
|
aozorabunko: 92.97M |
|
|
``` |
|
|
|
|
|
https://huggingface.co/datasets/izumi-lab/wikipedia-ja-20230720 |
|
|
https://huggingface.co/datasets/izumi-lab/wikipedia-en-20230720 |
|
|
https://huggingface.co/datasets/izumi-lab/open-text-books |
|
|
https://huggingface.co/datasets/if001/aozorabunko-clean-sin |
|
|
https://huggingface.co/datasets/if001/oscar_2023_filtered |