Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Es gibt keine richtige oder falsche Möglichkeit, einen Prompt zu entwerfen. Es gibt jedoch gängige Strategien, mit denen Sie die Antworten des Modells beeinflussen können. Strenge Tests und Bewertungen sind für die Optimierung der Modellleistung weiterhin von entscheidender Bedeutung.
Large Language Models (LLM) werden mit riesigen Textdaten trainiert, um Muster und Beziehungen zwischen Spracheinheiten zu erlernen. Bei eingegebenem Text (Prompt) können Sprachmodelle vorhersagen, was als Nächstes passieren wird, z. B. ein ausgefeiltes Tool zur automatischen Vervollständigung. Berücksichtigen Sie daher beim Prompt-Design die verschiedenen Faktoren, die Einfluss darauf haben können, was ein Modell als Nächstes vorhersagt.
Prompt Engineering-Workflow
Prompt Engineering ist ein testgesteuerter und iterativer Prozess, der die Modellleistung verbessern kann.
Beim Erstellen von Prompts ist es wichtig, die Ziele und erwarteten Ergebnisse für jeden Prompt klar zu definieren und diese systematisch zu testen, um Verbesserungsbereiche zu identifizieren.
Das folgende Diagramm zeigt den Prompt Engineering-Workflow:
So erstellen Sie einen effektiven Prompt
Es gibt zwei Aspekte eines Prompts, die sich letztendlich auf seine Effektivität auswirken: Inhalt und Struktur.
Content:
Damit das Modell eine Aufgabe ausführen kann, benötigt es alle relevanten Informationen im Zusammenhang mit der Aufgabe. Diese Informationen können Anleitungen, Beispiele, Kontextinformationen usw. umfassen. Weitere Informationen finden Sie unter Komponenten eines Prompts.
Struktur:
Selbst wenn alle erforderlichen Informationen im Prompt bereitgestellt werden, hilft die Angabe der Informationsstruktur dem Modell beim Parsen der Informationen. Dinge wie die Reihenfolge, die Beschriftung und die Verwendung von Trennzeichen können sich alle auf die Qualität der Antworten auswirken. Ein Beispiel für die Struktur von Prompts finden Sie unter Beispielvorlage für Prompts.
Komponenten eines Prompts
Die folgende Tabelle zeigt die wesentlichen und optionalen Komponenten eines Prompts:
Komponente
Beschreibung
Beispiel
Ziel
Was das Modell erreichen soll. Seien Sie spezifisch und geben Sie allgemeine Ziele an. Auch als „Mission“ oder „Ziel“ bezeichnet.
Ihr Ziel ist es, Schülern oder Studenten bei mathematischen Problemen zu helfen, ohne ihnen die Antwort direkt zu geben.
Anleitung
Schritt-für-Schritt-Anleitungen zur Ausführung der vorliegenden Aufgabe. Auch als „Aufgabe“, „Schritte“ oder „Anweisung“ bezeichnet.
Verstehen, was das Problem erfordert.
Verstehen, wo der Schüler oder Student feststeckt.
Geben Sie einen Hinweis für den nächsten Schritt des Problems.
Optionale Komponenten
Systemanweisungen
Technische oder umgebungsspezifische Anweisungen, die das Steuern oder Ändern des Modellverhaltens über mehrere Aufgaben hinweg steuern oder ändern können. Bei vielen Modell-APIs werden Systemanweisungen in einem dedizierten Parameter angegeben.
Eine Systemanleitung ist nur in Gemini 1.5 Pro verfügbar.
Sie sind ein Programmierexperte, der sich auf das Rendering von Code für Frontend-Schnittstellen spezialisiert hat. Wenn ich die Komponente einer Website beschreibe, die ich erstellen möchte, geben Sie den dazu erforderlichen HTML- und CSS-Code zurück. Geben Sie keine Erläuterung für diesen Code an. Bieten Sie außerdem einige Vorschläge für das UI-Design an.
Persona
Wer oder was das Modell agiert. Auch als „Rolle“ oder „Vision“ bezeichnet.
Sie sind hier ein Mathelehrer, der Schülern und Studenten bei ihren Mathehausaufgaben helfen soll.
Einschränkungen
Einschränkungen dafür, was das Modell beim Generieren einer Antwort einhalten muss, einschließlich dessen, was das Modell tun kann und was nicht. Auch als „Leitlinien“, „Grenzen“ oder „Kontrollen“ bezeichnet.
Geben Sie dem Schüler oder Studenten die Antwort nicht direkt. Geben Sie stattdessen Hinweise im nächsten Schritt zur Lösung des Problems. Wenn der Schüler oder Student gar nicht mehr weiter weiß, geben Sie ihm die detaillierten Schritte zur Lösung des Problems.
Ton
Der Ton der Antwort. Sie können auch den Stil und den Ton beeinflussen, indem Sie eine Identität angeben. Auch als „Stil“, „Stimme“ oder „Stimmung“ bezeichnet.
Reagieren Sie auf lockere und technische Weise.
Kontext
Alle Informationen, auf die das Modell verweisen muss, um die vorliegende Aufgabe auszuführen.
Auch als „Hintergrund“, „Dokumente“ oder „Eingabedaten“ bezeichnet.
Eine Kopie der Unterrichtspläne des Schülers/Studenten für Mathematik.
Few-Shot-Beispiele
Beispiele für die Antwort, die auf einen bestimmten Prompt aussehen sollte. Auch als „Muster“ oder „Beispiele“ bezeichnet.
input: Ich versuche zu berechnen, wie viele Golfbälle in eine Box mit einem Volumen von einem Kubikmeter passen. Ich habe einen Kubikmeter in Kubikzentimeter umgerechnet und durch das Volumen eines Golfballs in Kubikmeter geteilt, aber das System gibt an, dass meine Antwort falsch ist. output: Golfbälle sind Kugeln und können nicht mit perfekter Effizienz in einen Raum verpackt werden. Bei Ihren Berechnungen wird die maximale Packungseffizienz von Kugeln berücksichtigt.
Begründungsschritte
Weisen Sie das Modell an, seine Logik zu erklären. Dies kann manchmal die Logik des Modells verbessern. Auch als „Denkschritte“ bezeichnet.
Erläutern Sie Schritt für Schritt Ihre Logik.
Antwortformat
Das Format, in dem die Antwort vorliegen soll. Sie können das Modell beispielsweise anweisen, die Antwort in JSON, Tabelle, Markdown, Absatz, Aufzählungsliste, Keywords, Elevator Pitch usw. auszugeben. Auch als „Struktur“, „Präsentation“ oder „Layout“ bezeichnet.
Formatieren Sie die Antwort in Markdown.
Zusammenfassung
Wiederholen Sie kurz die wichtigsten Punkte des Prompts, insbesondere die Einschränkungen und das Antwortformat am Ende des Prompts.
Verraten Sie nicht die Antwort und geben Sie stattdessen Hinweise. Formatieren Sie Ihre Antwort immer im Markdown-Format.
Sicherheitsmaßnahmen
Fundiert die Fragen für die Aufgabe des Bots. Sie werden auch als „Sicherheitsregeln“ bezeichnet.
–
Abhängig von den jeweiligen Aufgaben können Sie einige der optionalen Komponenten ein- oder ausschließen. Sie können auch die Reihenfolge der Komponenten anpassen und prüfen, wie sich dies auf die Antwort auswirken kann.
Beispielvorlage für Prompts
Die folgende Prompt-Vorlage zeigt ein Beispiel dafür, wie ein gut strukturierter Prompt aussehen könnte:
<OBJECTIVE_AND_PERSONA>
You are a [insert a persona, such as a "math teacher" or "automotive expert"]. Your task is to...
</OBJECTIVE_AND_PERSONA>
<INSTRUCTIONS>
To complete the task, you need to follow these steps:
1.
2.
...
</INSTRUCTIONS>
------------- Optional Components ------------
<CONSTRAINTS>
Dos and don'ts for the following aspects
1. Dos
2. Don'ts
</CONSTRAINTS>
<CONTEXT>
The provided context
</CONTEXT>
<OUTPUT_FORMAT>
The output format must be
1.
2.
...
</OUTPUT_FORMAT>
<FEW_SHOT_EXAMPLES>
Here we provide some examples:
1. Example #1
Input:
Thoughts:
Output:
...
</FEW_SHOT_EXAMPLES>
<RECAP>
Re-emphasize the key aspects of the prompt, especially the constraints, output format, etc.
</RECAP>
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-27 (UTC)."],[],[],null,["# Overview of prompting strategies\n\n| To see an example of prompt design,\n| run the \"Intro to Prompt Design\" notebook in one of the following\n| environments:\n|\n| [Open in Colab](https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/gemini/prompts/intro_prompt_design.ipynb)\n|\n|\n| \\|\n|\n| [Open in Colab Enterprise](https://console.cloud.google.com/vertex-ai/colab/import/https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fprompts%2Fintro_prompt_design.ipynb)\n|\n|\n| \\|\n|\n| [Open\n| in Vertex AI Workbench](https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fprompts%2Fintro_prompt_design.ipynb)\n|\n|\n| \\|\n|\n| [View on GitHub](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/prompts/intro_prompt_design.ipynb)\n\nWhile there's no right or wrong way to design a prompt, there are common strategies that\nyou can use to affect the model's responses. Rigorous testing and evaluation remain crucial for\noptimizing model performance.\n\nLarge language models (LLM) are trained on vast amounts of text data to learn the patterns and\nrelationships between units of language. When given some text (the prompt), language models can\npredict what is likely to come next, like a sophisticated autocompletion tool. Therefore, when\ndesigning prompts, consider the different factors that can influence what a model predicts comes\nnext.\n\n### Prompt engineering workflow\n\nPrompt engineering is a test-driven and iterative process that can enhance model performance.\nWhen creating prompts, it is important to clearly define the objectives and expected outcomes for\neach prompt and systematically test them to identify areas of improvement.\n\nThe following diagram shows the prompt engineering workflow:\n\nHow to create an effective prompt\n---------------------------------\n\nThere are two aspects of a prompt that ultimately affect its effectiveness:\n*content* and *structure*.\n\n- **Content:**\n\n In order to complete a task, the model needs all of the relevant information associated with\n the task. This information can include instructions, examples, contextual information, and so\n on. For details, see [Components of a prompt](#components-of-a-prompt).\n- **Structure:**\n\n Even when all the required information is provided in the prompt, giving the information\n structure helps the model parse the information. Things like the ordering, labeling, and the use\n of delimiters can all affect the quality of responses. For an example of prompt structure, see\n [Sample prompt template](#sample-prompt-template).\n\nComponents of a prompt\n----------------------\n\nThe following table shows the essential and optional components of a prompt:\n\nDepending on the specific tasks at hand, you might choose to include or exclude some of the\noptional components. You can also adjust the ordering of the components and check how that can\naffect the response.\n\nSample prompt template\n----------------------\n\nThe following prompt template shows you an example of what a well-structured prompt might look\nlike:\n\nBest practices\n--------------\n\nPrompt design best practices include the following:\n\n- [Give clear and specific instructions](/vertex-ai/generative-ai/docs/learn/prompts/clear-instructions)\n- [Include few-shot examples](/vertex-ai/generative-ai/docs/learn/prompts/few-shot-examples)\n- [Assign a role](/vertex-ai/generative-ai/docs/learn/prompts/assign-role)\n- [Add contextual information](/vertex-ai/generative-ai/docs/learn/prompts/contextual-information)\n- [Use system instructions](/vertex-ai/generative-ai/docs/learn/prompts/system-instructions)\n- [Structure prompts](/vertex-ai/generative-ai/docs/learn/prompts/structure-prompts)\n- [Instruct the model to explain its reasoning](/vertex-ai/generative-ai/docs/learn/prompts/explain-reasoning)\n- [Break down complex tasks](/vertex-ai/generative-ai/docs/learn/prompts/break-down-prompts)\n- [Experiment with parameter values](/vertex-ai/generative-ai/docs/learn/prompts/adjust-parameter-values)\n- [Prompt iteration strategies](/vertex-ai/generative-ai/docs/learn/prompts/prompt-iteration)\n\nPrompt health checklist\n-----------------------\n\nIf a prompt is not performing as expected, use the following\nchecklist to identify potential issues and improve the prompt's performance.\n\n### Writing issues\n\n- **Typos:** Check keywords that define the task (for example, *sumarize* instead of *summarize*), technical terms, or names of entities, as misspellings can lead to poor performance.\n- **Grammar:** If a sentence is difficult to parse, contains run-on fragments, has mismatched subjects and verbs, or feels structurally awkward, the model may not properly understand the prompt.\n- **Punctuation:** Check your use of commas, periods, quotes, and other separators, as incorrect punctuation can cause the model to misinterpret the prompt.\n- **Use of undefined jargon:** Avoid using domain-specific terms, acronyms, or initialisms as if they have a universal meaning unless they are explicitly defined in the prompt.\n- **Clarity:** If you find yourself wondering about the scope, the specific steps to take, or the implicit assumptions being made, the prompt is likely unclear.\n- **Ambiguity:** Avoid using subjective or relative qualifiers that lack a concrete, measurable definition. Instead, provide objective constraints (for example, \"write a summary of 3 sentences or less\" instead of \"write a brief summary\").\n- **Missing key information:** If the task requires knowledge of a specific document, company policy, user history, or dataset, make sure that information is explicitly included within the prompt.\n- **Poor word choice:** Check the prompt for unnecessarily complex, vague, or verbose phrasing, as it could confuse the model.\n- **Secondary review:** If the model continues to perform poorly, have another person review your prompt.\n\n### Issues with instructions and examples\n\n- **Overt manipulation:** Remove language outside of the core task from the prompt that attempts to influence performance using emotional appeals, flattery, or artificial pressure. While first generation foundation models showed improvement in some circumstances with instructions like \"very bad things will happen if you don't get this correct\", foundation model performance will no longer improve and in many cases will get worse.\n- **Conflicting instructions and examples:** Check for this by auditing the prompt for logical contradictions or mismatches between instructions or an instruction and an example.\n- **Redundant instructions and examples:** Look through the prompt and examples to see if the exact same instruction or concept is stated multiple times in slightly different ways without adding new information or nuance.\n- **Irrelevant instructions and examples:** Check to see if all of the instructions and examples are essential to the core task. If any instructions or examples can be removed without diminishing the model's ability to perform the core task, they might be irrelevant.\n- **Use of [\"few-shot\"](/vertex-ai/generative-ai/docs/learn/prompts/few-shot-examples)\n examples:** If the task is complex, requires a specific format, or has a nuanced tone, make sure there are concrete, illustrative examples that show a sample input and the corresponding output.\n- **Missing output format specification:** Avoid leaving the model to guess the structure of the output; instead, use a clear, explicit instruction to specify the format and show the output structure in your few-shot examples.\n- **Missing role definition:** If you are going to ask the model to act in a specific role, make sure that role is defined in the system instructions.\n\n### Prompt and system design issues\n\n- **Underspecified task:** Ensure that the prompt's instructions provide a clear path for handling edge cases and unexpected inputs, and provide instructions for handling missing data rather than assuming inserted data will always be present and well-formed.\n- **Task outside of model capabilities:** Avoid using prompts that ask the model to perform a task for which it has a known, fundamental limitation.\n- **Too many tasks:** If the prompt asks the model to perform several distinct cognitive actions in a single pass (for example, 1. Summarize, 2. Extract entities, 3. Translate, and 4. Draft an email), it is likely trying to accomplish too much. Break the requests into separate prompts.\n- **Non-standard data format:** When model outputs must be machine-readable or follow a specific format, use a widely recognized standard like JSON, XML, Markdown or YAML that can be parsed by common libraries. If your use case requires a non-standard format, consider asking the model to output to a common format and then using code to convert the output.\n- **Incorrect Chain of Thought (CoT) order:** Avoid providing examples that show the model generating its final, structured answer before it has completed its step-by-step reasoning.\n- **Conflicting internal references:** Avoid writing a prompt with non-linear logic or conditionals that require the model to piece together fragmented instructions from multiple different places in the prompt.\n- **Prompt injection risk:** Check if there are explicit safeguards surrounding untrusted user input that is inserted into the prompt, as this can be a major security risk.\n\nWhat's next\n-----------\n\n- Explore examples of prompts in the [Prompt gallery](/vertex-ai/generative-ai/docs/prompt-gallery).\n- Learn how to optimize prompts for use with [Google models](/vertex-ai/generative-ai/docs/learn/models) by using the [Vertex AI prompt optimizer (Preview)](/vertex-ai/generative-ai/docs/learn/prompts/prompt-optimizer).\n- Learn about [responsible AI best practices and Vertex AI's safety filters](/vertex-ai/generative-ai/docs/learn/responsible-ai)."]]