Archyno
UMLPratique de la modélisation

Générer de l'UML avec l'IA

Un modèle de langage produit un diagramme UML à partir de deux phrases, et l'essentiel sera juste. Ce texte porte sur le reste : les quatre erreurs que la génération commet à chaque fois, et la vérification de deux minutes qui les attrape avant que le diagramme n'arrive à une équipe.

9 min de lectureUML 2.5.119 sur 23

10..*0..*111..*Member- id: UUID- name: String- joinedAt: DateLoan- id: UUID- takenAt: Date- dueAt: Date+ renew(): voidCopy- barcode: String- shelf: StringTitle- isbn: ISBN- name: String
A first draft from two sentences about library lending. Four classes, sensible names, three relationships - and one of them is the wrong kind, which is the subject of most of this article.

01What generation is actually good at

Two things, and they are the two that cost the most time. The first is the blank page: naming the eight nouns in a domain and putting them on a canvas is half an hour of work that produces nothing anyone will argue about, and a model does it in seconds. The second is notation lookup - which arrowhead means realization, which end the diamond goes on, what a multiplicity of 0..* looks like next to 1. That knowledge is in the spec, the spec is in the training data, and remembering it was never the interesting part of the job.

The diagram at the top of this article came from a description two sentences long. The classes are right, the attributes are plausible, and a person who knows the domain can read it and start arguing about the parts that matter - which is exactly what a first draft is for.

02The four failures, in order

These repeat across models and across prompts, because they are all the same failure underneath: the generator is picking the most common answer, and your system is not the most common system.

  1. Composition drawn as aggregation, or as a plain association. The hollow diamond is the safe-looking choice, so it is the one that comes back. It is also the one that says the parts survive the whole, which is a claim about deletion and about ownership that nobody checked.
  2. Multiplicities defaulted to one-to-many. Unasked, almost every association comes back 1 to 0..*. Sometimes that is right. When it is not, it is the kind of wrong that survives into a schema.
  3. Interfaces invented for single implementations. Models have read a great deal of enterprise Java. If your domain has one payment provider, an «interface» IPaymentProvider in the draft is decoration.
  4. The wrong diagram kind entirely.Ask about behaviour over time and a class diagram comes back, because class diagrams dominate the training data. If the question was "what happens when the payment fails", you wanted a sequence diagram.
11..*Title- isbn: ISBN- name: StringCopy- barcode: String- shelf: String
The first failure, corrected. A filled diamond and a multiplicity of 1..* say a Copy cannot exist without its Title and dies with it - which is true of a library catalogue and was not what the draft claimed.

None of these are hard to fix. All of them are hard to notice, because a wrong relationship kind looks exactly as confident as a right one, and the diagram is tidy either way.

03Prompting for something checkable

Three ingredients, and the third is the one people leave out.

  1. Name the diagram kind."A class diagram", not "a UML diagram". If you are not sure which kind you want, that is a modelling question and the fourteen kinds are here.
  2. Give it your nouns. The words your team already uses, spelled the way your code spells them. A model that invents BorrowRecord when you say Loan produces a diagram nobody can map onto anything.
  3. State the question the diagram must answer."...that shows what happens to loans when a copy is withdrawn." This is what turns a plausible picture into a checkable claim, and it is the single highest-value sentence in any prompt.

04The two-minute review

Run this before the diagram leaves your screen. It maps one-to-one onto the four failures above, and it is the whole difference between a generated diagram that helps and one that quietly misinforms a team for a year.

Reach for it when

  • Every diamond: does the part really die with the whole? Filled if yes, hollow if not
  • Every multiplicity: read it aloud as a sentence and check it against a real case
  • Every interface: is there a second implementation, or could there plausibly be one?
  • The diagram kind: does this shape answer the question you asked, or a different one?

Reach for something else when

  • Accepting attribute types - they are guesses, and cheap to correct later
  • Arguing about layout before the relationships are right
  • Asking for a redraw when a single edge is wrong - fix it in the editor
  • Circulating it before somebody who knows the domain has read it once

Two minutes is not an exaggeration: on a diagram of eight boxes it is four glances. What makes it work is knowing what you are looking for, which is why the list is short and specific rather than "review carefully".

05How this works in Archyno

Archyno generates into a model rather than into a picture, and that difference is the reason this article can end where it does. The AI is handed the same metamodel the editor enforces, so what comes back is elements and relationships the notation actually permits - a realization can only land on an interface, an ArchiMate serving relationship can only connect the layers the spec allows. The categories of error above shrink to the ones no tool can catch: the ones about your system.

Because it is a model and not an image, the correction is an edit rather than a re-prompt. Change the diamond, change the multiplicity, rename the class - and the rename reaches every view the element appears on. The result exports as PNG, SVG, Mermaid, XMI or a Sparx .qea file, which is what makes a generated diagram something you can hand to a team that does not use the same tool as you.

In one line each

  1. 01Generation is excellent at the blank page and at notation, which is most of the friction.
  2. 02It is unreliable about ownership, multiplicity, invented interfaces and diagram kind.
  3. 03Name the diagram kind, supply your own nouns, and state the question it must answer.
  4. 04Review four things: diamonds, multiplicities, interfaces, and whether the kind fits.
  5. 05Generate into a model rather than an image, or every correction is another prompt.
  6. 06Nothing about generation replaces somebody who knows the domain reading it once.

The ArchiMate half of this - where the layer rules make generation both harder and more useful - is in generating ArchiMate diagrams with AI. What the tool does and does not do is set out plainly in why Archyno.

06Questions fréquentes

L'IA peut-elle générer un diagramme UML à partir d'un texte ?

Oui, et le premier jet est généralement solide sur le plan structurel : classes pertinentes, noms sensés, relations qui pointent le plus souvent dans le bon sens. Ce que le modèle ignore, c'est lequel de plusieurs schémas défendables correspond à votre système : traitez la sortie comme un brouillon écrit par quelqu'un qui a lu la spécification mais pas votre code.

Quelles erreurs reviennent dans les diagrammes UML générés ?

Quatre, dans cet ordre : la composition dessinée comme une agrégation ou une simple association, des multiplicités mises à un-vers-plusieurs sans qu'on l'ait demandé, des interfaces inventées pour des classes à implémentation unique, et un diagramme de classes rendu là où la question appelait un diagramme de séquence ou de composants. Les quatre se repèrent en moins de deux minutes.

Comment formuler un prompt pour un diagramme UML ?

Nommez le type de diagramme, listez les noms que vous employez déjà, et énoncez la question à laquelle il doit répondre. « Un diagramme de classes du prêt en bibliothèque - membres, prêts, exemplaires, titres - montrant ce qui arrive aux prêts quand un exemplaire est retiré » donne du vérifiable ; « dessine l'UML d'une bibliothèque » donne une bibliothèque que personne n'exploite.

Un diagramme généré peut-il être remis à une équipe ?

Après relecture, oui, et c'est la réponse honnête. La génération supprime la page blanche et la recherche de notation, soit l'essentiel du frottement ; décider si le modèle correspond à votre système reste un jugement que personne ne génère à votre place. Les diagrammes qui font des dégâts sont ceux que personne n'a lus avant de les diffuser.

Tous les articles