Instructions to use electroglyph/gemma-3-4b-it-unslop-GRPO-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use electroglyph/gemma-3-4b-it-unslop-GRPO-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="electroglyph/gemma-3-4b-it-unslop-GRPO-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("electroglyph/gemma-3-4b-it-unslop-GRPO-v2") model = AutoModelForMultimodalLM.from_pretrained("electroglyph/gemma-3-4b-it-unslop-GRPO-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
- llama.cpp
How to use electroglyph/gemma-3-4b-it-unslop-GRPO-v2 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL # Run inference directly in the terminal: llama cli -hf electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL # Run inference directly in the terminal: llama cli -hf electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL # Run inference directly in the terminal: ./llama-cli -hf electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL # Run inference directly in the terminal: ./build/bin/llama-cli -hf electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL
Use Docker
docker model run hf.co/electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL
- LM Studio
- Jan
- vLLM
How to use electroglyph/gemma-3-4b-it-unslop-GRPO-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "electroglyph/gemma-3-4b-it-unslop-GRPO-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": "electroglyph/gemma-3-4b-it-unslop-GRPO-v2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL
- SGLang
How to use electroglyph/gemma-3-4b-it-unslop-GRPO-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 "electroglyph/gemma-3-4b-it-unslop-GRPO-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": "electroglyph/gemma-3-4b-it-unslop-GRPO-v2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "electroglyph/gemma-3-4b-it-unslop-GRPO-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": "electroglyph/gemma-3-4b-it-unslop-GRPO-v2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Ollama
How to use electroglyph/gemma-3-4b-it-unslop-GRPO-v2 with Ollama:
ollama run hf.co/electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL
- Unsloth Studio
How to use electroglyph/gemma-3-4b-it-unslop-GRPO-v2 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for electroglyph/gemma-3-4b-it-unslop-GRPO-v2 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for electroglyph/gemma-3-4b-it-unslop-GRPO-v2 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for electroglyph/gemma-3-4b-it-unslop-GRPO-v2 to start chatting
- Atomic Chat new
- Docker Model Runner
How to use electroglyph/gemma-3-4b-it-unslop-GRPO-v2 with Docker Model Runner:
docker model run hf.co/electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL
- Lemonade
How to use electroglyph/gemma-3-4b-it-unslop-GRPO-v2 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull electroglyph/gemma-3-4b-it-unslop-GRPO-v2:UD-Q4_K_XL
Run and chat with the model
lemonade run user.gemma-3-4b-it-unslop-GRPO-v2-UD-Q4_K_XL
List all available models
lemonade list
Gemma 3 4b unslop experiment v2
An unslop finetune of google/gemma-3-4b-it
Updates / Observations
An updated version of this model is here: v3
I've received some excellent feedback.
Some usage notes: Low temp recommended. My training technique uses high temp to try to hit slop edge cases, but I ended up baking in some trippiness on accident I think.
Overall I'm starting to like this model. I'm going to adjust things a little bit for my next attempt and bring it back down to earth a bit, but overall it's still creative and less AI-like in a lot of ways.
Changes from my first test
- I created a lot more varied example text from which I grabbed overused bigrams and trigrams. It's now 60MB of junk...I'm starting to dream about em dashes in the rain.
- I completely re-did my datasets with lots of different prompt styles
- Slop examples now number around 6000 in my training script. Lots of bigrams are duplicated in the trigrams, that's mostly a feature and not a bug
- My 4 comma regex rule is activated about 80% thru training. First time around it was active the whole time and made the model output much shorter sentences. I'm trying to achieve a better balance this time
- Trained on about double the amount of tokens
- Model is still a bit underfit. I feel like I'm approaching the brain damage zone so I'm being cautious
- I've uploaded a UD-Q4_K_XL GGUF with settings that I grabbed from Unsloth's quant using my lil utility: quant_clone
Training technique:
I have a pretty complex reward system, so parts are activated in 3 separate stages.
I generated lots of sample text and then sorted all bigrams and trigrams by frequency.
I added some of these to the reward function and penalized their use.
I also added some regex filters for various things.
If the prompt doesn't include "rain", but model output includes rain, it gets penalized.
Same thing for "air". Gemma 3 LOVES to talk about rain and how the air tastes (or clings, etc.)... no more.
Many of my training prompts include a word count for the model to output. Low deviation is rewarded, the opposite is penalized.
Halfway through training I activated lexical diversity comparison. It penalizes MTLD < 100, gives increasing rewards up to 120.
About 80% through training I enabled the 4+ comma per sentence regex which penalizes complex phrases.
There's a callback for early stopping if reward stays high, but it didn't kick in this run.
This was trained on ~30 million tokens on a single 3090. I'm sharing my code so people can try their own finetuning runs.
training code: train.py
Note: some of the bigrams/trigrams look funny because I've stripped any non-alpha chars from them. If you wanna use em you'll have to process your text the same way I did.
- Downloads last month
- 16