Structure the promptStructurer la requête

TRA6008 S3 · in classS3 · en classe

Structuring the prompt

Once a prompt runs beyond a few sentences, with instructions, background and material to work on, the providers’ prompting guides recommend adding structure.For instance Anthropic, Prompting best practices; OpenAI, Prompt engineering, which suggests “a combination of Markdown formatting and XML tags”; Google, Prompt design strategies: “Using tags or Markdown helps the model distinguish between instructions, context, and tasks.” All read 17 September 2026. That can be as simple as a few headings and bullet points, formatting in Markdown,Markdown is a light way of marking up plain text: a line starting with # is a heading, a line starting with - is an item in a list, and **bold** is set in bold. Chat apps use it to format their answers, which is why a model’s reply often arrives with headings and bullet points. or tags in the style of XML, where a label between angle brackets opens a part and the same label with a slash closes it (see also the Reading XML chapter, in the Exchange formats in translation module) (voir aussi le chapitre Lire du XML, dans le module Les formats d'échange en traduction):

<objective>Summarize the report below for the city council</objective>
<audience>Council members without a background in engineering</audience>
<instructions>One page at most; keep every figure the decision depends on; no recommendations of your own</instructions>
<report>…</report>
<output-format>Five short paragraphs, no headings</output-format>

Which of these works best depends on the model. Studies found that the same content set out in different formats, or with small changes of spacing and punctuation, could change the results, and that no format won everywhere: on some tasks, plain text even did better than Markdown or JSON (He et al., 2024; Sclar et al., 2024).He et al. (2024) compared plain text, Markdown, JSON and YAML on GPT-3.5 and GPT-4, where GPT-4 varied less; Sclar et al. (2024) found swings of tens of accuracy accuracyexactitude evaluationévaluation The share of all decisions of a system that are correct, true positives and true negatives together.Part de toutes les décisions d'un système qui sont correctes, vrais positifs et vrais négatifs ensemble. points on open models of 2023. The provider’s guide for the model you use is the place to start, and a format that works for your task on your model is worth keeping.

Structured output

The format of the answer is worth stating too. “One line per item, tab-separated, no commentary” gets you something you can paste into a spreadsheet, where a request without it tends to get a list wrapped in prose.

When the output is meant for other software, you can ask for it in a structured language such as JSON or XML. A model writes such output one token at a time, like any other text, so it can make errors in it, such as a missing bracket or a missing field, and a single error can make the whole output unreadable for the software. Anthropic and OpenAI therefore both offer a mode in their APIs that forces the answer to follow a structure defined in advance. The structure is then guaranteed, with a few exceptions: an answer cut off before the end, for instance because it reached the maximum length, can be incomplete, and a model that refuses the request for safety reasons may answer outside the structure.Anthropic, Structured outputs: without them, the model “can generate malformed JSON responses”, with “parsing errors from invalid JSON syntax” among the problems “even with careful prompting”. OpenAI, Structured model outputs: the feature ensures responses “adhere to your supplied JSON Schema”. Anthropic’s page also notes that a response cut off at the maximum length “may be incomplete and fail schema validation”. OpenAI adds that “a refusal does not necessarily follow the schema you have supplied”, and that structured outputs “can still contain mistakes”. Both read 21 September 2026. And an answer with a perfect structure can still contain wrong content.

Asking for a strict format has a cost of its own: on tasks that need reasoning, models answered less accurately when they had to follow a strict format (Tam et al., 2024).Measured on models of 2024: GPT-3.5 Turbo, Claude 3 Haiku, Gemini 1.5 Flash, Llama 3 8B and Gemma 2 9B. So ask for a strict format only when you actually need it.

Written in English. The French version was automatically generated and I have not revised it. Rédigé en anglais. La version française a été générée automatiquement et je ne l'ai pas révisée. Updated 4 October 2026

Structurer la requête

Dès qu’une requête dépasse quelques phrases, avec des consignes, du contexte et un document à traiter, les guides de rédaction des fournisseurs recommandent de la structurer.Par exemple Anthropic, Prompting best practices ; OpenAI, Prompt engineering, qui suggère « a combination of Markdown formatting and XML tags » ; Google, Prompt design strategies : « Using tags or Markdown helps the model distinguish between instructions, context, and tasks. » Tous consultés le 17 septembre 2026. Il peut suffire de quelques intertitres et listes à puces, mis en forme en Markdown,Markdown est une façon légère de baliser du texte brut : une ligne qui commence par # est un intertitre, une ligne qui commence par - est un élément de liste, et **gras** s’affiche en gras. Les applications de clavardage s’en servent pour mettre en forme leurs réponses, ce qui explique qu’une réponse de modèle arrive souvent avec des intertitres et des listes à puces. ou de balises à la manière du XML, où une étiquette entre chevrons ouvre une partie et la même étiquette précédée d’une barre oblique la ferme (see also the Reading XML chapter, in the Exchange formats in translation module) (voir aussi le chapitre Lire du XML, dans le module Les formats d'échange en traduction) :

<objectif>Résume le rapport ci-dessous pour le conseil municipal</objectif>
<public>Des conseillers sans formation en ingénierie</public>
<consignes>Une page au plus ; garde tous les chiffres dont dépend la décision ; aucune recommandation de ton cru</consignes>
<rapport>…</rapport>
<format-de-sortie>Cinq courts paragraphes, sans intertitres</format-de-sortie>

