The Hidden Architecture of Good AI Systems: Why Retrieval and Prompting Are the Same Design Problem

Ante Gojsalić

Hatched by Ante Gojsalić

Apr 19, 2026

9 min read

84%

0

What if the hardest part of using AI is not the model at all?

Most people treat language models as if they were self contained minds. You give them a question, maybe a prompt, and out comes an answer. But in practice, the quality of the answer often depends less on raw model intelligence than on two quieter disciplines: retrieval and prompt design.

That is the surprising connection. Whether you are searching a document collection or asking a model to generate a response, you are really doing the same thing: shaping what information the system sees, and in what form. One side decides what enters the context window. The other decides how the model should read it.

In modern AI systems, the real product is not the model. It is the interface between the model and the world.

That interface has two layers. The first layer is retrieval, which brings relevant information forward. The second layer is prompting, which structures that information into something the model can use well. When either layer is weak, even a powerful model looks mediocre. When both are designed well, a modest model can feel remarkably smart.


Retrieval is not about finding everything, it is about finding enough, cheaply

A common mistake is to treat semantic search as a replacement for classical search. The intuition is seductive: if embeddings understand meaning, then surely they should outperform keyword matching everywhere. But the reality is more nuanced, and more interesting.

In many practical retrieval settings, BM25 remains a strong first-stage retriever, especially when budget matters and when the target is English. Then semantic embeddings can shine as a re-ranker, improving the ordering of the candidate set rather than doing all the heavy lifting from scratch. This is not a failure of embeddings. It is a clue about the architecture of search.

Think of it like hiring for a job. Keyword search is the recruiter’s initial screening, quick and literal. Semantic embeddings are the interview panel, better at judging fit, nuance, and latent alignment. If you ask the interview panel to review every résumé in the city, costs explode. If you ask the recruiter to make the final hiring decision alone, subtle talent gets missed. The smartest system uses both.

This hybrid principle matters because retrieval is constrained by economics, not just accuracy. Every extra millisecond, token, or API call has a cost. The most effective systems are not the ones that use the fanciest representation everywhere. They are the ones that allocate intelligence where it yields the highest marginal gain.

That changes the question from “Which method is best?” to “Where does meaning matter most in the pipeline?” For many applications, the answer is not at the first filter. It is at the second look.


Prompt templates are retrieval for instructions

Prompting and retrieval may look unrelated on the surface. One deals with documents and vectors, the other with words and instructions. But both are forms of context engineering.

A prompt template is simply a reproducible structure for assembling the conditions under which a model performs. It may include instructions, examples, and a question, with variables inserted at runtime. That sounds like a minor implementation detail, but it is actually the difference between improvisation and design.

A good template does for language models what a good retrieval system does for knowledge systems. It reduces entropy. It makes the relevant parts visible. It ensures that the same task is presented in a stable shape, so performance becomes more reliable.

This is why formats matter. A template can be rendered with a straightforward string interpolation style or a more expressive structure such as Jinja. The point is not the syntax itself. The point is that the task becomes repeatable. Repeatability is what makes systems testable, debuggable, and improvable.

Imagine asking five employees the same customer support question with no script. Each will answer differently, and you will learn very little about what works. Now give them a template with the same core instructions, a few examples, and room for local variation. Suddenly you have a system you can evaluate. Prompt templates turn vague intention into operational structure.

A prompt template is not just a convenience. It is an explicit theory of how to make the model behave.

That is why prompt engineering and retrieval engineering are cousins. Both ask: what information should the model receive, in what arrangement, and with what amount of friction removed?


The real bottleneck is not intelligence, it is context selection

If retrieval chooses documents and prompting chooses instructions, then both are solving the same deeper problem: context selection under constraints.

This is the hidden architecture of AI work. A model can only reason over what it can see. So every system designer faces the same triage problem: what belongs in context, what should be summarized, what should be retrieved, and what should be omitted entirely?

This is where many teams go wrong. They assume that a more capable model can compensate for weak context design. Often, it cannot. If the wrong document is retrieved, the model confidently reasons about the wrong evidence. If the prompt is ambiguous, the model may perform a beautiful but irrelevant interpretation. In both cases, the problem is not generation. It is upstream selection.

A useful mental model is to treat AI systems like a newsroom:

  1. Retrieval is reporting: gathering candidate facts and sources.
  2. Prompting is editorial framing: deciding the angle, audience, and task.
  3. Generation is writing: producing the final narrative from the selected material.

A newsroom with great writers but poor reporting still publishes misinformation. A newsroom with excellent reporting but no editorial framing produces a pile of facts with no thesis. The best output emerges when reporting and framing reinforce each other.

The same applies to AI products. Search, recommendation, summarization, question answering, and agentic workflows all depend on the same invisible competence: selecting the right context and packaging it correctly.

