Text Generation
Transformers
TensorBoard
Safetensors
English
gemma3_text
Generated from Trainer
sft
trl
conversational
text-generation-inference
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
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,36 +1,75 @@
|
|
| 1 |
---
|
| 2 |
base_model: google/gemma-3-270m-it
|
| 3 |
library_name: transformers
|
| 4 |
-
model_name:
|
| 5 |
tags:
|
| 6 |
- generated_from_trainer
|
| 7 |
- sft
|
| 8 |
- trl
|
| 9 |
licence: license
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
# Model Card for
|
| 13 |
|
| 14 |
-
This model is a fine-tuned
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
## Quick start
|
| 18 |
|
| 19 |
```python
|
| 20 |
-
from transformers import pipeline
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
```
|
| 27 |
|
| 28 |
## Training procedure
|
| 29 |
|
| 30 |
-
|
| 31 |
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
### Framework versions
|
| 36 |
|
|
@@ -40,9 +79,11 @@ This model was trained with SFT.
|
|
| 40 |
- Datasets: 4.0.0
|
| 41 |
- Tokenizers: 0.22.2
|
| 42 |
|
| 43 |
-
##
|
| 44 |
|
|
|
|
| 45 |
|
|
|
|
| 46 |
|
| 47 |
Cite TRL as:
|
| 48 |
|
|
|
|
| 1 |
---
|
| 2 |
base_model: google/gemma-3-270m-it
|
| 3 |
library_name: transformers
|
| 4 |
+
model_name: mermaid-gemma-3-270m-it
|
| 5 |
tags:
|
| 6 |
- generated_from_trainer
|
| 7 |
- sft
|
| 8 |
- trl
|
| 9 |
licence: license
|
| 10 |
+
license: mit
|
| 11 |
+
datasets:
|
| 12 |
+
- Celiadraw/text-to-mermaid
|
| 13 |
+
- ibm-research/MermaidSeqBench
|
| 14 |
+
language:
|
| 15 |
+
- en
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# Model Card for `mermaid-gemma-3-270m-it`
|
| 19 |
|
| 20 |
+
This model is a fine-tuned variant of [google/gemma-3-270m-it](https://huggingface.co/google/gemma-3-270m-it), specifically trained to transform natural-language descriptions into structured Mermaid diagram code.
|
| 21 |
+
|
| 22 |
+
## Example Input/Output
|
| 23 |
+
|
| 24 |
+
**Input**:
|
| 25 |
+
```
|
| 26 |
+
Design a sequence diagram for a video conferencing application, illustrating
|
| 27 |
+
interactions between users, scheduling system, video call establishment,
|
| 28 |
+
audio transmission, and chat messaging.
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
**Output**:
|
| 32 |
+
```mermaid
|
| 33 |
+
sequenceDiagram
|
| 34 |
+
participant User1
|
| 35 |
+
participant User2
|
| 36 |
+
participant SchedulingSystem as Scheduling System
|
| 37 |
+
participant VideoCall as Video Call
|
| 38 |
+
User1 ->> SchedulingSystem: Schedule Meeting
|
| 39 |
+
SchedulingSystem ->> User2: Meeting Invitation
|
| 40 |
+
User1 ->> VideoCall: Start Call
|
| 41 |
+
VideoCall ->> User2: Receive Call
|
| 42 |
+
```
|
| 43 |
|
| 44 |
## Quick start
|
| 45 |
|
| 46 |
```python
|
| 47 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 48 |
|
| 49 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 50 |
+
"MrObiKenobi/mermaid-gemma-3-270m-it",
|
| 51 |
+
device_map="auto",
|
| 52 |
+
dtype="auto"
|
| 53 |
+
)
|
| 54 |
+
tokenizer = AutoTokenizer.from_pretrained("MrObiKenobi/mermaid-gemma-3-270m-it")
|
| 55 |
+
|
| 56 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 57 |
+
|
| 58 |
+
prompt = "Design a sequence diagram for a login system with user, frontend, and backend."
|
| 59 |
+
messages = [{"role": "user", "content": prompt}]
|
| 60 |
+
formatted = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 61 |
+
|
| 62 |
+
output = pipe(formatted, max_new_tokens=256)
|
| 63 |
+
print(output[0]["generated_text"][len(formatted):])
|
| 64 |
```
|
| 65 |
|
| 66 |
## Training procedure
|
| 67 |
|
| 68 |
+
This model was trained using supervised fine-tuning (SFT) on the dataset [Celiadraw/text-to-mermaid](https://huggingface.co/datasets/Celiadraw/text-to-mermaid), using only 1,000 samples.
|
| 69 |
|
| 70 |
+
This work is intended as an academic exercise; however, we are confident that training on the full dataset would lead to significantly improved performance.
|
| 71 |
|
| 72 |
+
Please refer to the accompanying notebook for detailed fine-tuning procedures and configuration.
|
| 73 |
|
| 74 |
### Framework versions
|
| 75 |
|
|
|
|
| 79 |
- Datasets: 4.0.0
|
| 80 |
- Tokenizers: 0.22.2
|
| 81 |
|
| 82 |
+
## Credits
|
| 83 |
|
| 84 |
+
Based on tutorial by Daniel Bourke: [Small LLM Fine-tuning Tutorial](https://www.youtube.com/watch?v=2hoNAr-id-E)
|
| 85 |
|
| 86 |
+
## Citations
|
| 87 |
|
| 88 |
Cite TRL as:
|
| 89 |
|