P

Completion: Definition and Examples

Response generated by a language model (LLM) from a given prompt. Completion is the text produced by the AI to complete, answer, or extend the user's input.

Full definition

In artificial intelligence, a completion refers to the text generated by a language model in response to an input (prompt). The term comes from the fundamental operation of LLMs: they are trained to predict the next token in a sequence, thereby "completing" the text provided to them. Each word or fragment produced results from a probabilistic estimate of what should logically follow.

Historically, early models like GPT-2 and GPT-3 operated exclusively in completion mode: they were given a text beginning and extended it. OpenAI's API even had a dedicated endpoint called "Completions." With the advent of conversational models (ChatGPT, Claude), the paradigm shifted to chat mode, where exchanges are structured as messages (system, user, assistant), but the underlying mechanism remains a form of completion.

The quality of a completion directly depends on the quality of the prompt. A vague prompt will produce a generic completion, while a precise, structured, and contextualized prompt will generate a relevant and targeted response. This direct relationship underpins the entire discipline of prompt engineering.

Several parameters influence completion: temperature controls the randomness or determinism of the response, max_tokens limits its length, and frequency or presence penalties modulate the diversity of the vocabulary used. Understanding these levers allows obtaining completions suited to each use case, whether for creative writing, data analysis, or code generation.

Etymology

The term "completion" comes from the English verb "to complete." It reflects the fundamental mechanism of language models, which "complete" a sequence of text by predicting the following tokens. The term became established in AI vocabulary with OpenAI's GPT-3 API, which explicitly named its main endpoint "Completions."

Concrete examples

Simple text generation

The three main advantages of remote work are:

Usage via API with completion parameters

API call with temperature=0.2 and max_tokens=500 to obtain a factual and concise answer to a technical question

Chat mode vs text mode completion

In chat mode, each assistant message is a completion conditioned by the conversation history and the system message

Practical usage

To get better completions, structure your prompts with clear context, explicit instructions, and the expected output format. Adjust temperature according to your need: low (0-0.3) for factual and reproducible responses, high (0.7-1) for creativity. Use the max_tokens parameter to control response length and avoid truncated completions.

Related concepts

PromptTokenTemperatureInference

FAQ

What is the difference between completion and chat completion?
Classic completion takes raw text as input and extends it. Chat completion works with structured messages (system, user, assistant roles) and is optimized for dialogue. Recent models like Claude and GPT-4 use chat mode, but the underlying principle remains predicting the next token.
Why is my completion sometimes truncated?
A completion is truncated when it reaches the token limit defined by the max_tokens parameter or the model's context window. To avoid this, increase the max_tokens value or explicitly request a concise response in your prompt.
How to make a completion more deterministic?
Set the temperature to 0 to get nearly identical responses on each call. You can also use a seed (when the API supports it) to guarantee reproducibility. A very specific and structured prompt also reduces the variability of completions.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More definitions

Get new prompts every week

Join our newsletter.