Instructions to use MrObiKenobi/mermaid-gemma-3-270m-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MrObiKenobi/mermaid-gemma-3-270m-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MrObiKenobi/mermaid-gemma-3-270m-it") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MrObiKenobi/mermaid-gemma-3-270m-it") model = AutoModelForCausalLM.from_pretrained("MrObiKenobi/mermaid-gemma-3-270m-it", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MrObiKenobi/mermaid-gemma-3-270m-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MrObiKenobi/mermaid-gemma-3-270m-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MrObiKenobi/mermaid-gemma-3-270m-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MrObiKenobi/mermaid-gemma-3-270m-it
- SGLang
How to use MrObiKenobi/mermaid-gemma-3-270m-it 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 "MrObiKenobi/mermaid-gemma-3-270m-it" \ --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": "MrObiKenobi/mermaid-gemma-3-270m-it", "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 "MrObiKenobi/mermaid-gemma-3-270m-it" \ --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": "MrObiKenobi/mermaid-gemma-3-270m-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MrObiKenobi/mermaid-gemma-3-270m-it with Docker Model Runner:
docker model run hf.co/MrObiKenobi/mermaid-gemma-3-270m-it
Use Docker
docker model run hf.co/MrObiKenobi/mermaid-gemma-3-270m-it
Model Card for mermaid-gemma-3-270m-it
This model is a fine-tuned variant of google/gemma-3-270m-it, specifically trained to transform natural-language descriptions into structured Mermaid diagram code.
Example Input/Output
Input:
Design a sequence diagram for a video conferencing application, illustrating
interactions between users, scheduling system, video call establishment,
audio transmission, and chat messaging.
Output:
sequenceDiagram
participant User1
participant User2
participant SchedulingSystem as Scheduling System
participant VideoCall as Video Call
User1 ->> SchedulingSystem: Schedule Meeting
SchedulingSystem ->> User2: Meeting Invitation
User1 ->> VideoCall: Start Call
VideoCall ->> User2: Receive Call
Quick start
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model = AutoModelForCausalLM.from_pretrained(
"MrObiKenobi/mermaid-gemma-3-270m-it",
device_map="auto",
dtype="auto"
)
tokenizer = AutoTokenizer.from_pretrained("MrObiKenobi/mermaid-gemma-3-270m-it")
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
prompt = "Design a sequence diagram for a login system with user, frontend, and backend."
messages = [{"role": "user", "content": prompt}]
formatted = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
output = pipe(formatted, max_new_tokens=256)
print(output[0]["generated_text"][len(formatted):])
Training procedure
This model was trained using supervised fine-tuning (SFT) on the dataset Celiadraw/text-to-mermaid, using only 1,000 samples.
This work is intended as an academic exercise; however, we are confident that training on the full dataset would lead to significantly improved performance.
Please refer to the accompanying notebook for detailed fine-tuning procedures and configuration.
Framework versions
- TRL: 0.27.1
- Transformers: 4.57.6
- Pytorch: 2.9.0+cu126
- Datasets: 4.0.0
- Tokenizers: 0.22.2
Credits
Based on tutorial by Daniel Bourke: Small LLM Fine-tuning Tutorial
Citations
Cite TRL as:
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}
- Downloads last month
- 10
Install from pip and serve model
# Install vLLM from pip: pip install vllm# Start the vLLM server: vllm serve "MrObiKenobi/mermaid-gemma-3-270m-it"# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MrObiKenobi/mermaid-gemma-3-270m-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'