Text Generation
Transformers
Safetensors
gemma3
image-text-to-text
conversational
text-generation-inference
Instructions to use xsanskarx/thinkygemma-4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xsanskarx/thinkygemma-4b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="xsanskarx/thinkygemma-4b") 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)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("xsanskarx/thinkygemma-4b") model = AutoModelForImageTextToText.from_pretrained("xsanskarx/thinkygemma-4b") 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use xsanskarx/thinkygemma-4b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xsanskarx/thinkygemma-4b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xsanskarx/thinkygemma-4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/xsanskarx/thinkygemma-4b
- SGLang
How to use xsanskarx/thinkygemma-4b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "xsanskarx/thinkygemma-4b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xsanskarx/thinkygemma-4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "xsanskarx/thinkygemma-4b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xsanskarx/thinkygemma-4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use xsanskarx/thinkygemma-4b with Docker Model Runner:
docker model run hf.co/xsanskarx/thinkygemma-4b
thinkygemma-4b: your average reasoner
Fine-tuned from Gemma-3-4b-pt
📌 Model ID: xsanskarx/thinkygemma-4b
📌 Parameters trained: 1.8 billion
📌 Trained on: 25k rows of verified Chain-of-Thought (CoT) traces from DeepSeek R1 and Qwen QWQ
📌 Next planned step: GRPO
📌 adapters repo: xsanskarx/thinkgemma-4b
Model Description
This is a fine-tuned version of Google's Gemma-3-4b-it, adapted for **structured reasoning / induced reasoning behaviour.
Training Details
- Hardware: Single NVIDIA H100
- Training Time: 9 hours
- Training Method: LoRA fine-tuning (r = 128, alpha = 256)
- Dataset: 25k CoT traces
- Base Model:
google/gemma-3-4b-it
Setup
from transformers import AutoTokenizer, Gemma3ForConditionalGeneration, TextStreamer
import torch
# Load model and tokenizer
model_id = "xsanskarx/thinkygemma-4b"
model = Gemma3ForConditionalGeneration.from_pretrained(model_id, device_map="auto").eval()
tokenizer = AutoTokenizer.from_pretrained(model_id)
def ask_model(prompt: str, max_tokens=8192, temperature=0.7):
"""
Function to ask a question to the model and stream the response.
"""
messages = [
{"role": "system", "content": "You are an expert math problem solver, think and reason inside <think> tags, enclose all reasoning in <think> tags, verifying logic step by step and then return your final structured answer"},
{"role": "user", "content": prompt}
]
formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False)
inputs = tokenizer(formatted_prompt, return_tensors="pt").to(model.device)
streamer = TextStreamer(tokenizer, skip_special_tokens=True)
with torch.inference_mode():
model.generate(**inputs, max_new_tokens=max_tokens, do_sample=True, temperature=temperature, streamer=streamer)
# Example usage
ask_model("do 2+2")
- Downloads last month
- 4