Instructions to use yasutoshi-lab/Ranunculus-v1-1B-DPO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yasutoshi-lab/Ranunculus-v1-1B-DPO with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yasutoshi-lab/Ranunculus-v1-1B-DPO", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("yasutoshi-lab/Ranunculus-v1-1B-DPO", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yasutoshi-lab/Ranunculus-v1-1B-DPO with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yasutoshi-lab/Ranunculus-v1-1B-DPO" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yasutoshi-lab/Ranunculus-v1-1B-DPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yasutoshi-lab/Ranunculus-v1-1B-DPO
- SGLang
How to use yasutoshi-lab/Ranunculus-v1-1B-DPO 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 "yasutoshi-lab/Ranunculus-v1-1B-DPO" \ --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": "yasutoshi-lab/Ranunculus-v1-1B-DPO", "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 "yasutoshi-lab/Ranunculus-v1-1B-DPO" \ --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": "yasutoshi-lab/Ranunculus-v1-1B-DPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yasutoshi-lab/Ranunculus-v1-1B-DPO with Docker Model Runner:
docker model run hf.co/yasutoshi-lab/Ranunculus-v1-1B-DPO
Ranunculus-v1-1B-DPO
Ranunculus-v1-1B-DPOは、Ranunculus-v1-1B-SFTに、そのモデル自身の思考ありの出力から作った組でDPOを行ったモデルです。思考あり/思考なしを切り替えられます(Qwen3 と同じ enable_thinking 方式)。
注記: このモデルの構成(Ranunculus 構成)は、Qwen3-4B のアーキテクチャをベースに規模縮小したものです。Qwen3-4B の重みは使用していません。
研究目的のモデルです。 性能は度外視とし、学習段階ごとにどのような変化が起こるか確認することを重視しています。
モデルの系譜
| 段階 | モデル | 内容 |
|---|---|---|
| 事前学習 | Ranunculus-v1-1B-PT | 日英の Wikipedia で事前学習 |
| SFT | Ranunculus-v1-1B-SFT | 会話データで SFT。思考の有無を切り替えられる |
| DPO | Ranunculus-v1-1B-DPO(このモデル) | 自分の出力から作った組で DPO |
| 量子化 | Ranunculus-v1-1B | DPO 後のモデルを量子化したモデル |
モデルの詳細
| 項目 | 値 |
|---|---|
| 言語 | 日本語・英語 |
| ベースモデル | Ranunculus-v1-1B-SFT |
| エポック数 | 2(28 step) |
| パラメータ数 | 約 1.015B |
| 層数 | 35 |
| 隠れ次元 / FFN 中間次元 | 1,536 / 4,096 |
| Attention | 12 ヘッド(KV ヘッド 3、GQA)、Head 次元 128、q_norm・k_norm あり |
| 活性化関数 | SiLU(SwiGLU) |
| 位置エンコーディング | RoPE(θ = 500,000) |
| 語彙サイズ | 96,000 |
| 最大コンテキスト長 | 8,192 トークン |
| 埋め込みと出力層 | 重みを共有 |
| 保存形式 | float32(model.safetensors、約 4.1GB) |
データ
| データセット | 内容 | 組数(train) |
|---|---|---|
| ranunculus-thinking-onpolicy-dpo | Ranunculus-v1-1B-SFT が思考ありで生成した応答を nvidia/Qwen3.8-27B-NVFP4 で採点し、最高点と最低点を組にしたもの | 867 |
使い方
pip install torch accelerate "transformers==5.19.0"
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "yasutoshi-lab/Ranunculus-v1-1B-DPO"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id, trust_remote_code=True, dtype=torch.bfloat16, device_map="auto"
).eval()
messages = [{"role": "user", "content": "日本の首都はどこですか?"}]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, enable_thinking=False, # 思考させる場合は True
return_tensors="pt", return_dict=True,
).to(model.device)
with torch.no_grad():
out = model.generate(
**inputs, max_new_tokens=1024, do_sample=True, temperature=0.7, top_p=0.9, repetition_penalty=1.1
)
print(tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=False))
Ranunculus 構成のコード(
configuration_ranunculus.py・modeling_ranunculus.py)を同梱しており、config.jsonのauto_mapから読み込まれます。trust_remote_code=Trueが必要です。 動作を確認した版は transformers 5.19.0(PyPI 版)です。transformers の内部の機能を使っているため、ほかの版では動かない可能性があります。 重みは float32 で保存しています。推論ではdtype=torch.bfloat16を推奨します。 チャット形式は ChatML です(chat_template.jinjaを同梱)。enable_thinking=True(既定)では<think>…</think>で思考してから回答し、Falseでは思考せずに回答します。生成は<|im_end|>または<|endoftext|>で終わります。
評価
lm-evaluation-harness で計測しました(単位は %)。few-shot の指定がないものは 0-shot です。選択式のタスクは、チャット形式を使わずに測っています。
| タスク | 形式 | Ranunculus-v1-1B-DPO |
|---|---|---|
| MMLU-Pro | 10 択、5-shot | 11.29 |
| JMMLU | 4 択、5-shot | 26.17 |
| ARC-Easy | 4 択 | 41.92 |
| HellaSwag(acc_norm) | 4 択 | 31.81 |
| LAMBADA | 最後の 1 語 | 27.81 |
| PIQA(acc_norm) | 2 択 | 57.45 |
| WinoGrande | 2 択 | 49.88 |
| XWinograd(日本語) | 2 択 | 55.16 |
| JCommonsenseQA | 5 択、3-shot | 43.25 |
| GSM8K | 生成、5-shot(chat template なし) | 2.27 |
| GSM8K | 生成、5-shot(思考なし) | 1.67 |
| GSM8K | 生成、5-shot(思考あり) | 1.14 |
- JMMLU と JCommonsenseQA は、公式のデータ(nlp-waseda/JMMLU、yahoojapan/JGLUE v1.3)から評価タスクを制作しました。一般の公開値と条件が違うため、単純に比較することはできません。
制約とリスク
- 思考は、日本語の質問でも英語で書かれます(SFT の学習データの思考過程が英語のため)。
- 思考・回答とも、事実関係の誤りや同じ文の繰り返しが多く見られます。思考を閉じずに生成が続くこともあります。思考させても、GSM8K の正答率は上がっていません。
- 事前学習の Wikipedia、SFT の oasst2 の会話、DPO の採点に使ったモデルの話題・地域・視点のバイアスを引き継いでいる可能性があります。
ライセンス
CC BY-SA 3.0
引用
@misc{ranunculus_v1_1b_dpo,
title = {Ranunculus-v1-1B-DPO},
author = {yasutoshi-lab},
year = {2026},
url = {https://huggingface.co/yasutoshi-lab/Ranunculus-v1-1B-DPO}
}
- Downloads last month
- 31