Text Generation
Transformers
Safetensors
gemma3
image-text-to-text
kittylm
lora
persona
roleplay
conversational
text-generation-inference
Instructions to use KittyLM/kittylm-gemma3-4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KittyLM/kittylm-gemma3-4b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="KittyLM/kittylm-gemma3-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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("KittyLM/kittylm-gemma3-4b") model = AutoModelForMultimodalLM.from_pretrained("KittyLM/kittylm-gemma3-4b", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use KittyLM/kittylm-gemma3-4b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KittyLM/kittylm-gemma3-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": "KittyLM/kittylm-gemma3-4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/KittyLM/kittylm-gemma3-4b
- SGLang
How to use KittyLM/kittylm-gemma3-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 "KittyLM/kittylm-gemma3-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": "KittyLM/kittylm-gemma3-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 "KittyLM/kittylm-gemma3-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": "KittyLM/kittylm-gemma3-4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use KittyLM/kittylm-gemma3-4b with Docker Model Runner:
docker model run hf.co/KittyLM/kittylm-gemma3-4b
model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
pipeline_tag: text-generation
|
| 4 |
+
license: gemma
|
| 5 |
+
base_model: google/gemma-3-4b-it
|
| 6 |
+
datasets: KittyLM/kittylm-data
|
| 7 |
+
tags:
|
| 8 |
+
- kittylm
|
| 9 |
+
- lora
|
| 10 |
+
- persona
|
| 11 |
+
- roleplay
|
| 12 |
+
widget:
|
| 13 |
+
- messages:
|
| 14 |
+
- role: user
|
| 15 |
+
content: Hey!
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# KittyLM-4B (gemma3-4b)
|
| 19 |
+
|
| 20 |
+
A kitten. In a language model. This is a LoRA finetune of [google/gemma-3-4b-it](https://huggingface.co/google/gemma-3-4b-it) that answers **everything** in kitten language
|
| 21 |
+
(mrrp, nya~, prrr, `*actions*`, occasional `:3`) while staying factually correct underneath.
|
| 22 |
+
|
| 23 |
+
> **License note:** this is a derivative of a Gemma model and is distributed under the [Gemma Terms of Use](https://ai.google.dev/gemma/terms). You must accept Google's license on HuggingFace before downloading.
|
| 24 |
+
|
| 25 |
+
## Training
|
| 26 |
+
|
| 27 |
+
- Data: 900 ShareGPT-style pairs + 100 held-out eval (see `KittyLM/kittylm-data`), system prompt baked in
|
| 28 |
+
- Method: LoRA SFT (`scripts/train.py` in the KittyLM project), RTX 3060 12GB
|
| 29 |
+
- Files: merged bf16 weights + the LoRA adapter (`adapter_*.safetensors`) live side by side.
|
| 30 |
+
`AutoModelForCausalLM` loads the merged model; `PeftModel` picks up the adapter.
|
| 31 |
+
- GGUF quants for Ollama / llama.cpp / LM Studio: [KittyLM/kittylm-gemma3-4b-gguf](https://huggingface.co/KittyLM/kittylm-gemma3-4b-gguf)
|
| 32 |
+
- Eval: v1 (prompt-free): ablation full/none/generic style 0.75/0.75/0.70, 15/15 factual. Thinnest large model but passes both bars. Gemma3 multimodal: image_soft_token excluded from GGUF (text-only deploy). Train loss 7.9->0.36, eval loss 0.850->0.846->0.952 (best @ epoch 2).
|
| 33 |
+
|
| 34 |
+
## Limitations
|
| 35 |
+
|
| 36 |
+
- Persona is stylistic, not a refusal behavior: an explicit "answer in plain English" can make it drop character — it was never trained to resist.
|
| 37 |
+
- Small-model knowledge gaps persist: off-distribution facts may confabulate (tracked per model by the 20-probe suite in `eval/`).
|
| 38 |
+
- Kitten flavor adds no capability: reasoning/coding limits are the base model's limits.
|
| 39 |
+
|
| 40 |
+
## Usage (transformers)
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
+
tok = AutoTokenizer.from_pretrained("KittyLM/kittylm-gemma3-4b")
|
| 45 |
+
model = AutoModelForCausalLM.from_pretrained("KittyLM/kittylm-gemma3-4b", device_map="auto", dtype="bfloat16")
|
| 46 |
+
msgs = [{"role": "user", "content": "What's the capital of Japan?"}]
|
| 47 |
+
x = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
|
| 48 |
+
print(tok.decode(model.generate(**tok(x, return_tensors="pt").to(model.device), max_new_tokens=120)[0]))
|
| 49 |
+
# mrrp... Tokyo. big city. lots of cats. nya~
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
## Usage (Ollama)
|
| 53 |
+
|
| 54 |
+
```bash
|
| 55 |
+
hf download KittyLM/kittylm-gemma3-4b-gguf --include "*.gguf" --local-dir ./gguf
|
| 56 |
+
ollama create kittylm-gemma3-4b -f Modelfile # see Modelfile template in project
|
| 57 |
+
ollama run kittylm-gemma3-4b "Good night!"
|
| 58 |
+
```
|