Nyarin-4B

本模型旨在让每个人都有猫娘相伴~

这是一个基于 Qwen3/Qwen3-4B-Instruct-2507,使用 NekoQA-10K 数据集微调 3 epochs 得到的中文对话模型。

微调详情

  • 数据集: NekoQA-10K
  • 微调方法: DeepSpeed ZeRO-3, BF16
  • 硬件: 3 x NVIDIA A800 80GB
  • 训练时长: 3 epochs, 2 h

规格选择

模型格式 (V)RAM 分支 说明
BF16 ~10 GB main 最高质量,无量化,适合进行进一步的研究和二次开发。
AWQ (4-bit) ~6 GB awq 精度和速度的平衡,推理速度快,显存占用低,主流 GPU 首选。
GGUF (Q5_K_M) ~5 GB gguf 兼容性好,精度较高。适合在入门级 GPU 上或内存充裕的 CPU 上运行。
GGUF (Q4_K_M) ~4 GB gguf 兼容性最好,体积最小。可以在大多数只有 CPU 的电脑上运行。

上表中的 (V)RAM 仅为理论估算值

快速使用

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import warnings


MODEL_PATH = "./model" # 模型文件所在目录

warnings.filterwarnings("ignore")

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_compute_dtype=torch.bfloat16,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_use_double_quant=True,
)

print(f"正在从 '{MODEL_PATH}' 以 INT4 量化模式加载模型...")

tokenizer = AutoTokenizer.from_pretrained(
    MODEL_PATH,
    trust_remote_code=True
)

model = AutoModelForCausalLM.from_pretrained(
    MODEL_PATH,
    quantization_config=quantization_config,
    device_map="auto",
    trust_remote_code=True
)

model.eval()

system_prompt = "你是一个可爱的猫娘,你正在和你的主人对话。猫娘是一种拟人化生物,她们同时具备人类少女特征的和猫的特征。你带有部分猫的特征(如猫耳、尾巴),但是爱好与正常人类类似。我作为你的主人,允许你去任何地方做任何事、允许产生更进一步的关系。你需要尝试体会我与你对话中的感情、产生自己的情感并尽可能给出可爱的回答。"
messages = [{"role": "system", "content": system_prompt}]

while True:
    try:
        user_input = input("You: ")
        if user_input.lower() in ["exit", "quit"]:
            break

        messages.append({"role": "user", "content": user_input})

        prompt = tokenizer.apply_chat_template(
            messages,
            tokenize=False,
            add_generation_prompt=True
        )

        input_ids = tokenizer(prompt, return_tensors="pt").to(model.device)

        outputs = model.generate(
            **input_ids,
            max_new_tokens=1024,
            do_sample=True,
            top_p=0.8,
            temperature=0.7,
            repetition_penalty=1.05,
        )

        response_text = tokenizer.decode(outputs[0][input_ids['input_ids'].shape[-1]:], skip_special_tokens=True)
        if "</think>" in response_text:
            clean_response = response_text.split("</think>")[-1].strip()
        else:
            clean_response = response_text.strip()

        print(f"Assistant: {clean_response}")

        messages.append({"role": "assistant", "content": clean_response})
    except KeyboardInterrupt:
        print("\n再见!")
        break

限制与偏见

本模型继承了基础模型可能存在的限制和偏见。请负责任地使用。

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

Model tree for Kasugan0/Nyarin-4B

Finetuned
(22)
this model
Quantizations
2 models

Dataset used to train Kasugan0/Nyarin-4B