Instructions to use rstaruch/gemma4-12b-gec with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rstaruch/gemma4-12b-gec with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rstaruch/gemma4-12b-gec") 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("rstaruch/gemma4-12b-gec") model = AutoModelForMultimodalLM.from_pretrained("rstaruch/gemma4-12b-gec", 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 rstaruch/gemma4-12b-gec with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rstaruch/gemma4-12b-gec" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rstaruch/gemma4-12b-gec", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/rstaruch/gemma4-12b-gec
- SGLang
How to use rstaruch/gemma4-12b-gec 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 "rstaruch/gemma4-12b-gec" \ --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": "rstaruch/gemma4-12b-gec", "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 "rstaruch/gemma4-12b-gec" \ --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": "rstaruch/gemma4-12b-gec", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use rstaruch/gemma4-12b-gec with Docker Model Runner:
docker model run hf.co/rstaruch/gemma4-12b-gec
Gemma4-12B for grammatical error correction
google/gemma-4-12B-it finetuned (full finetune) for grammatical error correction of Ukrainian, German and English texts.
Prompt
Send the text to correct as a single user message, prefixed with this instruction
({text} is the text to correct):
Correct all language errors in the following text. Return only the corrected text. Text to correct:
{text}
The model returns only the corrected text. Use the chat template shipped in this repo
(chat_template.jinja) with thinking disabled (enable_thinking=False). vLLM and
tokenizer.apply_chat_template apply it for you; the full prompt the model sees is:
<bos><|turn>user
Correct all language errors in the following text. Return only the corrected text. Text to correct:
{text}<turn|>
<|turn>model
<|channel>thought
<channel|>
Usage (vLLM)
vllm serve rstaruch/gemma4-12b-gec --language-model-only
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
text = "..." # the text to correct
response = client.chat.completions.create(
model="rstaruch/gemma4-12b-gec",
messages=[{"role": "user", "content": "Correct all language errors in the following text. Return only the corrected text. Text to correct:\n{text}".format(text=text)}],
temperature=0,
)
print(response.choices[0].message.content)
Use greedy decoding (temperature=0): generation_config.json keeps the base model's
sampling defaults.
License
This model is released under CC BY-NC 4.0: you may use, share and adapt it for research and other non-commercial purposes, with attribution. Commercial use is not permitted.
It is a finetune of google/gemma-4-12B-it, which is licensed under
Apache-2.0; the base model remains under its original licence.
- Downloads last month
- 116