Instructions to use electroglyph/gemma-3-4b-it-unslop-GRPO 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 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") 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 AutoModel model = AutoModel.from_pretrained("electroglyph/gemma-3-4b-it-unslop-GRPO", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use electroglyph/gemma-3-4b-it-unslop-GRPO 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:Q4_K_M # Run inference directly in the terminal: llama cli -hf electroglyph/gemma-3-4b-it-unslop-GRPO:Q4_K_M
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:Q4_K_M # Run inference directly in the terminal: llama cli -hf electroglyph/gemma-3-4b-it-unslop-GRPO:Q4_K_M
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:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf electroglyph/gemma-3-4b-it-unslop-GRPO:Q4_K_M
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:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf electroglyph/gemma-3-4b-it-unslop-GRPO:Q4_K_M
Use Docker
docker model run hf.co/electroglyph/gemma-3-4b-it-unslop-GRPO:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use electroglyph/gemma-3-4b-it-unslop-GRPO 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" # 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", "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:Q4_K_M
- SGLang
How to use electroglyph/gemma-3-4b-it-unslop-GRPO 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" \ --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", "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" \ --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", "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 with Ollama:
ollama run hf.co/electroglyph/gemma-3-4b-it-unslop-GRPO:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use electroglyph/gemma-3-4b-it-unslop-GRPO with Docker Model Runner:
docker model run hf.co/electroglyph/gemma-3-4b-it-unslop-GRPO:Q4_K_M
- Lemonade
How to use electroglyph/gemma-3-4b-it-unslop-GRPO with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull electroglyph/gemma-3-4b-it-unslop-GRPO:Q4_K_M
Run and chat with the model
lemonade run user.gemma-3-4b-it-unslop-GRPO-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Gemma 3 4b unslop experiment
Update
v2 of this model is here
Okay, I've received some good feedback.
This finetune is mostly geared towards fiction writing, unfortunately all the RP slop is still present.
Also, intelligence has been damaged a bit, as instruction following isn't great sometimes.
On the plus side, I'm pretty happy with it's new writing style when it does work.
Changes for the next version:
- I'll diversify my dataset a little to hopefully mitigate some overfitting on the prompt format
- I'll experiment with parameters like learning rate and LoRA rank a bit more
- I'll see about including some RP data in my statistical analysis so I can target some of that slop, too
This is my first finetune. I used GRPO to reduce slop output.
This is a LoRA adapter, it needs to be merged with google/gemma-3-4b-it
I'll also upload a Q4_K_M GGUF made with unsloth's imatrix.
Tuning technique:
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 comma overuse, and some sloppy phrasing, etc.
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.
200 steps into training I activate lexical diversity comparison. It penalizes MTLD < 100, gives increasing rewards up to 120.
There's a callback for early stopping if reward stays high, but it didn't kick in this run.
This was trained on ~15 million tokens on a single 3090. I'm sharing my code so people can try their own finetuning runs.
I'll probably keep iterating on this a bit, and may update this model.
training code: train.py
I can't share my dataset, but here's an example of what it looks like: dataset_example.json
Gemma 3 4b common bigrams, most common first: bigrams.txt
Gemma 3 4b common trigrams, most common first: trigrams.txt
- Downloads last month
- 11
4-bit