File size: 2,047 Bytes
7f12c11
1bd9928
 
 
 
 
 
 
 
 
 
4b45e82
1bd9928
 
 
 
 
 
7f12c11
 
30f10c1
7f12c11
bb58bd2
 
 
 
 
 
ad7d465
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b45e82
 
 
fc475a3
7f12c11
4b45e82
fc475a3
 
7f12c11
4b45e82
 
7f12c11
4b45e82
 
 
7f12c11
4b45e82
1bd9928
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
79
80
81
82
83
84
85
86
87
---
language:
- en
- ja
pipeline_tag: text-generation
tags:
- facebook
- meta
- pytorch
- llama
- llama-3
license: other
license_name: llama3
license_link: LICENSE
datasets:
- cl-nagoya/auto-wiki-qa
- llm-jp/databricks-dolly-15k-ja
library_name: transformers
---

# 日本語向け Llama 3 8B

# はじめに
このリポジトリはLlama3を日本語化しようとしたモデルのリポジトリです。

# ライセンス
Llama 3 ライセンスなので商用利用可能です。ただし、Llama 3ライセンスをよく読んで使ってください。
 
# Usage

```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

# プロンプトの準備
messages = [
    {
        'role': "system",
        'content': "あなたは日本語で回答するAIアシスタントです。"
    },
    {
        'role': "user",
        'content': "猫と犬、どっちが好き?"
    }
]
prompt=tokenizer.apply_chat_template(messages, tokenize=False)

# 推論の実行
input_ids = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
    **input_ids,
    max_new_tokens=128,
    do_sample=True,
    top_p=0.95,
    temperature=0.2,
    repetition_penalty=1.1,
    eos_token_id=[
        tokenizer.eos_token_id,
        tokenizer.convert_tokens_to_ids("<|eot_id|>")
    ],
)
print(tokenizer.decode(outputs[0]))
```

Result:

```python
```

# 学習データ
- llm-jp/databricks-dolly-15k-ja
- cl-nagoya/auto-wiki-qa
- meta-llama/Meta-Llama-3-8B-Instruct

# 学習方法
meta-llama/Meta-Llama-3-8B-Instructに対して、cl-nagoya/auto-wiki-qaにある約240万件の学習データでLoRAによるインストラクションチューニングを1epoch行い、LoRAをマージしました。
その後、そのモデルに対して、llm-jp/databricks-dolly-15k-jaでLoRAによるインストラクションチューニングを1epoch行い、LoRAをマージしました。

# ハードウェア
- NVIDIA A6000x2

# ソフトウェア
- transformers
- trl

# 学習時間
- 50 GPU hours