Instructions to use kuramot6f/classical-smollm2-sft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kuramot6f/classical-smollm2-sft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kuramot6f/classical-smollm2-sft")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("kuramot6f/classical-smollm2-sft") model = AutoModelForCausalLM.from_pretrained("kuramot6f/classical-smollm2-sft", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use kuramot6f/classical-smollm2-sft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kuramot6f/classical-smollm2-sft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kuramot6f/classical-smollm2-sft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/kuramot6f/classical-smollm2-sft
- SGLang
How to use kuramot6f/classical-smollm2-sft 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 "kuramot6f/classical-smollm2-sft" \ --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": "kuramot6f/classical-smollm2-sft", "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 "kuramot6f/classical-smollm2-sft" \ --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": "kuramot6f/classical-smollm2-sft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use kuramot6f/classical-smollm2-sft with Docker Model Runner:
docker model run hf.co/kuramot6f/classical-smollm2-sft
classical-smollm2-sft: chatting with a model that has only read pre-1868 texts
A dialogue fine-tune of classical-smollm2-trunk, a 125M-parameter model trained from scratch only on texts written before 1868. It was fine-tuned on real conversations from classical and Edo-period texts, so it answers in premodern Japanese with replies such as 「いとかしこし」 or 「おかへりなされませ」.
This is an early research checkpoint. It has learned the turn-taking format and to stop after a short reply, but its replies are formulaic and often don't really answer the question.
Usage
The model was trained with this plain-text format; BOS is added by the tokenizer:
<s>user:
{your message}assistant:
{model reply}</s>
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "kuramot6f/classical-smollm2-sft"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.bfloat16).eval()
prompt = "user:\nいづこへ行く" + "assistant:\n"
inputs = tok(prompt, return_tensors="pt") # prepends <s>
out = model.generate(**inputs, max_new_tokens=96, do_sample=True, temperature=0.8, top_p=0.95,
eos_token_id=tok.eos_token_id, pad_token_id=tok.pad_token_id)
print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
For multi-turn chat, append assistant:\n{reply}</s> after each reply, then user:\n{next message}assistant:\n.
The separators are listed in chat_format.json.
Training
- Base: classical-smollm2-trunk at update 27,500, from the learning-rate decay phase. This is slightly earlier than the final trunk checkpoint published in that repo.
- Data: the high-quality subset of
classical-ja-sft-dialogue: two-speaker
scenes with
extraction_confidence >= 2andcontext_dependence <= 1. That gives 1,426 training scenes from 234 works and 56 validation scenes. The first speaker in a scene becomesuserand the other becomesassistant; consecutive turns by the same speaker are merged. - Loss on assistant tokens and EOS only. Full fine-tuning, learning rate 1e-5, batch ≤16, 3 epochs (270 updates).
- This checkpoint is update 90 (1 epoch), the one with the lowest validation loss:
| update | validation NLL (assistant tokens) |
|---|---|
| 0 (base) | 4.570 |
| 45 | 4.322 |
| 90 (this model) | 4.302 |
| 180 | 4.334 |
| 270 | 4.351 |
Limitations
- Replies are short and generic, and long prompts can cause repetition.
- The validation set is small and mostly from Wikisource. No test-set evaluation and no benchmark has been run, and whether fine-tuning made the model forget some of its pretraining has not been checked.
- Like the base model, it reflects pre-1868 views and must not be used as a source of facts.
SUMMARY.mdhas the full training report (in Japanese).
License
Weights and code: Apache-2.0. The fine-tuning data is CC BY-SA 4.0. The base model's training data also includes public-domain and CC BY-NC-SA 3.0 TW (CBETA) texts; see classical-smollm2-trunk.
- Downloads last month
- 17
Model tree for kuramot6f/classical-smollm2-sft
Base model
kuramot6f/classical-smollm2-trunk