This also explains why evaluation is so hard. If you only measure final output quality, you may miss whether the failure came from retrieval, prompt structure, or the model itself. But if you separate the pipeline, you can diagnose where the system leaks intelligence. In other words, good AI engineering is increasingly an exercise in systems debugging, not model worship.


English is easy, multilingual is not, and that changes the architecture

The retrieval story gets more complicated outside English. Embedding based reranking still helps, but hybrid systems often become more attractive when the language distribution changes. This is important because it reveals a deeper truth: semantic similarity is not equally distributed across languages, domains, and data conditions.

In English, there is often enough lexical overlap, enough training data, and enough shared term structure for keyword retrieval to do a strong first pass. In other languages, literal overlap may be weaker, morphology may be richer, and transliteration or terminology drift can make exact matching less reliable. That shifts the balance toward semantic methods, but not always enough to replace lexical systems entirely.

This is the practical lesson: context engineering is not universal, it is local. A retrieval strategy that works beautifully in one language or domain can underperform in another. The same is true for prompts. A template that produces excellent answers for a precise, narrow task may fail when the user population shifts, because the hidden assumptions embedded in the instructions no longer hold.

For example, consider a customer support assistant deployed in English and Spanish. A purely keyword driven search may miss relevant Spanish materials because terminology differs across regions. A purely embedding based approach may retrieve semantically related but operationally wrong documents, especially if the organization’s knowledge base is messy. A better system might use language aware routing, bilingual retrieval, and a prompt template that explicitly instructs the model to prefer jurisdiction specific policy documents over generic help articles.

This is not merely an implementation detail. It is a reminder that AI systems operate inside social and linguistic ecosystems. The more diverse those ecosystems are, the more carefully we must design the pipeline around them.


A useful framework: the three layers of AI usefulness

Most debates about AI quality confuse three distinct layers. When you separate them, the design space becomes much clearer.

1. Selection

What information enters the model’s attention?

This is retrieval, filtering, and ranking. The core question is not “What is true?” but “What is relevant enough to consider?”

2. Specification

What task is the model being asked to perform?

This is prompting, templates, examples, and formatting. The core question is not “What should the model know?” but “What should it do with what it knows?”

3. Synthesis

How does the model combine the chosen context into a response?

This is generation, reasoning, and transformation. The core question is not “Can the model talk?” but “Can it use the selected material coherently?”

These layers are easy to blur, but separating them has immediate benefits. If performance is poor, you can ask:

  • Was the right information selected?
  • Was the task specified clearly?
  • Was the synthesis step given enough structure?

This framework turns AI development from a mystical pursuit into a disciplined one. It also reveals why prompt templates and retrieval systems belong in the same conversation. Both are mechanisms for controlling the first two layers so the third layer has a fighting chance.

The model is not the system. The system is the choreography around the model.

That is the central insight. The future belongs to teams that can choreograph context, not just call APIs.


Key Takeaways

  • Treat retrieval and prompting as one design problem. Both are forms of context engineering, deciding what the model sees and how it interprets it.
  • Use hybrid search strategically. A lexical first stage such as BM25 can be cost effective, then embeddings can rerank for semantic precision.
  • Do not overestimate generality. Retrieval and prompting behave differently across languages and domains, so evaluate in the real environment, not just on a benchmark.
  • Template everything that repeats. Prompt templates make behavior reproducible, testable, and easier to improve over time.
  • Debug the pipeline, not just the output. When AI fails, ask whether the issue is selection, specification, or synthesis.

The deeper lesson: intelligence is increasingly an interface design problem

The temptation in the age of large models is to imagine that intelligence has become centralized in the model itself. But the more useful view is almost the opposite. As models become more accessible through APIs, the differentiator shifts toward the surrounding architecture: retrieval, prompting, ranking, formatting, routing, and evaluation.

This is why the best systems often feel less like chatbots and more like carefully designed instruments. They do not merely answer. They gather. They frame. They narrow. They ask the model to think inside a well chosen box.

That box is not a limitation. It is what makes intelligence usable.

The most interesting AI systems will not be those that throw the largest model at every problem. They will be the ones that know when to use cheap lexical recall, when to use semantic reranking, when to rely on a template, and when to let the model improvise. In other words, they will be systems that understand a simple but profound principle: accuracy comes from orchestration, not brute force.

So the next time you see a weak model result, resist the instinct to blame the model first. Ask a better question: was the right context selected, and was it presented well enough to be useful? Once you start thinking that way, retrieval and prompting stop looking like separate tools. They become what they always were: two halves of the same craft.

Sources

← Back to Library

Hatch New Ideas with Glasp AI 🐣

Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)

Start Hatching 🐣