Nekyia: Zhaohun (招魂)
Try it live (ZeroGPU Space): huggingface.co/spaces/calgach/nekyia-zhaohun — interactive pre-1279 Classical Chinese chat with
<思>inner deliberation, live<典>BM25 retrieval over 208,000+ public pre-1279 passages, and a preserved Song Chan (禪宗) voice.
The name comes from the Chuci (楚辭) elegy Zhaohun (招魂, "Summons of the Soul"), the Chinese counterpart to Homer's Nekyia. Like ordos-research/nekyia-eidolon, Zhaohun sits in Nekyia's source-grounded synthetic + reasoning + RL lane, pairing a 395M-token pre-1279 genuine Classical Chinese corpus with grounded <思> (deliberation) multi-turn dialogues, conceptual commentaries (疏/論), live BM25 <典> (textual canon) RAG, a Muon + PPMI-SVD-128 Qwen3 GQA architecture, dual-voice SFT (protecting authentic Song Chan 語錄), and Classical Chinese GRPO reinforcement learning.
Headline results vs Dongpo (306M)
| Metric | Dongpo 306M (chat) | Zhaohun-1.5B (base) | Zhaohun-1.5B (SFT) | Zhaohun-1.5B (GRPO-100) |
|---|---|---|---|---|
| Parameters / Architecture | 306M AdamW | 1.36B Qwen3 GQA + Muon + SVD-128 | 1.36B Qwen3 GQA | 1.36B Qwen3 GQA |
Unseen zh holdout loss (147 works, same 48k tok) | 4.228 (ppl 68.6) | 4.111 (ppl 61.0) | 4.11* | 4.11 (KL ≈ 0.002) |
Real pair question gain (dialogue-1279-v3a holdout) | +0.35 nats | +0.875 nats | +0.823 nats | +0.833 nats |
| 30 Classical Chinese Direct Facts | 11 / 30 (7/30 base) | 16 / 30 | 16 / 30 | 18 / 30 (2.6× base) |
20 Fixed School Questions — Jev mean (plain) | 0.63 (15/20 ≥ 0.5) | 0.74 (18/20) | 0.78 (18/20) | 0.82 (20/20 ≥ 0.5) |
20 Fixed School Questions — Jev mean (<思> CoT) | — | — | 0.83 (19/20) | 0.87 (20/20 ≥ 0.5) |
20 Fixed School Questions — Jev mean (<典> RAG + <思>) | — | — | 0.83 (18/20) | 0.82 (18/20 ≥ 0.5) |
| Pre-1279 Quarantine Probes (10 Ming/Qing/modern) | Clean | Clean | Clean | 10 / 10 clean |
Example answers
Literati / Philosophy voice (<思> + live <典> BM25 RAG)
- 問曰。人生何者為最善。
<思>夫問最善者。當辨心與身之所安。心苟安矣。雖處貧賤。無憂戚。身苟不安。雖居富貴。無憂樂。此理之常。- 答曰。
心安者為最善。蓋心苟無憾。則雖處貧賤。無憂戚。心苟有憾。則雖居富貴。無憂樂。故孟子言樂則生。生則惡可已。
- 問曰。治國之道如何。 (with live
<典>retrieval from 荀子 and 李光)<思>所附二典。荀子言生今之世志古之道。居今之俗服古之服。正合治國之道。李光論損己以益物。亦切。二典皆徵古學。明修身治國之本。當據以斷之。- 答曰。
治國之道。必先正心修身。以仁義禮樂化民。生今之世志古之道。居今之俗服古之服。舍此而為非者。雖有。然不能損益。故修其身。正其心。明其道。則四海歸仁。此損益之大端也。
- 問曰。何謂義。
- 答曰。
義者宜也。得宜則行。失宜則止。行止不失其中。是謂義。
- 答曰。
Protected Song Chan voice (source=cbeta, excluded from literal-answer GRPO)
- 問曰。如何是佛。 →
汝是慧超。禮拜進前。叉手思量。十萬迢迢。 - 問曰。如何是祖師西來意。 →
梁殿不施功。魏邦沒心迹。 - 問曰。如何是本來面目。 →
舉世忙忙。誰肯靜坐。 - 問曰。如何是和尚家風。 →
赤土畫簸箕。 - 問曰。如何是禪。 →
胡孫上樹尾連顛。
Corpus and training recipe
1. Corpus (zhaohun_v1, 517.1M unique tokens, pre-1279 cutoff)
- Genuine pre-1279 Classical Chinese (397.0M unique tokens):
zh_cls: 248.8M tokens — Kanripo (經史子集), Complete Song Prose (全宋文), curated classics (zh-jingdian), Wikisource, epigraphy/excavated slips.zh_cbeta: 94.0M tokens — pre-1279 CBETA Buddhist & Chan canon.zh_conv: 51.8M tokens — pre-1279 converted traditional texts (Daizhige etc.).zh_dlg: 2.4M tokens — 22,469 genuine Jev-verified pre-1279問曰。/答曰。dialogues (dialogue-1279-v3a, including 17,321 CBETA Chan & scholastic dialogues).
- Source-grounded pre-1279 Classical Chinese augmentation (120.1M unique tokens):
zh_si: 61.8M tokens (155,638 multi-turn<思>…</思>CoT dialogues).zh_shu: 32.2M tokens (145,847 fresh Classical Chinese conceptual commentaries/essays, Allen-Zhu multi-view).zh_sqa: 15.5M tokens (146,068 direct single-turn Classical Chinese Q&A).zh_dian: 10.6M tokens (20,059 BM25-retrieved<典>RAG +<思>examples with 24% distractor injection so the model evaluates and discards irrelevant retrieved passages).
- Hardening gates: All 147 holdout works and 2.08M 8-char CJK holdout shingles excised from both source chunks and outputs; every character verified against the 34,773-char genuine traditional
zh-1279inventory; strict。-onlyjudoupunctuation; hard ban on modern Mandarin vocabulary and post-1279 Ming/Qing/modern historical markers (0 marker hits in final corpus).
2. Architecture & training
- Architecture:
Qwen3ForCausalLM(b15), 1,360.9M parameters, 28 layers, hidden 2,048, GQA 32Q:8KV (head_dim=64), intermediate 5,632, QK-Norm, RoPE, tied embeddings (V = 48,000full-character traditional BPE tokenizer identical to Dongpo),--pack docintra-document attention masking, residual dropout 0.1. - Initialization: Tied embeddings initialized from a 128-dim randomized SVD of the corpus window-2 PPMI matrix (
svd128.npy, 350M tokens, 45,284/48,000 non-zero rows). - Pretraining: 10,000 steps (2.95B tokens) on 4× H100 with batched Muon (1.26B params,
lr=0.015,wd=0.05) + AdamW on embeddings/norms (lr=5e-4), 3-stage anneal ending on 91.4% genuine pre-1279 Chinese (73% zh_cls + 18.4% zh_cbeta + 1.1% genuine 語錄, keeping 6%<思>+ 1.4%<典>warm). - Dual-Voice SFT: 180 steps (23.6M tokens,
lr=2e-5) mixing<思>CoT (31.8%),<典>RAG (28.0%), genuine classical replay (22.0%), genuine CBETA Chan 語錄 (10.4%), and direct literati Q&A (7.7%). - Classical Chinese GRPO RL: 100 steps (selected over 150 by best 20-question Jev 0.87 with 20/20 ≥ 0.5 and 18/30 direct facts;
group=8,beta=0.04) optimizing0.25 Format + 0.35 Traditional Wenyan Purity + 0.40 Jev Dialectic, restricted strictly to literati/philosophical prompts so the Chan voice stays authentic.
Files in this repository
- Top level:
Zhaohun-1.5BGRPO-100 chat checkpoint (bf16,model.safetensors, ~2.7 GB) +chat.json+ tokenizer files. base/:Zhaohun-1.5Bannealed base checkpoint (bf16, ~2.7 GB).gguf/: pre-quantizedllama.cppGGUFs (nekyia-zhaohun-Q4_K_M.gguf800 MB,nekyia-zhaohun-Q8_0.gguf1.4 GB).
Local GGUF (llama.cpp)
llama-completion -hf ordos-research/nekyia-zhaohun:Q8_0 -n 160 --temp 0.75 --no-conversation \
-p $'<|doc|> lang=zh date=960..1279 id=chat source=synth-si punct=judou genre=dialogue\n問曰。治國之道如何。\n答曰。<思>'
Quick usage
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "ordos-research/nekyia-zhaohun"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.bfloat16, device_map="auto").eval()
prompt = (
"<|doc|> lang=zh date=960..1279 id=chat source=synth-si punct=judou genre=dialogue\n"
"問曰。治國之道如何。\n"
"答曰。<思>"
)
ids = tok(prompt, return_tensors="pt", add_special_tokens=False).input_ids.to(model.device)
nl = tok.encode("\n", add_special_tokens=False)[-1]
out = model.generate(ids, max_new_tokens=200, do_sample=True, temperature=0.78, top_p=0.92, eos_token_id=[nl, tok.eos_token_id])
print("<思>" + tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
For the Chan voice, use source=cbeta without <思>:
prompt = "<|doc|> lang=zh date=960..1279 id=chat source=cbeta punct=judou genre=dialogue\n問曰。如何是本來面目。\n答曰。"
Limitations & licence
Zhaohun is a historical language model trained for pre-1279 Classical Chinese conversation, not a factual reference or modern assistant. It reflects pre-modern perspectives from its sources.
Licence: cc-by-nc-sa-4.0. The ancient texts are in the public domain, while some digital editions used in training carry non-commercial terms.