File size: 2,121 Bytes
27341b6 4e74950 27341b6 4e74950 a589be0 4e74950 7db5ed1 4e74950 a589be0 4e74950 a589be0 4e74950 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | ---
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 |