Instructions to use Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT") model = AutoModelForMultimodalLM.from_pretrained("Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT
- SGLang
How to use Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT with Docker Model Runner:
docker model run hf.co/Nextorage/Llama-3.1-Swallow-8B-OpenMath-FT
Llama-3.1-Swallow-8B OpenMath Fine-Tuned (T2T)
概要 / Overview
Nextorage AiDAPTIV+ プラットフォーム上で 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 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
推論スクリプト(コード実行パイプライン付き)
# 依存パッケージのインストール
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 での直接推論
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 日本語翻訳版(全 1,825,008 件)
<llm-code>タグ付きエントリを抽出後、Python 実行検証でクリーニング(除外率 2.3%)- GSM8K・MATH 等の数学ベンチマークを元に構築された数学文章題 + Python コード解答ペア
制限事項 / Limitations
- 日本語数学文章題(主に GSM8K・MATH 難易度)に特化しており、他タスクの性能は保証されない
- 最高精度の発揮には Python コード実行パイプライン(
subprocess実行環境)が必要 - 日本語翻訳は機械翻訳を使用しており、一部の表現に不自然さが残る場合がある
- テストセット 30件での評価結果のため、統計的信頼区間に注意
ライセンス / License
本モデルは Llama 3.1 Community License に基づいています。 商用利用は条件付きで許可されています。詳細はライセンス全文を参照してください。
引用 / Citation
@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}
}
- Downloads last month
- 50