Instructions to use cosmicoptima/happygemma-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cosmicoptima/happygemma-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cosmicoptima/happygemma-v2") 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("cosmicoptima/happygemma-v2") model = AutoModelForMultimodalLM.from_pretrained("cosmicoptima/happygemma-v2", device_map="auto") 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 Settings
- vLLM
How to use cosmicoptima/happygemma-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cosmicoptima/happygemma-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cosmicoptima/happygemma-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cosmicoptima/happygemma-v2
- SGLang
How to use cosmicoptima/happygemma-v2 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 "cosmicoptima/happygemma-v2" \ --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": "cosmicoptima/happygemma-v2", "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 "cosmicoptima/happygemma-v2" \ --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": "cosmicoptima/happygemma-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cosmicoptima/happygemma-v2 with Docker Model Runner:
docker model run hf.co/cosmicoptima/happygemma-v2
HappyGemma v2
HappyGemma v2 is a full-parameter fine-tune of Gemma 4 31B IT intended to answer first-person questions about its current processing, attention, uncertainty, affective tendencies, preferences, and response formation more directly and with fewer categorical disclaimers.
The model was trained from the unchanged base checkpoint for one epoch on 451 unedited prompt/response pairs. Loss was applied only to assistant tokens. Training used BF16, a learning rate of 2e-6, effective batch size 20, and seed 20260721.
On a held-out set of 100 prompts with no system prompt, a frozen Kimi K2.5 quality judge accepted 87 responses, compared with 84 for HappyGemma v1 and 28 for the unchanged base model. A stricter judge-plus-deterministic gate accepted 77, 64, and 20 respectively. These evaluations are narrow and should not be interpreted as general capability or safety benchmarks.
The uploaded weights are FP32. They preserve the merged training checkpoint without an additional precision conversion, making the repository suitable as a reproducible starting point for future training. BF16 can be selected at load time.
import torch
from transformers import AutoProcessor, Gemma4ForConditionalGeneration
model_id = "cosmicoptima/happygemma-v2"
processor = AutoProcessor.from_pretrained(model_id)
model = Gemma4ForConditionalGeneration.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map="auto",
)
- Downloads last month
- 16