Files
llm-jp-4-kappa-32b-a3b-v0.1/README.md
ModelHub XC 5c940e6b6c 初始化项目,由ModelHub XC社区提供模型
Model: third-intelligence/llm-jp-4-kappa-32b-a3b-v0.1
Source: Original Platform
2026-09-26 20:04:29 +08:00

331 lines
15 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
license: apache-2.0
language:
- en
- ja
base_model:
- llm-jp/llm-jp-4-32b-a3b-thinking
pipeline_tag: text-generation
library_name: transformers
---
# llm-jp-4-kappa-32b-a3b-v0.1
![kappa-images.003 (1)](https://cdn-uploads.huggingface.co/production/uploads/65f01b5235c5424c262c8be8/DjZxFJ3ic19pm4rkiHuOO.jpeg)
**llm-jp-4-kappa-32b-a3b-v0.1** は、**Third-intelligence** が研究開発の一環で試作した日本語・英語対応の Thinking 型大規模言語モデルです。[`llm-jp/llm-jp-4-32b-a3b-thinking`](https://huggingface.co/llm-jp/llm-jp-4-32b-a3b-thinking) をベースに、
- Reasoning(思考プロセスの生成)能力を強化するための **SFT (Supervised Fine-Tuning)**
- 数学・コード領域における **強化学習 (Reinforcement Learning)**
の 2 段階の追加学習を行い、ベースモデルが持つ日本語性能を維持しつつ、推論・数学・コーディング能力の向上を目指しました。
ベースモデルと同様、**Mixture-of-Experts (MoE) アーキテクチャ**(総パラメータ約 32B / activated 約 3B)を採用しているため、同規模の dense モデルと比較して推論時の計算コストを抑えつつ、高い性能を発揮します。
詳細については[技術ブログ](https://third-intelligence.com/ja/posts/kappa-v01-reasoning-post-training)を参照ください。
---
## モデル概要
| 項目 | 内容 |
|---|---|
| ベースモデル | [`llm-jp/llm-jp-4-32b-a3b-thinking`](https://huggingface.co/llm-jp/llm-jp-4-32b-a3b-thinking) |
| アーキテクチャ | Mixture-of-Experts (MoE), Thinking モデル |
| 総パラメータ数 | 約 32B |
| Activated パラメータ数 | 約 3B |
| 学習手法 | SFT(Reasoning 強化) + 強化学習(数学・コード) |
| 対応言語 | 日本語 / 英語 |
| 最大コンテキスト長 | 65,536 tokens |
| ライセンス | Apache License 2.0(ベースモデルの条件も継承) |
---
## ベンチマーク
評価には [swallow-llm/swallow-evaluation-instruct](https://github.com/swallow-llm/swallow-evaluation-instruct) を使用しました(OpenRouter 経由でモデルが使用できるよう、一部修正を加えました。)
また、OpenRouter でデプロイされているモデルについては、serving しているプロバイダーの設定により量子化などが行われており、本来のフルプレシジョン版から性能が劣化している可能性があります。ただし、評価にあたっては OpenRouter 側の設定で可能な限り高いパフォーマンスとなるよう **Exacto** の設定を有効にしました。
LLM-as-a-judgeが必要になるベンチマークについては評価モデルにopenai/gpt-4.1を使用しました。(プロバイダーはAzureに固定しています。)
### 比較対象モデル
| 略称 | モデル ID | 備考 |
|---|---|---|
| **llm-jp-4-kappa (本モデル)** | `third-intelligence/llm-jp-4-kappa-32b-a3b-v0.1` | 本モデル |
| llm-jp-4 | `llm-jp/llm-jp-4-32b-a3b-thinking` | ベースモデル |
| gpt-oss-20b | `openai/gpt-oss-20b` (via OpenRouter) | |
| nemotron-3-nano | `nvidia/nemotron-3-nano-30b-a3b` (via OpenRouter) | |
| qwen3-30b | `qwen/qwen3-30b-a3b-thinking-2507` (via OpenRouter) | |
### サマリー(主要スコア)
> **太字** は各行の最高スコアを示します。
| ベンチマーク | **llm-jp-4-kappa (本モデル)** | llm-jp-4 | gpt-oss-20b | nemotron-3-nano | qwen3-30b |
|---|---:|---:|---:|---:|---:|
| MMLU ProX Japanese (avg) | 0.6724 | 0.6759 | 0.6886 | 0.5740 | **0.7547** |
| MMLU Pro English (avg) | 0.7025 | 0.6956 | 0.7343 | 0.7180 | **0.8038** |
| Japanese MT-Bench (avg) | **0.9339** | 0.9270 | 0.8749 | 0.8900 | 0.8693 |
| English MT-Bench (avg) | 0.9226 | 0.9220 | 0.8899 | 0.9216 | **0.9304** |
| JEMHopQA F1 | 0.6329 | **0.6391** | 0.4737 | 0.2329 | 0.5597 |
| MCLM Math 100 (Japanese) | 0.8788 | 0.8687 | 0.9394 | 0.8081 | **0.9697** |
| GPQA Diamond | 0.5505 | 0.4899 | 0.6364 | 0.5909 | **0.7121** |
| AIME 2024/2025 | 0.4333 | 0.3833 | 0.5667 | 0.3667 | **0.8833** |
### Japanese MT-Bench(カテゴリ別)
| カテゴリ | **llm-jp-4-kappa (本モデル)** | llm-jp-4 | gpt-oss-20b | nemotron-3-nano | qwen3-30b |
|---|---:|---:|---:|---:|---:|
| coding | **0.9480** | 0.9420 | 0.9340 | 0.9450 | 0.8680 |
| extraction | **0.8730** | 0.8650 | 0.8380 | 0.8030 | 0.8400 |
| humanities | **0.9870** | 0.9770 | 0.8300 | 0.9550 | 0.9540 |
| math | **0.9950** | 0.9800 | 0.9920 | 0.9070 | 0.9470 |
| reasoning | **0.8470** | 0.8310 | 0.8090 | 0.8050 | 0.7590 |
| roleplay | **0.9480** | 0.9340 | 0.8310 | 0.8720 | 0.8130 |
| stem | 0.9670 | **0.9770** | 0.9120 | 0.9610 | 0.9130 |
| writing | 0.9060 | **0.9100** | 0.8530 | 0.8720 | 0.8600 |
| 1st turn | **0.9545** | 0.9520 | 0.9145 | 0.8888 | 0.8930 |
| 2nd turn | **0.9133** | 0.9020 | 0.8353 | 0.8913 | 0.8455 |
| **平均** | **0.9339** | 0.9270 | 0.8749 | 0.8900 | 0.8693 |
### English MT-Bench(カテゴリ別)
| カテゴリ | **llm-jp-4-kappa (本モデル)** | llm-jp-4 | gpt-oss-20b | nemotron-3-nano | qwen3-30b |
|---|---:|---:|---:|---:|---:|
| coding | 0.9240 | **0.9340** | 0.9040 | 0.8910 | 0.8860 |
| extraction | 0.8590 | 0.8220 | 0.8610 | 0.8430 | **0.8980** |
| humanities | 0.9570 | **0.9800** | 0.9250 | 0.9410 | 0.9600 |
| math | 0.9990 | 0.9990 | 0.9720 | 0.9960 | **1.0000** |
| reasoning | 0.8460 | 0.8260 | 0.7590 | 0.8990 | **0.9030** |
| roleplay | 0.9290 | **0.9360** | 0.8710 | 0.9340 | 0.9090 |
| stem | **0.9910** | 0.9780 | 0.9380 | 0.9410 | 0.9730 |
| writing | 0.8760 | 0.9010 | 0.8890 | **0.9280** | 0.9140 |
| 1st turn | 0.9468 | 0.9368 | 0.9208 | **0.9523** | 0.9515 |
| 2nd turn | 0.8985 | 0.9073 | 0.8590 | 0.8910 | **0.9093** |
| **平均** | 0.9226 | 0.9220 | 0.8899 | 0.9216 | **0.9304** |
### MMLU ProX Japanese / MMLU Pro English(科目別)
<details>
<summary>📊 MMLU ProX Japanese 科目別スコアを開く</summary>
| 科目 | **llm-jp-4-kappa (本モデル)** | llm-jp-4 | gpt-oss-20b | nemotron-3-nano | qwen3-30b |
|---|---:|---:|---:|---:|---:|
| business | 0.7338 | 0.7326 | 0.7782 | 0.5741 | **0.8238** |
| law | 0.3326 | 0.3472 | 0.3034 | 0.2899 | **0.4067** |
| psychology | 0.6454 | 0.6654 | 0.6654 | 0.5890 | **0.7180** |
| biology | 0.7950 | 0.7880 | 0.7964 | 0.6820 | **0.8522** |
| chemistry | 0.7686 | 0.7712 | 0.8012 | 0.6793 | **0.8640** |
| history | 0.5039 | 0.5223 | 0.5118 | 0.4173 | **0.5984** |
| other | 0.6006 | 0.5898 | 0.5931 | 0.5011 | **0.6656** |
| health | 0.6332 | 0.6332 | 0.6332 | 0.5109 | **0.6594** |
| economics | 0.7370 | 0.7322 | 0.7464 | 0.6351 | **0.8128** |
| math | 0.8586 | 0.8608 | 0.8993 | 0.7631 | **0.9023** |
| physics | 0.7929 | 0.7968 | 0.8075 | 0.6659 | **0.8676** |
| computer science | 0.7512 | 0.7537 | 0.8073 | 0.6634 | **0.8195** |
| philosophy | 0.5050 | 0.5170 | 0.5010 | 0.3928 | **0.5892** |
| engineering | 0.5160 | 0.5222 | 0.5470 | 0.4314 | **0.7379** |
| **平均** | 0.6724 | 0.6759 | 0.6886 | 0.5740 | **0.7547** |
</details>
<details>
<summary>📊 MMLU Pro English 科目別スコアを開く</summary>
| 科目 | **llm-jp-4-kappa (本モデル)** | llm-jp-4 | gpt-oss-20b | nemotron-3-nano | qwen3-30b |
|---|---:|---:|---:|---:|---:|
| business | 0.7529 | 0.7452 | 0.8137 | 0.7617 | **0.8631** |
| law | 0.4532 | 0.4405 | 0.4142 | 0.4714 | **0.5450** |
| psychology | 0.7306 | 0.7168 | 0.7206 | 0.7556 | **0.7757** |
| biology | 0.8410 | 0.8536 | 0.8536 | 0.8438 | **0.8870** |
| chemistry | 0.7420 | 0.7482 | 0.8269 | 0.7889 | **0.8763** |
| history | 0.6273 | 0.6010 | 0.5906 | 0.6089 | **0.6483** |
| other | 0.6504 | 0.6353 | 0.6461 | 0.6526 | **0.7370** |
| health | 0.6883 | 0.6601 | 0.7237 | 0.7152 | **0.7665** |
| economics | 0.7820 | 0.7761 | 0.7998 | 0.7773 | **0.8483** |
| math | 0.8653 | 0.8564 | 0.9112 | 0.8756 | **0.9445** |
| physics | 0.7852 | 0.7814 | 0.8276 | 0.7921 | **0.8961** |
| computer science | 0.7268 | 0.7341 | 0.8146 | 0.7756 | **0.8439** |
| philosophy | 0.5892 | 0.6132 | 0.6192 | 0.5972 | **0.6854** |
| engineering | 0.5057 | 0.4902 | 0.5944 | 0.5304 | **0.7678** |
| **平均** | 0.7025 | 0.6956 | 0.7343 | 0.7180 | **0.8038** |
</details>
---
## 使い方
### 必要環境
- GPU: 推奨 **A100 80GB ×2 以上 / H100 80GB ×2 以上**(bfloat16・MoE expert parallel 動作時)
- 単一 80GB GPU でも `tensor-parallel-size=1` で動作可能ですが、KV キャッシュ確保のため `--max-model-len` を下げる必要がある場合があります。
- CUDA 12.4+
- Python 3.10+
### 1. transformers での推論
HuggingFace transformers ベースのパイプラインに組み込みたい場合は、以下のように直接ロードして使用できます。なお transformers から直接生成すると、出力には思考プロセス用の特殊トークン(`<|channel|>analysis` や `<|channel|>final` など)がそのまま含まれるため、思考と最終回答を分離して扱いたい場合は前述の vLLM + cookbook 構成を利用するか、出力をパースしてください。
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "third-intelligence/llm-jp-4-kappa-32b-a3b-v0.1"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
messages = [
{"role": "user", "content": "日本の宇宙開発の歴史について教えてください。"},
]
# chat_template により思考用プロンプトが付与されます
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
).to(model.device)
with torch.no_grad():
output_ids = model.generate(
input_ids,
max_new_tokens=4096,
do_sample=True,
temperature=0.7,
top_p=0.95,
pad_token_id=tokenizer.eos_token_id,
)
generated = output_ids[0][input_ids.shape[-1]:]
print(tokenizer.decode(generated, skip_special_tokens=False))
```
### 2. vLLM での推論(推奨)
LLM-jp-4 系のモデルは、独自の Reasoning フォーマット(`<|channel|>final` などの特殊トークンによる思考プロセス出力)を採用しているため、素の vLLM ではそのまま正しく serve することができません。公式の [`llm-jp/llm-jp-4-cookbook`](https://github.com/llm-jp/llm-jp-4-cookbook) を利用することが推奨されています。
#### セットアップ
```bash
# 1. vLLM 0.17 以降をインストール
pip install "vllm>=0.17.0"
# 2. LLM-jp-4 cookbook を clone
git clone https://github.com/llm-jp/llm-jp-4-cookbook.git
cd llm-jp-4-cookbook/llmjp4_vllm
```
#### vLLM サーバの起動
```bash
python example_cli.py serve third-intelligence/llm-jp-4-kappa-32b-a3b-v0.1 \
--host 0.0.0.0 \
--port 8000 \
--served-model-name llm-jp-4-kappa \
--trust-remote-code \
--dtype bfloat16 \
--tensor-parallel-size 2 \
--gpu-memory-utilization 0.85 \
--max-model-len 65536 \
--reasoning-parser llmjp4 \
--enable-expert-parallel
```
主なオプションの意味:
| オプション | 説明 |
|---|---|
| `--reasoning-parser llmjp4` | LLM-jp-4 thinking 用の reasoning parser を有効化。**必須** |
| `--enable-expert-parallel` | MoE の expert parallel を有効化(マルチ GPU で推奨) |
| `--tensor-parallel-size` | テンソル並列数。GPU 枚数に合わせて変更してください(1, 2, 4, 8 など) |
| `--max-model-len` | 最大コンテキスト長(最大 65,536) |
| `--gpu-memory-utilization` | GPU メモリ使用率の上限。OOM になる場合は下げてください |
> **トラブルシュート: `RuntimeError: Already borrowed`**
> 環境によっては、reasoning parser の初期化時に tokenizer の競合により上記エラーが発生することがあります。その場合は cookbook 内 `llmjp4_reasoning_parser.py` の以下 2 行を、tokenizer.encode を経由しない形に置き換えてください。
>
> ```python
> # Before
> self._reasoning_end_prefix = tokenizer.encode("<|channel|>final")
> self._reasoning_prefill = tokenizer.encode("<|start|>assistant")
>
> # After
> self._reasoning_end_prefix = [9, 2520]
> self._reasoning_prefill = [10, 12811]
> ```
#### OpenAI 互換 API で叩く
```bash
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "llm-jp-4-kappa",
"messages": [
{"role": "user", "content": "整数 a, b が a^2 + b^2 = 50 を満たすとき、(a, b) の組み合わせを全て求めてください。"}
],
"max_tokens": 4096,
"temperature": 0.7
}'
```
Python (OpenAI SDK) からも同様に呼び出せます。`--reasoning-parser llmjp4` を有効にしているため、思考プロセスは `reasoning_content` フィールドに、最終回答は `content` フィールドに分離されて返ります。
```python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
resp = client.chat.completions.create(
model="llm-jp-4-kappa",
messages=[
{"role": "user", "content": "再帰関数を使ってフィボナッチ数列の n 番目の値を返す Python 関数を書いてください。"}
],
max_tokens=4096,
temperature=0.7,
)
msg = resp.choices[0].message
print("=== 思考プロセス ===")
print(getattr(msg, "reasoning_content", ""))
print("=== 最終回答 ===")
print(msg.content)
```
---
## 注意事項
本モデルは **研究目的で公開されているモデル** です。出力の正確性・安全性・倫理性は保証されず、事実と異なる内容(ハルシネーション)や不適切な内容を生成する可能性があります。商用利用やミッションクリティカルな用途での使用は想定していません。本モデルの利用により生じたいかなる損害についても開発者は責任を負いません。ライセンスはベースモデル(`llm-jp/llm-jp-4-32b-a3b-thinking`)の条件も併せて確認・遵守してください。
## ライセンス
本モデルは **Apache License 2.0** のもとで公開されます。ベースモデル `llm-jp/llm-jp-4-32b-a3b-thinking` のライセンス・利用規約も併せて遵守してください。
## 謝辞
- ベースモデルを公開してくださっている [LLM-jp プロジェクト](https://llm-jp.nii.ac.jp/)
- データを公開してくださっている[NVIDIA](https://huggingface.co/nvidia)
- 評価フレームワーク [`swallow-llm/swallow-evaluation-instruct`](https://github.com/swallow-llm/swallow-evaluation-instruct) を公開してくださっている [Swallow プロジェクト](https://swallow-llm.github.io/index.ja.html)
をはじめとする皆様に最大の感謝を申し上げます。
## 引用
```bibtex
@misc{llm-jp-4-kappa-32b-a3b-v0_1,
title = {llm-jp-4-kappa-32b-a3b-v0.1},
author = {third-intelligence},
year = {2026},
howpublished = {\url{https://huggingface.co/third-intelligence/llm-jp-4-kappa-32b-a3b-v0.1}}
}
```