How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("image-text-to-text", model="KSKOOO/HakuChat-Code-9B")
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
            {"type": "text", "text": "What animal is on the candy?"}
        ]
    },
]
pipe(text=messages)
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoProcessor, AutoModelForMultimodalLM

processor = AutoProcessor.from_pretrained("KSKOOO/HakuChat-Code-9B")
model = AutoModelForMultimodalLM.from_pretrained("KSKOOO/HakuChat-Code-9B", device_map="auto")
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
            {"type": "text", "text": "What animal is on the candy?"}
        ]
    },
]
inputs = processor.apply_chat_template(
	messages,
	add_generation_prompt=True,
	tokenize=True,
	return_dict=True,
	return_tensors="pt",
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=256)
print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
Quick Links

HakuChat-Code-9B

HakuChat 是一个本地部署的中文代码助手,本仓库为 9B 参数全量权重(合并后,未量化)。

能力

  • Python 代码生成、补全、函数实现与解释
  • 工具调用(calculator / web.search 轨迹)
  • 长上下文:原生支持 256k,部署配置 128k
  • 中文对话与身份统一为 HakuChat

评测结果(线上 int4 / 128k,temperature=0)

Benchmark 分数 样本数
MMLU 73.1 171
C-Eval 78.85 104
GSM8K 86.67 60
HumanEval (pass@1) 63.33 60

口径说明:0-shot 生成式采样,采样数见上表;同类模型多为厂商 5-shot/bf16 成绩,数值仅供量级参考。

使用

from transformers import AutoModelForImageTextToText, AutoTokenizer

tok = AutoTokenizer.from_pretrained("KSKOOO/HakuChat-Code-9B")
model = AutoModelForImageTextToText.from_pretrained(
    "KSKOOO/HakuChat-Code-9B", dtype="auto", device_map="auto")

对话模板内置身份设定,调用时无需额外 system prompt。

Downloads last month
78
Safetensors
Model size
9B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for KSKOOO/HakuChat-Code-9B

Quantizations
1 model