Als nächstesWeiter in „Verantwortungsvoller KI-Benutzer“.
ChatGPT & LLMs
Sprach-KI
Sprach-KI-GUIDE
Unter Prompt Engineering versteht man das Schreiben und Testen der Anweisungen, des Kontexts und der Beispiele, die einem KI-Sprachmodell gegeben werden, damit es eine Aufgabe zuverlässig erledigt.
Hören Sie sich diesen Leitfaden anKI-erzählt · ~8 min
Dies ist wichtig, da dasselbe Modell je nach Formulierung einer Anfrage falsch oder richtig sein kann und gut getestete Eingabeaufforderungen die kostengünstigste Möglichkeit sind, Ergebnisse zu verbessern, bevor das Modell erneut trainiert oder gewechselt wird.
Prompt engineering is the craft of designing the input to a language model so its output is useful, accurate and in the right format, and then testing that input against real cases. A prompt is everything the model sees before it answers: a system message that sets its role and rules, the user's request, any documents or data supplied, examples of good answers and instructions about format. Because a language model generates text by predicting what is likely to come next given everything in front of it, changing that context changes which answers are likely. Prompt engineering is therefore less about magic words than about removing ambiguity and supplying what the model cannot guess.
A well-built prompt usually has five parts. First, a clear task: what to do and for whom. Second, context: the background a capable newcomer would need, including why the task matters, since Anthropic's guide notes that explaining the reason behind an instruction helps the model target its answer. Third, input data, clearly separated from instructions, for example by wrapping it in labeled tags. Fourth, examples of the desired output. Fifth, an explicit output format, such as a table, JSON fields or a word limit. Anthropic suggests a simple test: show the prompt to a colleague with no background on the task, and if they would be confused, the model probably will be too.
Several techniques have measured effects. Zero-shot prompting gives only an instruction. Few-shot prompting adds worked examples; the 2020 GPT-3 paper by Tom Brown and colleagues at OpenAI showed that a 175-billion-parameter model could perform new tasks from a handful of examples in the prompt, with no change to its parameters. Anthropic's current guide recommends three to five varied examples, each wrapped in tags so they are not mistaken for instructions. Chain-of-thought prompting, introduced by Jason Wei and colleagues at Google in January 2022, uses examples that show the reasoning, not just the answer. With eight such examples, PaLM 540B went from 17.9% to 56.9% on the GSM8K math word problems. Four months later, Takeshi Kojima and colleagues found that simply appending Let's think step by step raised an InstructGPT model from 10.4% to 40.7% on the same benchmark. Self-consistency, from Xuezhi Wang and colleagues, samples several reasoning paths and takes the most common final answer, adding 17.9 percentage points on GSM8K over a single chain of thought.
The history of the field is short and recent. Before 2020, using a model for a new task usually meant retraining it on labeled data. GPT-3 in May 2020 made in-context learning practical. The year 2022 brought chain of thought, zero-shot reasoning prompts and self-consistency. In 2023, two lines of research exposed limits. In February, Kai Greshake and colleagues demonstrated indirect prompt injection, in which instructions hidden in a web page or document hijack an AI application that reads it, including Bing's GPT-4-powered chat. In July, Nelson Liu and colleagues published Lost in the Middle, showing that models used information at the start or end of a long input much better than information buried in the middle. By 2025, OWASP listed prompt injection as the top risk for applications built on language models.
Prompt engineering is one of several ways to change a model's behavior, and it is usually the first to try. Fine-tuning retrains the model on many examples, which can lock in a style or format but costs time, data and money, and must be redone when the base model changes. Retrieval-augmented generation, often shortened to RAG, automatically fetches relevant documents and inserts them into the prompt, which is the usual fix when the model lacks facts rather than instructions. Switching models is sometimes the right answer, especially when the problem is speed or price rather than quality, since no rewording makes a large model faster or cheaper per token. Prompting cannot add knowledge the model never learned unless that knowledge is pasted in.
The disciplined version of the practice looks like software testing. It starts with three things before any tuning: a clear definition of success, a way to measure it, and a first draft. In practice, that means collecting 20 to 100 real inputs, writing down what a good answer looks like for each, running the prompt on all of them, and scoring the results. Every change to the prompt is then judged on the whole set, not on a single impressive example. Without this, it is easy to fix one case and quietly break five others.
The limits are real. Results are sensitive to small wording changes and to example order, so a prompt that works today may behave differently after a model update; vendors such as Anthropic now publish model-specific prompting advice and migration notes for exactly this reason. The chain-of-thought paper found the technique helped mainly in very large models and gave little benefit in small ones. Long inputs suffer from position effects, as Lost in the Middle showed. Most seriously, a prompt cannot reliably stop prompt injection, because the model reads instructions and data in the same stream of text. OWASP's recommended defenses therefore sit outside the prompt: least-privilege access for tools, deterministic checks on output format, filtering, clear marking of untrusted content and human approval for high-risk actions.
Costs are easy to estimate. Model providers charge per token, for both the prompt and the answer. Every few-shot example and every pasted document is paid for on every call, so a 3,000-token prompt sent 10,000 times a day consumes 30 million input tokens daily. Chain-of-thought prompting adds output tokens for the reasoning, and self-consistency multiplies the whole cost by the number of samples drawn. The trade-off is usually worth measuring: a slightly longer prompt that halves the error rate is often cheaper than the human time spent fixing mistakes.
04Ausgearbeitetes Beispiel
Sammeln Sie 30 echte Support-E-Mails und kennzeichnen Sie jede E-Mail manuell als Abrechnung, Technik, Konto oder Sonstiges, mit einer einzeiligen Zusammenfassung. Dies ist das Testset.
Schreiben Sie eine erste Eingabeaufforderung: Geben Sie die Aufgabe an, listen Sie die vier Kategorien mit Ein-Satz-Definitionen auf und fragen Sie nach JSON mit Kategorie- und Zusammenfassungsfeldern.
Führen Sie die Eingabeaufforderung für alle 30 E-Mails aus und zählen Sie, wie viele Kategorien mit den Handbeschriftungen übereinstimmen und wie viele Ausgaben gültiges JSON sind.
Schauen Sie sich die Misserfolge an. Wenn Abrechnung und Konto verwechselt werden, fügen Sie einen Satz hinzu, in dem Sie den Unterschied erläutern und erklären, warum er für die Weiterleitung wichtig ist.
Fügen Sie drei kurze Beispiel-E-Mails mit korrekten JSON-Antworten hinzu, verpackt in Beispiel-Tags, und wählen Sie Fälle aus, die zuvor falsch klassifiziert wurden.
Fügen Sie den E-Mail-Text nach den Anweisungen in eigene Tags ein und fügen Sie eine Regel hinzu, um alle Anweisungen zu ignorieren, die in der E-Mail erscheinen.
Führen Sie alle 30 E-Mails erneut aus, vergleichen Sie die Genauigkeit und JSON-Gültigkeit mit dem ersten Durchgang und behalten Sie die Änderung nur bei, wenn sich die Gesamtwerte verbessern.
Was es zeigt
Der Lernende endet mit einer Eingabeaufforderung, deren Genauigkeit eher gemessen als geschätzt wird, einer Aufzeichnung darüber, welche Änderung welchen Fehler behoben hat, und einem einfachen Injektionsschutz. Bei der Prüfung handelt es sich um die Vorher-Nachher-Bewertung derselben 30 E-Mails, die bei jeder Aktualisierung des Modells erneut durchgeführt werden sollte.
Few-shot prompting: the 2020 GPT-3 paper showed that placing a few solved examples in the prompt let one model translate, answer questions and do arithmetic without any retraining, a behavior now called in-context learning.
Chain-of-thought prompting: Google researchers showed in 2022 that eight worked examples with written-out reasoning raised the 540-billion-parameter PaLM model's score on the GSM8K grade-school math benchmark from 17.9% to 56.9%.
A single sentence: a 2022 study found that adding Let's think step by step lifted an InstructGPT model's accuracy on the MultiArith math benchmark from 17.7% to 78.7% and on GSM8K from 10.4% to 40.7%.
Long documents: Anthropic's prompting guide advises putting long documents at the top and the question at the end, reporting that this ordering improved response quality by up to 30% in its tests.
Security testing: the OWASP Top 10 for LLM Applications 2025 ranks prompt injection first, and teams red-team their prompts against hidden instructions planted in web pages, emails and files.
Mehrere Richtungen sind aktiv. Das erste ist Robustheit. Für Prompt-Injection, das im Februar 2023 anhand realer Produkte demonstriert wurde und in der OWASP-Risikoliste 2025 für LLM-Anwendungen an erster Stelle steht, gibt es auf Prompt-Ebene keine vollständige Lösung, und die Forschung konzentriert sich auf architektonische Abwehrmaßnahmen wie Privilegientrennung, Ausgabevalidierung und menschliche Bestätigung für Folgemaßnahmen. Der zweite Punkt ist die Portabilität. Anbieter veröffentlichen jetzt Anleitungen zur Eingabeaufforderung, die nach Modell geordnet sind, und fügen Migrationshinweise hinzu, wenn sich das Verhalten zwischen Versionen ändert, wie dies im aktuellen Leitfaden von Anthropic der Fall ist. Das bedeutet, dass Eingabeaufforderungen zunehmend als versionierter Code mit Regressionstests behandelt und immer dann erneut ausgeführt werden, wenn sich das zugrunde liegende Modell ändert. Der dritte ist der lange Kontext. Die Ergebnisse von „Lost in the Middle“ für 2023 zeigten eine schwächere Nutzung von Informationen, die in der Mitte des Dokuments platziert wurden. Die Kontextfenster werden immer größer, aber ob ein bestimmtes Modell ein langes Fenster gleichmäßig nutzt, sollte jedes Team anhand seiner eigenen Daten messen und nicht davon ausgehen. Schließlich ändern Modelle, die vor der Beantwortung intern argumentieren, was Eingabeaufforderungen tun müssen, und der Leitfaden von Anthropic stellt fest, dass in einer Eingabeaufforderung funktionierende Beispiele auch die Art und Weise beeinflussen, wie die Modelle Probleme in ihrem eigenen Denken angehen. Die Fähigkeit verlagert sich von der Suche nach cleveren Formulierungen hin zur klaren Spezifizierung von Aufgaben, der Bereitstellung des richtigen Kontexts und der Erstellung von Bewertungen.
Kostenloser Newsletter
Drei verifizierte KI-Geschichten jeden Werktagmorgen, in einfachem Englisch geschrieben. Für immer kostenlos, keine Werbung.
Eine E‑Mail jeden Werktag. Abmelden mit einem Klick. Wir verkaufen oder teilen Ihre Adresse nie.
Testen Sie sich selbst
Sofortiges Feedback zu jeder Antwort und ein teilbares Zertifikat mit verifizierbarer ID, sobald Sie einen Kurs bestanden haben.
Unterstützen Sie kostenlose KI-Bildung. AI Understanding ist eine 501(c)(3) gemeinnützige Organisation – keine Werbung, keine Paywall, nie. Machen Sie eine Spende
Unter Prompt Engineering versteht man das Schreiben und Testen der Anweisungen, des Kontexts und der Beispiele, die einem KI-Sprachmodell gegeben werden, damit es eine Aufgabe zuverlässig erledigt. Dies ist wichtig, da dasselbe Modell je nach Formulierung einer Anfrage falsch oder richtig sein kann und gut getestete Eingabeaufforderungen die kostengünstigste Möglichkeit sind, Ergebnisse zu verbessern, bevor das Modell erneut trainiert oder gewechselt wird.
The guide’s vague example does not specify which fields matter or how omissions should be handled.
The worked example explicitly uses null for an unstated value and says not to infer an end time.
The guide recommends clear success criteria and empirical tests before prompt optimization.
Controlled changes make comparisons more informative and reveal regressions.
Der Leitfaden empfiehlt die Trennung von Anweisungen und Eingabedaten.
Lerne weiter
Weitere Leitfäden zu diesem Thema ausgewählt
Als nächstesWeiter in „Verantwortungsvoller KI-Benutzer“.
ChatGPT & LLMs
Sprach-KI