🚀 核智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 🚩🚩