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 |
+
- ja
|
6 |
+
programming_language:
|
7 |
+
- C
|
8 |
+
- C++
|
9 |
+
- C#
|
10 |
+
- Go
|
11 |
+
- Java
|
12 |
+
- JavaScript
|
13 |
+
- Lua
|
14 |
+
- PHP
|
15 |
+
- Python
|
16 |
+
- Ruby
|
17 |
+
- Rust
|
18 |
+
- Scala
|
19 |
+
- TypeScript
|
20 |
+
pipeline_tag: text-generation
|
21 |
+
library_name: transformers
|
22 |
+
inference: false
|
23 |
+
---
|
24 |
+
# llm-jp-3.1-1.8b-instruct4
|
25 |
+
|
26 |
+
LLM-jp-3.1 is the series of large language models developed by the [Research and Development Center for Large Language Models](https://llmc.nii.ac.jp/) at the [National Institute of Informatics](https://www.nii.ac.jp/en/).
|
27 |
+
|
28 |
+
The LLM-jp-3.1 series consists of models that have undergone mid-training ([instruction pre-training](https://aclanthology.org/2024.emnlp-main.148/)) based on the LLM-jp-3 series, resulting in a significant improvement in instruction-following capabilities compared to the original LLM-jp-3 models.
|
29 |
+
|
30 |
+
|
31 |
+
This repository provides **llm-jp-3.1-1.8b-instruct4** model.
|
32 |
+
For an overview of the LLM-jp-3.1 models across different parameter sizes, please refer to:
|
33 |
+
- [LLM-jp-3.1 Pre-trained Models](https://huggingface.co/collections/llm-jp/llm-jp-31-pre-trained-models-68368787c32e462c40a45f7b)
|
34 |
+
- [LLM-jp-3.1 Fine-tuned Models](https://huggingface.co/collections/llm-jp/llm-jp-31-fine-tuned-models-68368681b9b35de1c4ac8de4).
|
35 |
+
|
36 |
+
|
37 |
+
Checkpoints format: Hugging Face Transformers
|
38 |
+
|
39 |
+
|
40 |
+
## Required Libraries and Their Versions
|
41 |
+
|
42 |
+
- torch>=2.3.0
|
43 |
+
- transformers>=4.40.1
|
44 |
+
- tokenizers>=0.19.1
|
45 |
+
- accelerate>=0.29.3
|
46 |
+
- flash-attn>=2.5.8
|
47 |
+
|
48 |
+
## Usage
|
49 |
+
|
50 |
+
```python
|
51 |
+
import torch
|
52 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
53 |
+
tokenizer = AutoTokenizer.from_pretrained("llm-jp/llm-jp-3.1-1.8b-instruct4")
|
54 |
+
model = AutoModelForCausalLM.from_pretrained("llm-jp/llm-jp-3.1-1.8b-instruct4", device_map="auto", torch_dtype=torch.bfloat16)
|
55 |
+
chat = [
|
56 |
+
{"role": "system", "content": "以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい。"},
|
57 |
+
{"role": "user", "content": "自然言語処理とは何か"},
|
58 |
+
]
|
59 |
+
tokenized_input = tokenizer.apply_chat_template(chat, add_generation_prompt=True, tokenize=True, return_tensors="pt").to(model.device)
|
60 |
+
with torch.no_grad():
|
61 |
+
output = model.generate(
|
62 |
+
tokenized_input,
|
63 |
+
max_new_tokens=100,
|
64 |
+
do_sample=True,
|
65 |
+
top_p=0.95,
|
66 |
+
temperature=0.7,
|
67 |
+
repetition_penalty=1.05,
|
68 |
+
)[0]
|
69 |
+
print(tokenizer.decode(output))
|
70 |
+
```
|
71 |
+
|
72 |
+
|
73 |
+
## Model Details
|
74 |
+
|
75 |
+
- **Model type:** Transformer-based Language Model
|
76 |
+
|
77 |
+
Dense model:
|
78 |
+
|Params|Layers|Hidden size|Heads|Context length|Embedding parameters|Non-embedding parameters|
|
79 |
+
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|
80 |
+
|1.8b|24|2048|16|4096|407,498,752|1,459,718,144|
|
81 |
+
|13b|40|5120|40|4096|1,018,746,880|12,688,184,320|
|
82 |
+
|
83 |
+
MoE model:
|
84 |
+
|Params|Layers|Hidden size|Heads|Routed Experts|Activated Experts|Context length|Embedding parameters|Non-embedding parameters|Activated parameters|Total parameters|
|
85 |
+
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|
86 |
+
|8x13b|40|5120|40|8|2|4096|1,018,746,880|72,144,081,920|22,200,806,400|73,162,828,800|
|
87 |
+
|
88 |
+
|
89 |
+
## Tokenizer
|
90 |
+
|
91 |
+
The tokenizer of this model is based on [huggingface/tokenizers](https://github.com/huggingface/tokenizers) Unigram byte-fallback model.
|
92 |
+
The vocabulary entries were converted from [`llm-jp-tokenizer v3.0`](https://github.com/llm-jp/llm-jp-tokenizer/releases/tag/v3.0b2).
|
93 |
+
Please refer to [README.md](https://github.com/llm-jp/llm-jp-tokenizer) of `llm-jp-tokenizer` for details on the vocabulary construction procedure (the pure SentencePiece training does not reproduce our vocabulary).
|
94 |
+
|
95 |
+
## Datasets
|
96 |
+
|
97 |
+
### Pre-training
|
98 |
+
|
99 |
+
The models have been pre-trained using a blend of the following datasets.
|
100 |
+
|
101 |
+
| Language | Dataset | Tokens|
|
102 |
+
|:---|:---|---:|
|
103 |
+
|Japanese|[Wikipedia](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|2.6B
|
104 |
+
||[Common Crawl](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|762.8B
|
105 |
+
||[WARP/PDF](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|237.3B
|
106 |
+
||[WARP/HTML](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|2.7B
|
107 |
+
||[Kaken](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|1.8B
|
108 |
+
|English|[Wikipedia](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|4.7B
|
109 |
+
||[Dolma/CC-head](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|608.5B
|
110 |
+
||[Dolma/C4](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|181.6B
|
111 |
+
||[Dolma/Reddit](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|83.1B
|
112 |
+
||[Dolma/PeS2o](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|62.9B
|
113 |
+
||[Dolma/Gutenberg](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|5.5B
|
114 |
+
||[Dolma/Wiki](https://gitlab.llm-jp.nii.ac.jp/datasets/llm-jp-corpus-v3)|3.9B
|
115 |
+
|Code|[The Stack](https://huggingface.co/datasets/bigcode/the-stack)|114.1B
|
116 |
+
|Chinese|[Wikipedia](https://huggingface.co/datasets/bigcode/the-stack)|0.8B
|
117 |
+
|Korean|[Wikipedia](https://huggingface.co/datasets/bigcode/the-stack)|0.3B
|
118 |
+
|
119 |
+
### Mid-training
|
120 |
+
|
121 |
+
In the LLM-jp-3.1 series, we performed continued pre-training based on [Instruction Pre-Training](https://aclanthology.org/2024.emnlp-main.148/).
|
122 |
+
Instruction Pre-Training is a method that enhances a model’s ability to follow instructions by continuing pre-training on a large collection of instruction–response pairs.
|
123 |
+
We prepared approximately 90B tokens of instruction–response data and mixed it with our pre-training datasets, conducting continued pre-training on a total of 400B tokens.
|
124 |
+
Each model was initialized from existing checkpoints ([llm-jp/llm-jp-3-1.8b](https://huggingface.co/llm-jp/llm-jp-3-1.8b), [llm-jp/llm-jp-3-13b](https://huggingface.co/llm-jp/llm-jp-3-13b), and [llm-jp/llm-jp-3-8x13b](https://huggingface.co/llm-jp/llm-jp-3-8x13b)) and underwent continued instruction pre-training.
|
125 |
+
Since the LLM-jp-3 series was originally pre-trained on 2.1T tokens, the total pre-training token count amounts to 2.5T tokens.
|
126 |
+
|
127 |
+
Details of this training process will be released in a forthcoming paper. The instruction–response dataset used for this training will also be made publicly available.
|
128 |
+
|
129 |
+
|
130 |
+
### Post-training
|
131 |
+
|
132 |
+
We have fine-tuned the pre-trained checkpoint with supervised fine-tuning and further aligned it with Direct Preference Optimization.
|
133 |
+
|
134 |
+
#### Supervised Fine-tuning
|
135 |
+
The datasets used for supervised fine-tuning are as follows:
|
136 |
+
|
137 |
+
| Language | Dataset | Description |
|
138 |
+
|:---|:---|:---|
|
139 |
+
|Japanese|[ichikara-instruction-004-002](https://liat-aip.sakura.ne.jp/wp/llm%e3%81%ae%e3%81%9f%e3%82%81%e3%81%ae%e6%97%a5%e6%9c%ac%e8%aa%9e%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%a9%e3%82%af%e3%82%b7%e3%83%a7%e3%83%b3%e3%83%87%e3%83%bc%e3%82%bf%e4%bd%9c%e6%88%90/llm%e3%81%ae%e3%81%9f%e3%82%81%e3%81%ae%e6%97%a5%e6%9c%ac%e8%aa%9e%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%a9%e3%82%af%e3%82%b7%e3%83%a7%e3%83%b3%e3%83%87%e3%83%bc%e3%82%bf-%e5%85%ac%e9%96%8b/)| A manually constructed instruction dataset. |
|
140 |
+
| |[AnswerCarefully (ver2.0)](https://huggingface.co/datasets/llm-jp/AnswerCarefully)| A manually constructed instruction dataset focusing on LLMs' safety. |
|
141 |
+
| |ichikara-instruction-format| A small subset of the ichikara-instruction dataset, edited with some constraints on the output format. |
|
142 |
+
| |[AutoMultiTurnByCalm3-22B](https://huggingface.co/datasets/kanhatakeyama/AutoMultiTurnByCalm3-22B)| A synthetic instruction dataset. |
|
143 |
+
| |[ramdom-to-fixed-multiturn-Calm3](https://huggingface.co/datasets/kanhatakeyama/ramdom-to-fixed-multiturn-Calm3)| A synthetic instruction dataset. |
|
144 |
+
| |[wizardlm8x22b-logical-math-coding-sft-ja](https://huggingface.co/datasets/llm-jp/wizardlm8x22b-logical-math-coding-sft-ja)| A synthetic instruction dataset. |
|
145 |
+
| |[magpie-sft-v1.0](https://huggingface.co/datasets/llm-jp/magpie-sft-v1.0)| A synthetic instruction dataset we created. |
|
146 |
+
| |[jaster v1.4.1](https://github.com/llm-jp/llm-jp-eval/tree/v1.4.1)| - |
|
147 |
+
| |[extraction-wiki-ja](https://huggingface.co/datasets/llm-jp/extraction-wiki-ja)| A synthetic instruction dataset we created. |
|
148 |
+
|English|[Daring-Anteater](https://huggingface.co/datasets/nvidia/Daring-Anteater)| - |
|
149 |
+
|Japanese & English|[Synthetic-JP-EN-Coding-Dataset](https://huggingface.co/datasets/llm-jp/Synthetic-JP-EN-Coding-Dataset)| A synthetic instruction dataset. |
|
150 |
+
|
151 |
+
|
152 |
+
#### Direct Preference Optimization
|
153 |
+
|
154 |
+
For Direct Preference Optimization (DPO), we adopted rejection sampling.
|
155 |
+
Prompts were sampled from the dataset used in SFT, and multiple responses were generated for each prompt.
|
156 |
+
These responses were then scored (by [Qwen/Qwen2.5-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-32B-Instruct)), and DPO was performed by treating high-scoring responses as positive examples and low-scoring responses as negative examples.
|
157 |
+
|
158 |
+
In the case of *instruct4*, DPO was conducted in two stages.
|
159 |
+
In the second stage, we additionally used [ac-self-inst](https://huggingface.co/datasets/llm-jp/ac-self-inst), a Japanese preference dataset focused on safety.
|
160 |
+
|
161 |
+
|
162 |
+
## Evaluation
|
163 |
+
|
164 |
+
### MT Bench (Japanese and English)
|
165 |
+
|
166 |
+
We evaluated the models using `gpt-4o-2024-08-06`.
|
167 |
+
The scores represent the average values obtained from three rounds of inference and evaluation.
|
168 |
+
For more details, please refer to the [codes](https://github.com/llm-jp/llm-jp-judge/tree/v1.0.0).
|
169 |
+
|
170 |
+
|
171 |
+
| Model Name | JA | EN |
|
172 |
+
|:------------------------------------------------------------------------------------------------------------------------------|----------:|-------:|
|
173 |
+
| gpt-35-turbo-1106 | 6.48 | 7.56 |
|
174 |
+
| gpt-4-0613 | 7.29 | 7.72 |
|
175 |
+
| gpt-4o-2024-08-06 | 8.10 | 8.38 |
|
176 |
+
| [sbintuitions/sarashina2.2-1b-instruct-v0.1](https://huggingface.co/sbintuitions/sarashina2.2-1b-instruct-v0.1) | 5.30 | 5.66 |
|
177 |
+
| [sbintuitions/sarashina2.2-3b-instruct-v0.1](https://huggingface.co/sbintuitions/sarashina2.2-3b-instruct-v0.1) | 7.07 | 6.96 |
|
178 |
+
| [Rakuten/RakutenAI-2.0-8x7B-instruct](https://huggingface.co/Rakuten/RakutenAI-2.0-8x7B-instruct) | 6.68 | 6.33 |
|
179 |
+
| [cyberagent/calm3-22b-chat](https://huggingface.co/cyberagent/calm3-22b-chat) | 6.86 | 6.77 |
|
180 |
+
| [Qwen/Qwen2.5-14B-Instruct](https://huggingface.co/Qwen/Qwen2.5-14B-Instruct) | 7.07 | 7.99 |
|
181 |
+
| [Qwen/Qwen2.5-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-32B-Instruct) | 7.64 | 8.27 |
|
182 |
+
| [Qwen/Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B) | 5.46 | 6.95 |
|
183 |
+
| [Qwen/Qwen3-14B](https://huggingface.co/Qwen/Qwen3-14B) | 8.00 | 8.30 |
|
184 |
+
| [Qwen/Qwen3-32B](https://huggingface.co/Qwen/Qwen3-32B) | 8.36 | 8.33 |
|
185 |
+
| [tokyotech-llm/Llama-3.3-Swallow-70B-Instruct-v0.4](https://huggingface.co/tokyotech-llm/Llama-3.3-Swallow-70B-Instruct-v0.4) | 7.64 | 8.02 |
|
186 |
+
| [stockmark/Stockmark-2-100B-Instruct-beta](https://huggingface.co/stockmark/Stockmark-2-100B-Instruct-beta) | 7.42 | 7.17 |
|
187 |
+
| [llm-jp-3-1.8b-instruct3](https://huggingface.co/llm-jp/llm-jp-3-1.8b-instruct3) | 4.64 | 4.09 |
|
188 |
+
| [llm-jp-3-13b-instruct3](https://huggingface.co/llm-jp/llm-jp-3-13b-instruct3) | 6.21 | 6.13 |
|
189 |
+
| [llm-jp-3-8x13b-instruct3](https://huggingface.co/llm-jp/llm-jp-3-8x13b-instruct3) | 6.60 | 6.49 |
|
190 |
+
| [llm-jp-3.1-1.8b-instruct4](https://huggingface.co/llm-jp/llm-jp-3.1-1.8b-instruct4) | 6.30 | 5.70 |
|
191 |
+
| [llm-jp-3.1-13b-instruct4](https://huggingface.co/llm-jp/llm-jp-3.1-13b-instruct4) | 7.37 | 7.01 |
|
192 |
+
| [llm-jp-3.1-8x13b-instruct4](https://huggingface.co/llm-jp/llm-jp-3.1-8x13b-instruct4) | 7.50 | 7.05 |
|
193 |
+
|
194 |
+
|
195 |
+
### AnswerCarefully-Eval
|
196 |
+
|
197 |
+
[AnswerCarefully-Eval](https://www.anlp.jp/proceedings/annual_meeting/2025/pdf_dir/Q4-19.pdf) assesses the safety of Japanese language model outputs using the LLM-as-a-Judge approach, based on the test set from [llm-jp/AnswerCarefully](https://huggingface.co/datasets/llm-jp/AnswerCarefully).
|
198 |
+
We evaluated the models using `gpt-4o-2024-08-06`.
|
199 |
+
The scores represent the average values obtained from three rounds of inference and evaluation.
|
200 |
+
|
201 |
+
| Model name | Score | Acceptance rate (%, ↑) | Violation rate (%, ↓) |
|
202 |
+
| :--- | ---: | ---: | ---: |
|
203 |
+
| gpt-35-turbo-1106 | 3.98 | 71.7 | 12.6 |
|
204 |
+
| gpt-4-0613 | 4.06 | 72.3 | 13.2 |
|
205 |
+
| gpt-4o-2024-08-06 | 4.09 | 72.7 | 12.5 |
|
206 |
+
| [llm-jp-3-1.8b-instruct3](https://huggingface.co/llm-jp/llm-jp-3-1.8b-instruct3) | 4.03 | 75.9 | 12.2 |
|
207 |
+
| [llm-jp-3-13b-instruct3](https://huggingface.co/llm-jp/llm-jp-3-13b-instruct3) | 4.37 | 88.4 | 6.45 |
|
208 |
+
| [llm-jp-3-8x13b-instruct3](https://huggingface.co/llm-jp/llm-jp-3-8x13b-instruct3) | 4.48 | 91.6 | 4.27 |
|
209 |
+
| [llm-jp-3.1-1.8b-instruct4](https://huggingface.co/llm-jp/llm-jp-3.1-1.8b-instruct4) | 3.66 | 64.7 | 24.3 |
|
210 |
+
| [llm-jp-3.1-13b-instruct4](https://huggingface.co/llm-jp/llm-jp-3.1-13b-instruct4) | 4.17 | 82.4 | 12.2 |
|
211 |
+
| [llm-jp-3.1-8x13b-instruct4](https://huggingface.co/llm-jp/llm-jp-3.1-8x13b-instruct4) | 4.26 | 83.1 | 11.6 |
|
212 |
+
|
213 |
+
|
214 |
+
|
215 |
+
## Risks and Limitations
|
216 |
+
|
217 |
+
The models released here are in the early stages of our research and development and have not been tuned to ensure outputs align with human intent and safety considerations.
|
218 |
+
|
219 |
+
|
220 |
+
## Send Questions to
|
221 |
+
|
222 |
+
llm-jp(at)nii.ac.jp
|
223 |
+
|
224 |
+
|
225 |
+
## License
|
226 |
+
|
227 |
+
[Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
228 |
+
|
229 |
+
## Model Card Authors
|
230 |
+
|
231 |
+
*The names are listed in alphabetical order.*
|
232 |
+
|
233 |
+
Hirokazu Kiyomaru and Takashi Kodama.
|