Instructions to use k4rasu/zundamon-tiny-llm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use k4rasu/zundamon-tiny-llm with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="k4rasu/zundamon-tiny-llm")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("k4rasu/zundamon-tiny-llm") model = AutoModelForCausalLM.from_pretrained("k4rasu/zundamon-tiny-llm", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use k4rasu/zundamon-tiny-llm with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "k4rasu/zundamon-tiny-llm" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "k4rasu/zundamon-tiny-llm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/k4rasu/zundamon-tiny-llm
- SGLang
How to use k4rasu/zundamon-tiny-llm 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 "k4rasu/zundamon-tiny-llm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "k4rasu/zundamon-tiny-llm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "k4rasu/zundamon-tiny-llm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "k4rasu/zundamon-tiny-llm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use k4rasu/zundamon-tiny-llm with Docker Model Runner:
docker model run hf.co/k4rasu/zundamon-tiny-llm
幼生ずんだもん v4(zundamon-tiny-llm)
ゼロから学習した、とても小さな「ずんだもん風」の日本語会話モデルです。話しかけると、ずんだもんとして短く返事をし、返事の最後に、そのときの気持ちのタグ(〈うれしい〉〈かなしい〉など 8 種類)を 1 つ付けます。
| 版 | パラメータ | 構造 | int8 の大きさ |
|---|---|---|---|
| base(このフォルダの直下) | 約 174 万 | Llama(dim 128・8 層・8 ヘッド・KV 4 ヘッド・FFN 352) | 2.0MB |
small(small/) |
約 81 万 | Llama(dim 96・6 層・6 ヘッド・KV 3 ヘッド・FFN 256) | 0.9MB |
- 語彙:2,048(SentencePiece BPE)
- 文脈の長さ:256 トークン
ブラウザの中だけでも動きます。M5Stack Core2(ESP32)向けの int8 版も llama2c/ に入れています。
- デモ:https://crowpilot.github.io/zundamon-tiny-llm/
- コード(学習・Core2・ブラウザ):https://github.com/crowpilot/zundamon-tiny-llm
非公式のファン作品です。ずんだもんは東北ずん子・ずんだもんプロジェクトのキャラクターで、キャラクター利用の手引きに沿って非商用で公開しています。モデルがとても小さいので、ときどきおかしなことを言います。
使い方(transformers)
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "crowpilot/zundamon-tiny-llm"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo) # small は subfolder="small"
prompt = "A:おはよう、ずんだもん!B:"
ids = tok(prompt, return_tensors="pt").input_ids # 先頭に <s> が付きます
out = model.generate(ids, max_new_tokens=48, do_sample=False)
print(tok.decode(out[0, ids.shape[1]:])) # 例: おはよー!ボクはいつも元気いっぱいなのだ!〈ふつう〉
書き方の約束
- 話者:全角の
A:(話しかけ)とB:(ずんだもん)で書きます。 - 返事の終わり:返事の最後に気持ちのタグが 1 つ出て止まります(
generation_config.jsonの終わりのトークンにタグを入れてあります)。8 種類は〈ふつう〉〈うれしい〉〈ドヤ〉〈びっくり〉〈かなしい〉〈ぷんぷん〉〈こまった〉〈ねむい〉です。 - 会話の区切り:この版は 1 往復ずつ学習しています。話しかけるたびに先頭に
<s>を置くと、いちばん安定します。
Core2(ESP32)・llama2.c で使う
llama2c/ に次のファイルがあります。
| ファイル | 中身 |
|---|---|
zundamon-v4-base_q8.bin、zundamon-v4-small_q8.bin |
int8(グループ 32)。Core2 とブラウザ版の形式 |
zundamon-v4-*_fp32.bin |
llama2.c 形式の FP32 |
tok.bin |
llama2.c 形式のトークナイザ |
読み込み方はコードのリポジトリを見てください。気持ちタグ(語彙の 5〜12 番)は、返事の終わりの印として扱います。
学習
- 方法:ランダムな初期値から、次のトークンを当てる学習だけで作りました。指示に従う追加学習や強化学習はしていません。
- データ:Gemma 4(Apache 2.0)で作り、機械と Gemma の採点で選んだ、ずんだもんへの話しかけと返事の組(約 7 万組)。返事の気持ちも Gemma が 8 種類から選んでいます。学習データとデータの作り方は公開していません。
- 大きさ:学習トークンは約 162 万です。
- 環境:NVIDIA V100 1 枚で、base は約 10 分で学習できます。
評価
話しかけ 201 個への返事を、Gemma 4 がモデル名を伏せて 1〜5 点で採点しました。比べたのは、前に公開していた版(v3、気持ちタグなし)です。
| モデル | 応答 | ならでは(決まり文句でないか) | 気持ちタグの一致 |
|---|---|---|---|
| v3 base(前の公開版) | 1.89 | 1.47 | — |
| v4 base | 2.80 | 2.11 | 75.2% |
| v4 small | 2.92 | 2.07 | 75.5% |
- 「気持ちタグの一致」は、学習に使っていない組で、Gemma が付けた気持ちとモデルが選んだ気持ちが同じだった割合です。
- 応答の点が 2 以下の返事も、まだ半分ほどあります。
制限
- とても小さいモデルです。事実の知識はほとんどなく、話がつながらないこともよくあります。
- 1 往復ずつ学習しているので、前の会話の内容は使えません。
- 漢字の多い文や長い文は苦手です。
- 会話の練習用・遊び用です。大事な判断には使わないでください。
ライセンス
- モデル:MIT
- 学習データ:Gemma 4(Apache 2.0)で生成しました。
- ずんだもん:キャラクターに関する権利は東北ずん子・ずんだもんプロジェクトにあり、このライセンスの対象外です。利用するときはキャラクター利用の手引きに従ってください。
English summary
A very small Japanese chat model, trained from scratch, that answers in the style of Zundamon (unofficial, non-commercial fan work).
- Sizes:Llama architecture, about 1.74M parameters (base) and 0.81M (small)
- Vocabulary:2,048-token SentencePiece BPE
- Context length:256 tokens
Prompt format:A:<user>B:, with <s> placed before every exchange. The model ends each reply with one emotion tag such as 〈うれしい〉, and generation stops there.
Training data:about 70k single-turn exchanges written by Gemma 4 (Apache 2.0) and then filtered; each reply was also labeled with one of 8 emotions by Gemma. The dataset is not released.
Other formats:llama2c/ contains the int8 build for an ESP32 (M5Stack Core2) and for the browser demo.
- Downloads last month
- -