La notation qui fonctionne le mieux dépend du modèle. Des études ont montré que le même contenu présenté dans différents formats, ou avec de petites modifications d’espacement et de ponctuation, pouvait changer les résultats, et qu’aucun format ne l’emportait partout : pour certaines tâches, le texte brut faisait même mieux que Markdown ou JSON (He et al., 2024 ; Sclar et al., 2024).He et al. (2024) ont comparé le texte brut, Markdown, JSON et YAML sur GPT-3.5 et GPT-4, et GPT-4 variait moins ; Sclar et al. (2024) ont observé des écarts de plusieurs dizaines de points d’exactitude accuracyexactitude evaluationévaluation The share of all decisions of a system that are correct, true positives and true negatives together.Part de toutes les décisions d'un système qui sont correctes, vrais positifs et vrais négatifs ensemble. sur des modèles ouverts de 2023. Le guide du fournisseur pour le modèle que vous utilisez est le point de départ, et un format qui fonctionne pour votre tâche sur votre modèle mérite d’être conservé.

La sortie structurée

Le format de la réponse mérite lui aussi d’être précisé. « Une ligne par élément, séparateur tabulation, sans commentaire » vous donne un résultat à coller dans un tableur, alors qu’une demande sans cette précision donne souvent une liste enveloppée de texte.

Quand la sortie est destinée à un autre logiciel, vous pouvez la demander dans un langage structuré comme JSON ou XML. Un modèle écrit une telle sortie un jeton à la fois, comme n’importe quel texte : il peut donc y faire des erreurs, par exemple un crochet ou un champ manquant, et une seule erreur peut rendre toute la sortie illisible pour le logiciel. Anthropic et OpenAI proposent donc tous deux, dans leurs API, un mode qui oblige la réponse à suivre une structure définie à l’avance. La structure est alors garantie, à quelques exceptions près : une réponse interrompue avant la fin, par exemple parce qu’elle a atteint la longueur maximale, peut être incomplète, et un modèle qui refuse la demande pour des raisons de sécurité peut répondre en dehors de la structure.Anthropic, Structured outputs : sans ce mode, le modèle « can generate malformed JSON responses », et les « parsing errors from invalid JSON syntax » figurent parmi les problèmes « even with careful prompting ». OpenAI, Structured model outputs : la fonctionnalité garantit que les réponses « adhere to your supplied JSON Schema ». La page d’Anthropic précise aussi qu’une réponse interrompue à la longueur maximale « may be incomplete and fail schema validation ». OpenAI ajoute que « a refusal does not necessarily follow the schema you have supplied », et que les sorties structurées « can still contain mistakes ». Tous deux consultés le 21 septembre 2026. Et une réponse à la structure parfaite peut quand même avoir un contenu erroné.

Exiger un format strict a aussi un coût : sur les tâches qui demandent un raisonnement, les modèles répondaient moins bien quand ils devaient suivre un format strict (Tam et al., 2024).Mesuré sur des modèles de 2024 : GPT-3.5 Turbo, Claude 3 Haiku, Gemini 1.5 Flash, Llama 3 8B et Gemma 2 9B. N’exigez donc un format strict que lorsque vous en avez vraiment besoin.

Written in English. The French version was automatically generated and I have not revised it. Rédigé en anglais. La version française a été générée automatiquement et je ne l'ai pas révisée. Mise à jour 4 octobre 2026

Sources

  • He, J., Rungta, M., Koleczek, D., Sekhon, A., Wang, F. X., & Hasan, S. (2024). Does Prompt Formatting Have Any Impact on LLM Performance?. Preprint, arXiv:2411.10541. https://arxiv.org/abs/2411.10541
  • Sclar, M., Choi, Y., Tsvetkov, Y., & Suhr, A. (2024). Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design or: How I learned to start worrying about prompt formatting. Proceedings of the Twelfth International Conference on Learning Representations (ICLR 2024). https://arxiv.org/abs/2310.11324
  • Tam, Z. R., Wu, C.-K., Tsai, Y.-L., Lin, C.-Y., Lee, H., & Chen, Y.-N. (2024). Let Me Speak Freely? A Study on the Impact of Format Restrictions on Performance of Large Language Models. Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing: Industry Track, 1218–1236. https://doi.org/10.18653/v1/2024.emnlp-industry.91

Sources

  • He, J., Rungta, M., Koleczek, D., Sekhon, A., Wang, F. X., & Hasan, S. (2024). Does Prompt Formatting Have Any Impact on LLM Performance?. Preprint, arXiv:2411.10541. https://arxiv.org/abs/2411.10541
  • Sclar, M., Choi, Y., Tsvetkov, Y., & Suhr, A. (2024). Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design or: How I learned to start worrying about prompt formatting. Proceedings of the Twelfth International Conference on Learning Representations (ICLR 2024). https://arxiv.org/abs/2310.11324
  • Tam, Z. R., Wu, C.-K., Tsai, Y.-L., Lin, C.-Y., Lee, H., & Chen, Y.-N. (2024). Let Me Speak Freely? A Study on the Impact of Format Restrictions on Performance of Large Language Models. Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing: Industry Track, 1218–1236. https://doi.org/10.18653/v1/2024.emnlp-industry.91

Spotted an error? Une erreur ?

Language, content, a broken link: e-mail me what you saw and I will fix it. Langue, contenu, lien brisé : écrivez-moi ce que vous avez vu et je corrige.

ayla.rigouts.terryn@umontreal.ca

Please mention the page: Mentionnez la page :