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 >= 2 and context_dependence <= 1. That gives 1,426 training scenes from 234 works and 56 validation scenes. The first speaker in a scene becomes user and the other becomes assistant; 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.md has 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
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kuramot6f/classical-smollm2-sft

Finetuned
(1)
this model

Dataset used to train kuramot6f/classical-smollm2-sft