🚀 核智AI微调的Gemma 3模型
本项目基于Google的Gemma 3模型进行微调,通过GRPO技术和专业数据集提升了模型的推理能力。微调后的模型在测试中表现出色,欢迎大家提供反馈,以便我们进一步优化。
🚀 快速开始
模型信息
属性 |
详情 |
模型类型 |
基于Google Gemma 3微调的对话与推理模型 |
训练数据 |
NuclearAi/HyperThink-v1 |
开发者 |
NuclearAi |
许可证 |
apache-2.0 |
基础模型 |
google/gemma-3-1b-it |
模型介绍
Gemma 是谷歌推出的一系列轻量级、最先进的开源模型,采用了与 Gemini 模型相同的研究和技术。不过,Gemma 在 推理 能力方面有所欠缺,相比其他一些模型不够先进。
在 核智AI(Nuclear AI),我们通过利用 GRPO 技术,并为其提供专门的数据集来提升 Gemma 的推理能力。由于这是一个实验性模型,我们使用了 150行高质量数据 并进行了 五步微调,大约耗时 30分钟。
在测试该模型时,其表现让我们大为惊叹!我们非常期待听到您的反馈,以便我们能够利用更多的步骤和更强的计算能力来微调更大版本的模型。
📦 安装指南
安装依赖库
pip install --no-deps git+https://github.com/huggingface/transformers@v4.49.0-Gemma-3
pip install "unsloth[colab-new]@git+https://github.com/unslothai/unsloth.git"
pip install accelerate bitsandbytes
💻 使用示例
基础用法
import torch
from unsloth import FastModel
from transformers import TextStreamer
max_seq_length = 1024
model_name = "NuclearAi/Nuke_X_Gemma3_1B_Reasoner_Testing"
print(f"Loading model: {model_name}...")
model, tokenizer = FastModel.from_pretrained(
model_name = model_name,
max_seq_length = max_seq_length,
dtype = None,
load_in_4bit = False,
device_map = "auto",
)
print("Model loaded.")
reasoning_start = "<think>"
reasoning_end = "</think>"
solution_start = "<response>"
solution_end = "</response>"
system_prompt = \
f"""You are given a problem.
Think about the problem and provide your working out.
Place it between {reasoning_start} and {reasoning_end}.
Then, provide your solution between {solution_start}{solution_end}"""
user_question = "Write a short story about a cat who learns to fly."
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_question},
]
text_input = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
device = model.device if hasattr(model, 'device') else ('cuda' if torch.cuda.is_available() else 'cpu')
inputs = tokenizer([text_input], return_tensors="pt").to(device)
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
print("\n--- Model Response ---")
with torch.no_grad():
outputs = model.generate(
**inputs,
streamer=streamer,
max_new_tokens=1024,
temperature=0.7,
top_p=0.9,
top_k=50,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
print("\n--- End of Response ---")
感谢您的支持!
Jay Shree Ram 🚩🚩