初始化项目,由ModelHub XC社区提供模型
Model: Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT Source: Original Platform
This commit is contained in:
160
README.md
Normal file
160
README.md
Normal file
@@ -0,0 +1,160 @@
|
||||
---
|
||||
language:
|
||||
- ja
|
||||
license: llama3
|
||||
base_model: tokyotech-llm/Llama-3.1-Swallow-8B
|
||||
library_name: transformers
|
||||
tags:
|
||||
- fine-tuned
|
||||
- japanese
|
||||
- math
|
||||
- openmath
|
||||
- code-generation
|
||||
- text-generation
|
||||
datasets:
|
||||
- nvidia/OpenMathInstruct-1
|
||||
pipeline_tag: text-generation
|
||||
---
|
||||
|
||||
# Llama-3.1-Swallow-8B OpenMath Fine-Tuned (T2T)
|
||||
|
||||
## 概要 / Overview
|
||||
|
||||
Nextorage **AiDAPTIV+** プラットフォーム上で [Llama-3.1-Swallow-8B](https://huggingface.co/tokyotech-llm/Llama-3.1-Swallow-8B) をフルファインチューニングした、日本語数学文章題解答モデルです。
|
||||
|
||||
Python コード生成 + コード実行パイプラインと組み合わせることで Exact Match **60.0%** を達成し、商用 API(Claude Sonnet・GPT-4o: 各 56.7%)を上回りました。
|
||||
|
||||
A full fine-tuned version of [Llama-3.1-Swallow-8B](https://huggingface.co/tokyotech-llm/Llama-3.1-Swallow-8B) for Japanese math word problem solving, trained on AiDAPTIV+ platform by Nextorage.
|
||||
Combined with a Python code-execution pipeline, it achieves Exact Match **60.0%** — surpassing Claude Sonnet and GPT-4o (both 56.7%) on the same test set.
|
||||
|
||||
---
|
||||
|
||||
## 性能 / Performance
|
||||
|
||||
テストセット: OpenMath Instruct 日本語版 30件(コード実行パイプライン使用)
|
||||
|
||||
| モデル | Exact Match |
|
||||
|--------|:-----------:|
|
||||
| Llama-3.1-Swallow-8B(未FT ベースライン) | 36.7% |
|
||||
| Claude Sonnet (format_compliant) | 56.7% |
|
||||
| GPT-4o (format_compliant) | 56.7% |
|
||||
| **本モデル(Full FT + コード実行パイプライン)** | **60.0%** |
|
||||
|
||||
> **注**: コード実行パイプラインなしでは 20.0%。パイプラインにより 3 倍の精度向上。
|
||||
|
||||
---
|
||||
|
||||
## 使い方 / Usage
|
||||
|
||||
### 推論スクリプト(コード実行パイプライン付き)
|
||||
|
||||
```bash
|
||||
# 依存パッケージのインストール
|
||||
pip install transformers torch
|
||||
|
||||
# 評価・推論の実行(コード実行パイプライン有効)
|
||||
python run_inference.py \
|
||||
--model_path /path/to/this/model \
|
||||
--test_data /path/to/test.json \
|
||||
--code_exec_pipeline \
|
||||
--output_dir ./results
|
||||
```
|
||||
|
||||
### Python での直接推論
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
import torch
|
||||
|
||||
model_path = "Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT"
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_path,
|
||||
torch_dtype=torch.bfloat16,
|
||||
device_map="auto"
|
||||
)
|
||||
|
||||
SYSTEM_PROMPT = """あなたは数学の問題を解く優秀なAIアシスタントです。ステップバイステップで考え、Pythonコードを使って計算し、最終的な答えを明示してください。
|
||||
|
||||
回答は以下のフォーマットに従ってください:
|
||||
1. Pythonコードは <llm-code> と </llm-code> タグで囲んでください
|
||||
2. コードの実行結果は <llm-code-output> と </llm-code-output> タグで囲んでください
|
||||
3. 最終的な答えは \\boxed{答え} の形式で明示してください"""
|
||||
|
||||
question = "ジェイデンは8台のおもちゃの車を持っています。3台を友人に譲りました。ジェイデンには何台のおもちゃの車が残っていますか?"
|
||||
|
||||
messages = [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": question},
|
||||
]
|
||||
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
|
||||
output = model.generate(input_ids, max_new_tokens=512)
|
||||
print(tokenizer.decode(output[0][input_ids.shape[1]:], skip_special_tokens=True))
|
||||
```
|
||||
|
||||
**期待出力例:**
|
||||
```
|
||||
Pythonコードを使用してこの問題を解決しましょう。<llm-code>
|
||||
initial_cars = 8
|
||||
given_away = 3
|
||||
remaining = initial_cars - given_away
|
||||
print(remaining)
|
||||
</llm-code><llm-code-output>
|
||||
5
|
||||
</llm-code-output>
|
||||
したがって、ジェイデンには \boxed{5} 台のおもちゃの車が残っています。
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 学習設定 / Training Configuration
|
||||
|
||||
| パラメータ | 値 |
|
||||
|-----------|-----|
|
||||
| ベースモデル | tokyotech-llm/Llama-3.1-Swallow-8B |
|
||||
| 手法 | Full Fine-Tuning |
|
||||
| 学習データ | OpenMath Instruct 日本語版(9,772件 クリーニング済み) |
|
||||
| Learning Rate | 1e-6 |
|
||||
| LR Scheduler | cosine |
|
||||
| Epoch | 1 |
|
||||
| Batch Size (effective) | 32 (per_device=2, grad_accum=16) |
|
||||
| Max Seq Length | 2048 |
|
||||
| Precision | bf16_mixed |
|
||||
| Weight Decay | 0.05 |
|
||||
| プラットフォーム | Nextorage AiDAPTIV+ (phisonai2) |
|
||||
|
||||
### データセット詳細
|
||||
|
||||
- 元データ: [NVIDIA OpenMathInstruct-1](https://huggingface.co/datasets/nvidia/OpenMathInstruct-1) 日本語翻訳版(全 1,825,008 件)
|
||||
- `<llm-code>` タグ付きエントリを抽出後、Python 実行検証でクリーニング(除外率 2.3%)
|
||||
- GSM8K・MATH 等の数学ベンチマークを元に構築された数学文章題 + Python コード解答ペア
|
||||
|
||||
---
|
||||
|
||||
## 制限事項 / Limitations
|
||||
|
||||
- 日本語数学文章題(主に GSM8K・MATH 難易度)に特化しており、他タスクの性能は保証されない
|
||||
- 最高精度の発揮には Python コード実行パイプライン(`subprocess` 実行環境)が必要
|
||||
- 日本語翻訳は機械翻訳を使用しており、一部の表現に不自然さが残る場合がある
|
||||
- テストセット 30件での評価結果のため、統計的信頼区間に注意
|
||||
|
||||
---
|
||||
|
||||
## ライセンス / License
|
||||
|
||||
本モデルは [Llama 3.1 Community License](https://llama.meta.com/llama3_1/license/) に基づいています。
|
||||
商用利用は条件付きで許可されています。詳細はライセンス全文を参照してください。
|
||||
|
||||
---
|
||||
|
||||
## 引用 / Citation
|
||||
|
||||
```bibtex
|
||||
@misc{nextorage-openmath-ft-2026,
|
||||
title = {Llama-3.1-Swallow-8B OpenMath Fine-Tuned},
|
||||
author = {Nextorage Inc.},
|
||||
year = {2026},
|
||||
howpublished = {\url{https://huggingface.co/Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT}},
|
||||
note = {Full fine-tuned model for Japanese math word problem solving on AiDAPTIV+ platform}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user