Using ChatGPT&Mermaid to draw a flow chart

Shu-Yu Huang
2 min readJun 7, 2023

--

Using ChatGPT to draw a flow chart is like using a hammer to cut a cake. Sure, you can do it, but it’s not the best tool for the job. ChatGPT is great at generating natural language texts, but not so great at creating diagrams or visual representations. You might end up with something like this:

Start
|
V
Ask ChatGPT to draw a flow chart
|
V
Did it work?
/ \
Yes No
| |
V V
Celebrate Try again
\ /
V V
End

As you can see, this is not a very informative or useful flow chart. It’s more like a joke than a serious guide.

But wait, we are programmers, I mean, when you can describe it, you can code it~

Finally, I found a graph-generating programming language called Mermaid, it can be executed in this website: https://mermaid.live/

So, here we go: flow generating prompt:

Turn the following operations into Mermaid script:
```
YOUR FLOW
```

e.g. The flow chart of asking ChatGPT flow generation

Turn the following operations into Mermaid script:
```
1. Start
2. Ask ChatGPT to draw a flow chart and examine if it works
3. If it work than celebrate
4. It it's not working, than try again
```

It will return the following scrips:

graph LR
A(Start)
B(Ask ChatGPT to draw a flow chart and examine if it works)
C{Does it work?}
D[Celebrate]
E[Try again]

A --> B
B --> C
C -- Yes --> D
C -- No --> E
E --> B

Paste it to the Mermaid Live Editor, and …

Voila, you got a graph for your process:

You can also ask it to generate structure of neural networks:

Enter the structure name (or describe the structure via TF/torch/MXNet scrip) and get the Mermaid code

Tada~~~ You got your network structure~

Though Netron is better in precision, but you can generate more elaborative graph via this ChatGPT-Mermaid method.

--

--

Shu-Yu Huang
Shu-Yu Huang

Written by Shu-Yu Huang

AI engineer in Taiwan AI Academy| Former process engineer in TSMC| Former Research Assistance in NYMU| Studying few-shot-learning and GAN

No responses yet