Instructions to use yasutoshi-lab/Ranunculus-v1-1B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yasutoshi-lab/Ranunculus-v1-1B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yasutoshi-lab/Ranunculus-v1-1B", 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", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yasutoshi-lab/Ranunculus-v1-1B 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" # 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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yasutoshi-lab/Ranunculus-v1-1B
- SGLang
How to use yasutoshi-lab/Ranunculus-v1-1B 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" \ --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", "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" \ --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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yasutoshi-lab/Ranunculus-v1-1B with Docker Model Runner:
docker model run hf.co/yasutoshi-lab/Ranunculus-v1-1B
Ranunculus-v1-1B
Ranunculus-v1-1Bは、Ranunculus-v1-1B-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-DPO |
| パラメータ数 | 約 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 トークン |
| 埋め込みと出力層 | 重みを共有 |
| 保存形式 | compressed-tensors(model.safetensors、約 0.84GB) |
量子化
| 部分 | 精度 |
|---|---|
| attention(q/k/v/o_proj) | int8(出力チャネルごとのスケール) |
| MLP(gate/up/down_proj) | int4(128 列ごとのスケール) |
| 埋め込み(出力層と共有)・RMSNorm | bf16(量子化しない) |
- 方法:GPTQ(llm-compressor 0.14.0)
- 較正データ:ranunculus-sft の会話 512 件(思考あり 237・思考なし 275、最大 2,048 トークン)
使い方
pip install torch accelerate compressed-tensors "transformers==5.19.0"
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "yasutoshi-lab/Ranunculus-v1-1B"
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 の内部の機能を使っているため、ほかの版では動かない可能性があります。 動作を確認した compressed-tensors の版は 0.19.0 です。 transformers では、推論時に量子化した重みを bf16 に戻して計算します。小さくなるのはダウンロードと読み込み直後のメモリで、推論中のメモリと速度は元のモデルと同等か遅くなります。 チャット形式は ChatML です(chat_template.jinjaを同梱)。enable_thinking=True(既定)では<think>…</think>で思考してから回答し、Falseでは思考せずに回答します。生成は<|im_end|>または<|endoftext|>で終わります。
評価
lm-evaluation-harness で計測しました(単位は %)。few-shot の指定がないものは 0-shot です。選択式のタスクは、チャット形式を使わずに測っています。
| タスク | 形式 | Ranunculus-v1-1B |
|---|---|---|
| MMLU-Pro | 10 択、5-shot | 11.30 |
| JMMLU | 4 択、5-shot | 26.27 |
| ARC-Easy | 4 択 | 42.05 |
| HellaSwag(acc_norm) | 4 択 | 31.92 |
| LAMBADA | 最後の 1 語 | 26.99 |
| PIQA(acc_norm) | 2 択 | 57.24 |
| WinoGrande | 2 択 | 49.25 |
| XWinograd(日本語) | 2 択 | 54.74 |
| JCommonsenseQA | 5 択、3-shot | 42.72 |
| GSM8K | 生成、5-shot(chat template なし) | 1.52 |
| GSM8K | 生成、5-shot(思考なし) | 1.44 |
| GSM8K | 生成、5-shot(思考あり) | 1.21 |
- JMMLU と JCommonsenseQA は、公式のデータ(nlp-waseda/JMMLU、yahoojapan/JGLUE v1.3)から評価タスクを制作しました。一般の公開値と条件が違うため、単純に比較することはできません。
制約とリスク
- 思考は、日本語の質問でも英語で書かれます(SFT の学習データの思考過程が英語のため)。
- 思考・回答とも、事実関係の誤りや同じ文の繰り返しが多く見られます。思考を閉じずに生成が続くこともあります。思考させても、GSM8K の正答率は上がっていません。
- 量子化により、事前学習の検証 loss は元のモデルより 0.02 程度悪化しています(英 2.2518 → 2.2674、日 2.9562 → 2.9771)。
- 事前学習の Wikipedia、SFT の oasst2 の会話、DPO の採点に使ったモデルの話題・地域・視点のバイアスを引き継いでいる可能性があります。
ライセンス
CC BY-SA 3.0
引用
@misc{ranunculus_v1_1b,
title = {Ranunculus-v1-1B},
author = {yasutoshi-lab},
year = {2026},
url = {https://huggingface.co/yasutoshi-lab/Ranunculus-v1-1B}
}
- Downloads last month
- 45
Model tree for yasutoshi-lab/Ranunculus-v1-1B
Base model
yasutoshi-lab/Ranunculus-v1-1B-PT