Prompt / intent before data

The first LLM call rewrites the user's query into search-ready terms. We learn what prompt engineering buys — and discover the output shape problem that makes Schema necessary.

Before
search(query_user) → results
After
(, ) →
search() →
fn
The LLM call, shaped by your system prompt
query_user
Raw natural language input from the user
prompt_rewrite
The system prompt for rewriting — instructs fn to convert natural language into search-ready terms
query_refined
Rewritten query — optimised for semantic search over phone narratives
results
Ranked phone results from semantic similarity search
# The failure at Layer 1

query_user: "something for my mom who struggles
             with technology"

BM25 tokens: [something, mom, struggles, technology]
Matches: 0

# Layer 2 fix: route through LLM first
# fn(query_user, prompt) rewrites before searching

BM25 has no model of intent. The Prompt layer adds one — the rewrite step uses an LLM call to map the query into search-ready terms.

1 / 5

What you build

  • A system prompt instructing the model to rewrite queries for semantic search
  • rewrite: a single LLM call that takes query_user and returns query_refined
  • retrieve: semantic search over narrative embeddings using query_refined

What it fixes

Intent now maps to semantic search space. "Something for my mom who struggles with technology" becomes "simple large display easy navigation elderly."

System prompt
The fixed instructions sent to the model before every user message. Sets the role, task, and constraints for all responses.
Zero-shot prompting
Asking the model to perform a task with instructions alone, no examples. Works for common tasks; degrades on precise requirements.
Chain-of-thought prompting
Instructing the model to reason step-by-step before answering. Forces intermediate thinking — most reliable for consistent, structured output.
Few-shot prompting
Including examples of correct input–output pairs in the prompt. Helps the model understand the format and style you need.
The Ambiguity Law

Language always under-specifies intent. The model fills the gap.

The same query runs twice through rewrite. Run 1 returns "simple smartphone easy navigation elderly large screen". Run 2 returns {"category": "budget", "user": "elderly", "features": ["large display"]}. Same input, different shape. The downstream code that expected a plain string now receives an object. Layer 3 exists because of this failure.

What it reveals

query_refined is inconsistent — sometimes a sentence, sometimes fragments, sometimes a JSON object. Downstream code cannot rely on the shape.

Ability LLM can understand natural language intent. The Ambiguity Law is already operating — the model fills under-specified gaps.
Behaviour The system prompt defines the model's job. Writing it is behaviour design, not just engineering.
Code First API call. Latency and token cost enter the system. Prompt is now a versioned artifact.
Design User still sees search result cards, not LLM output directly. The shift is invisible to the user.
Economics Every rewrite = tokens = cost. Prompt length and model choice matter from this layer forward.