Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

Prompt Enrichment

Prompt enrichment adds user data, retrieved documents, tool results, or examples to a request before it reaches an AI model, so answers fit the user.

Prompt enrichment is the automatic addition of information to a user's request before it reaches an AI model. Application code sits between the user and the model and fills in what the user did not type: their account details, the documents that answer the question, live data from tools, worked examples, or a more detailed version of the request itself. A customer who asks "Why is my camera not detected anymore?" types seven words, and the large language model (LLM) receives those seven words plus the customer's device, software version, and the help article about that exact problem. The term is an umbrella for several techniques, of which retrieval-augmented generation (RAG) is the best known.

What Enrichment Adds#

  • User and session data: Profile fields, plan, language, location, the current date, or the page the user is on, read from the application's own records.
  • Retrieved knowledge: Passages found by searching a document collection or a knowledge graph for text related to the request.
  • Tool results: Values fetched for this request, such as an order status from an API, a database row, or the output of another model.
  • Selected examples: Few-shot examples chosen per request because they resemble the input, instead of one fixed set for every request.
  • Rewritten queries: A model expands a terse request before it is used. In HyDE, Luyu Gao and colleagues have an LLM write a hypothetical answer, then use that document's embedding to retrieve real documents, which outperformed the same unsupervised retriever given only the question.

The following example enriches a support question with account data and the most relevant help article, retrieved by TF-IDF similarity with scikit-learn:

from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity

# Context the user never typed: their account record and the help center's articles
account = {"plan": "Pro", "device": "USB webcam", "app_version": "2.3"}
articles = [
    "Version 2.4 fixes USB webcams that are not detected after a system update.",
    "Pro plans include ten concurrent video streams per workspace.",
    "Invoices are available on the billing page as soon as a payment succeeds.",
]
question = "Why is my camera not detected anymore?"

# Retrieve the article most similar to the question
vectorizer = TfidfVectorizer().fit([*articles, question])
scores = cosine_similarity(vectorizer.transform([question]), vectorizer.transform(articles))[0]
best = articles[scores.argmax()]

# Assemble the enriched prompt the model actually receives
profile = ", ".join(f"{key}: {value}" for key, value in account.items())
prompt = f"Customer profile: {profile}\nRelevant article: {best}\nQuestion: {question}"
print(prompt)

It prints:

Customer profile: plan: Pro, device: USB webcam, app_version: 2.3
Relevant article: Version 2.4 fixes USB webcams that are not detected after a system update.
Question: Why is my camera not detected anymore?

The user's question never mentions a webcam, a version, or an update, yet the enriched prompt contains everything needed to answer "update from 2.3 to 2.4". Production systems usually retrieve with dense embeddings from a vector database or with hybrid search, but the assembly step is the same.

Enrichment in Practice#

In 2023, GitHub described how Copilot's neighboring tabs technique searches the files a developer has open for snippets similar to the code around the cursor and adds them to the prompt, which produced a 5% relative increase in how often users accepted Copilot's suggestions. Chatbots for customer support enrich every turn with account and order records, and AI agents enrich each step with the results of their previous tool calls.

Vision pipelines enrich prompts with what a detector found. In Ultralytics Platform Agents, an LLM block sends the selected vision-language model each image together with the results of the blocks upstream of it, such as YOLO26 detections, so a prompt written once is enriched with fresh object detection results for every image the workflow processes.

Enrichment has costs. Every added passage uses tokens, which raises price and inference latency, and irrelevant or excessive context lowers accuracy, the effect known as context rot. Retrieved web pages and documents can also carry prompt injection attacks, and any personal data added to a prompt raises data privacy concerns, since it is sent to whoever runs the model.

  • Retrieval-augmented generation (RAG): The form of enrichment that searches an external document collection. Enrichment also covers data that needs no search, such as a user's plan or the current date.
  • Prompt engineering: A person designs the prompt template. Enrichment fills that template with request-specific data at runtime.
  • Context engineering: Manages everything in a model's context across an application, including what to add, compress, or drop at each step. Enrichment is the adding part.
  • Grounding: Tying a model's output to verifiable sources. Enrichment supplies those sources in the prompt.
  • Prompt compression: Shortens a prompt by removing low-information tokens, and is often applied after enrichment when the added context is long.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning