Text Generation
Transformers
Safetensors
haku
feature-extraction
hakuchat
chinese
9b
custom-architecture
conversational
custom_code
Run this model with HF Jobs
Run KSKOOO/hakuchat-9b on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/KSKOOO/hakuchat-9b. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/KSKOOO/hakuchat-9b on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/KSKOOO/hakuchat-9b. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/KSKOOO/hakuchat-9b. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use KSKOOO/hakuchat-9b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KSKOOO/hakuchat-9b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="KSKOOO/hakuchat-9b", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForConditionalGeneration model = AutoModelForConditionalGeneration.from_pretrained("KSKOOO/hakuchat-9b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use KSKOOO/hakuchat-9b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KSKOOO/hakuchat-9b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KSKOOO/hakuchat-9b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/KSKOOO/hakuchat-9b
- SGLang
How to use KSKOOO/hakuchat-9b 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 "KSKOOO/hakuchat-9b" \ --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": "KSKOOO/hakuchat-9b", "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 "KSKOOO/hakuchat-9b" \ --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": "KSKOOO/hakuchat-9b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use KSKOOO/hakuchat-9b with Docker Model Runner:
docker model run hf.co/KSKOOO/hakuchat-9b
HakuChat-9B (Code)
自研 9B 中文模型,基于 Haku 架构(HakuForConditionalGeneration),原生支持 262,144 token 上下文长度。
架构
| 项 | 值 |
|---|---|
| 参数量 | 9B |
| 上下文长度 | 262,144 tokens(无需 RoPE scaling) |
| 权重精度 | bfloat16 |
| KV cache | GQA,4 个 KV heads |
| 自定义代码 | 需要 trust_remote_code=True |
modeling_haku.py / configuration_haku.py 随仓库提供,transformers 会自动通过 trust_remote_code=True 加载。
加载方式
import torch
from transformers import AutoTokenizer, AutoModelForImageTextToText
path = "your-org/hakuchat-code-r8"
tok = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
path, trust_remote_code=True, dtype=torch.bfloat16
).to("cuda").eval()
messages = [{"role": "user", "content": "你是谁?"}]
text = tok.apply_chat_template(messages, tokenize=False,
add_generation_prompt=True, enable_thinking=False)
enc = tok(text, return_tensors="pt").to("cuda")
with torch.inference_mode():
out = model.generate(**enc, max_new_tokens=512, do_sample=False,
pad_token_id=tok.pad_token_id or tok.eos_token_id)
print(tok.decode(out[0][enc["input_ids"].shape[1]:], skip_special_tokens=True))
评测结果(2026 口径,730 题全量本地实测)
| 基准 | R11 @1k greedy | R11 @1k sample | R13 @8k sample | R14 @1k greedy |
|---|---|---|---|---|
| MMLU-Pro | 64.64% | 58.21% | 58.57% | 60.00% |
| AIME-2026 | 3.33% | 3.33% | 6.67% | 0.00% |
| MATH-500 | 53.00% | 45.00% | 32.00% | 42.00% |
| IFEval | 72.50% | 70.83% | 70.00% | 65.00% |
| SciQ | 93.00% | 95.00% | 91.00% | 93.00% |
| CommonsenseQA | 80.00% | 76.00% | 69.00% | 79.00% |
| 宏平均 | 61.08% | 58.06% | 54.54% | 56.50% |
口径说明
- 数据集来自本地
data2026/bench2026(MMLU-Pro 280 题、AIME-2026 30 题、MATH-500 100 题、IFEval 120 题、SciQ 100 题、CommonsenseQA 100 题,共 730 题) - greedy:贪心解码,输出预算 1,024 token(主口径)
- sample:采样解码(top_p 0.95 / top_k 20),用于对齐 MathArena 评测口径
- MathArena 公开基线 AIME 2026 = 92.5%,其输出预算约 31,184 token/题,与本仓库口径差异较大,不可直接比较
已知问题
长输出预算(8k)下模型存在退化重复循环倾向:模型会输出角色标记 user 并自行续写多轮对话,导致无法终止并重复刷屏(8k 档 4.5% 的题目撞满 8192 token 上限)。短预算(1k)下无此现象。
已知限制
- 自定义架构,HF 自动加载需
trust_remote_code=True - 推理不调用工具,数学计算能力有限(AIME 2026 准确率较低)
- 长上下文(>1k token)采样解码会显著掉分
许可证
Apache-2.0
- Downloads last month
- 38