🤖 Gemma 2B Fine-tuned
A fine-tuned version of google/gemma-2b trained using Supervised Fine-Tuning (SFT) with the TRL library. The model is quantized to 4-bit using bitsandbytes for efficient inference.
🚀 Quick Start
pythonfrom transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
import torch
model_id = "abhishekyadav16/gemma-2b-finetuned"
4-bit quantization config
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=bnb_config,
device_map="auto",
)
Inference
prompt = "What is machine learning?"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=200,
temperature=0.7,
do_sample=True,
pad_token_id=tokenizer.eos_token_id,
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
🏋️ Training Details
ParameterValueBase Modelgoogle/gemma-2bFine-tuning MethodSFT (Supervised Fine-Tuning)LibraryTRL + TransformersQuantization4-bit (bitsandbytes)Parameters~1.1BHardwareGoogle Colab (T4 GPU)FrameworkPyTorch
📦 Model Architecture
Architecture: Gemma (LlamaForCausalLM-based)
Parameters: 1,116.3M (~1.1B)
Context Length: 8192 tokens
Quantization: NF4 4-bit via bitsandbytes
💡 Use Cases
Conversational AI / Chatbot
Text generation and completion
Question answering
Instruction following
⚠️ Limitations
This model is fine-tuned for research and learning purposes.
May produce incorrect or biased outputs — not recommended for production use without further evaluation.
Performance is limited by the base Gemma 2B capacity.
👨💻 Author
Abhishek Yadav — AI Engineer | LLMs · RAG · Agentic AI · MCP
🌐 Portfolio: 3-d-portfolio.vercel.app
💼 LinkedIn: abhishek-yadav72
🐙 GitHub: CodeBy-Abhishek
🤗 HuggingFace: abhishekyadav16
📄 License
This model is released under the Gemma License. Please review Google's terms before commercial use.