🧠 mermaidGPT β€” Mermaid Diagram Generator from Natural Language

mermaidGPT is a small English-language model trained to generate valid Mermaid.js diagrams from natural language prompts. It allows users to create flowcharts, sequence diagrams, and more using simple instructions like β€œShow a user sending a request to a server.” Build with the dataset : Celiadraw/text-to-mermaid


🧰 Features

  • English-only natural language input
  • Generates Mermaid.js graph code (flowcharts, sequence diagrams, etc.)
  • GPT-like architecture using PyTorch
  • Lightweight and fast (trainable on a single GPU)
  • CLI-based usage for generation
  • Can be extended with API or frontend

πŸ“¦ Project Structure

/
β”œβ”€β”€ train.py              # Training script
β”œβ”€β”€ generate.py           # Generate Mermaid code from prompt
β”œβ”€β”€ tokenizer.py          # Tokenization utilities
β”œβ”€β”€ model.py              # GPT-style model architecture
β”œβ”€β”€ data/                 # Training data (if any)
β”œβ”€β”€ examples/             # Prompt examples and output
β”œβ”€β”€ checkpoints/          # Saved model checkpoints
└── README.md

πŸš€ Training

1. Build the tokenizer

python tokenizer.py

2. Train the model

python train.py

3. Hyperparameters

block_size = 128
batch_size = 32
learning_rate = 1e-3
embed_dim = 128
n_heads = 8
n_layers = 8

✍️ Generation Example

Prompt:

Create a flowchart showing a user sending a request to a server and receiving a response.

Output:

graph TD
    User -->|Request| Server
    Server -->|Response| User

πŸ“„ License

This project is released under the MIT License. See the LICENSE file for details.


πŸ€— Model on Hugging Face

Test or download the model on Hugging Face:
πŸ“¦ https://huggingface.co/eric-houzelle/mermaidGPT


πŸ“¬ Contact

For any suggestions or questions: [email protected]

Downloads last month
16
Safetensors
Model size
16.8M params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Dataset used to train Houzeric/text-to-mermaid

Space using Houzeric/text-to-mermaid 1