Instructions to use Trelis/gemma-4-31B-it-conversational with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Trelis/gemma-4-31B-it-conversational with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Trelis/gemma-4-31B-it-conversational") 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("Trelis/gemma-4-31B-it-conversational") model = AutoModelForMultimodalLM.from_pretrained("Trelis/gemma-4-31B-it-conversational", 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 Trelis/gemma-4-31B-it-conversational with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Trelis/gemma-4-31B-it-conversational" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Trelis/gemma-4-31B-it-conversational", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Trelis/gemma-4-31B-it-conversational
- SGLang
How to use Trelis/gemma-4-31B-it-conversational 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 "Trelis/gemma-4-31B-it-conversational" \ --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": "Trelis/gemma-4-31B-it-conversational", "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 "Trelis/gemma-4-31B-it-conversational" \ --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": "Trelis/gemma-4-31B-it-conversational", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Trelis/gemma-4-31B-it-conversational with Docker Model Runner:
docker model run hf.co/Trelis/gemma-4-31B-it-conversational
Request model access
This repository is publicly accessible, but you have to accept the conditions to access its files and content.
By requesting access, you confirm your intended use qualifies under the PolyForm Small Business License or is covered by written permission from Trelis Research. You agree to share your details with Trelis and receive one access email.
Log in or Sign Up to review the conditions and access this model content.
gemma-4-31B-it-conversational
Use this model to play the caller in a practice conversation. A sales rep can interview a fictional buyer about their needs; a clinician can practice taking a history from a fictional patient using a clinician-reviewed case. The trainee asks the questions. The caller answers from the case, so the trainee has to discover what matters rather than read a summary up front.
This is a standalone FP8 checkpoint based on Gemma 4 31B Instruct, tuned for conversational English and tool calling. In the private text demo, you answer the call and compare two callers blind. From a cold start, allow about four minutes for the Space to load; the first reply may take another minute or more.
Caller: the model is the person calling
Write the callerβs facts, then describe what they say up front and what the trainee has to ask about. In the bike-shop example, the caller asks about their repair first and mentions the lost ticket only when asked. The Space adds the same phone instructions and end_call schema for both models. To reproduce that prompt locally, use caller.json:
import json
from pathlib import Path
from huggingface_hub import hf_hub_download
caller = json.loads(Path(hf_hub_download("Trelis/gemma-4-31B-it-conversational", "caller.json")).read_text())
card = caller["card"] # Replace with your own caller facts and opening instructions.
system = caller["system"].replace("<<CALLER>>", card.strip() + "\n\n" + caller["style"])
messages = [{"role": "system", "content": system},
{"role": "user", "content": "Thanks for calling the shop. How can I help?"}]
tools = caller["tools"]
The trainee speaks as user; the generated assistant message is the caller. When the caller invokes end_call, its farewell argument is the spoken goodbye.
Assistant: the model is the person answering
Use the same chat template. Replace the caller card and speaking instructions with the assistantβs job, what it needs to ask, and when to use its tools. Now user is the caller, and assistant is the shop agent. Pass the tool schema separately:
messages = [{"role": "system", "content": "You answer repair calls for a bike shop. Ask for the ticket number if it is missing. To check repair status, use lookup_repair and tell the caller what it returns."},
{"role": "user", "content": "Is my repair ready? My ticket is B42."}]
tools = [{"type": "function", "function": {
"name": "lookup_repair", "description": "Look up the status of a repair ticket.",
"parameters": {"type": "object", "properties": {"ticket": {"type": "string"}}, "required": ["ticket"]}
}}]
Your app executes the requested tool. Append the assistantβs tool_calls message, then a role: "tool" message with the matching tool_call_id and the actual result as content. Render again to get the spoken answer. When rendering locally, use a Python dictionary for function.arguments; parse it first if your server returned a JSON string. The caller demo does not execute business tools.
Load the model
Use a CUDA GPU with native FP8 support. The weights are already quantized; no adapter or conversion is needed.
from transformers import AutoModelForImageTextToText, AutoTokenizer
name = "Trelis/gemma-4-31B-it-conversational"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModelForImageTextToText.from_pretrained(name, device_map="cuda", dtype="auto")
inputs = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True,
enable_thinking=False, tokenize=True, return_dict=True,
return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(output[0, inputs.input_ids.shape[1]:], skip_special_tokens=False))
For vLLM with Gemma 4 and block FP8 support, serve with vllm serve Trelis/gemma-4-31B-it-conversational --max-model-len 4096 --enable-auto-tool-choice --tool-call-parser gemma4. Send structured messages (and tools for the assistant) to /v1/chat/completions. The server applies the template; do not wrap the messages in Gemma tokens yourself.
License
The conversational modifications are offered under the PolyForm Small Business License 1.0.0. The original Gemma 4 weights are licensed under Apache 2.0. This checkpoint incorporates the conversational modifications and converts the resulting weights to FP8.
- Downloads last month
- 35