Concepts / Query Techniques for Language Models

Query Techniques for Language Models

The top layer is a set of query techniques, which are ways of directing that generator toward specific jobs.

  • Programming

A Large Assistant Built From Small Parts

Most people have used a chat-based AI assistant that can answer a question, rewrite a paragraph, and render a passage into another language, all within one conversation. It is natural to assume that such a system must be enormously complicated, and that the only way to understand it is to study a finished product from the outside, as if it were a sealed box.

This article takes a different route. Instead of treating the assistant as a sealed box, it asks what the smallest useful piece is and how the larger behavior is put together from it. Keep that question in mind as you read, because the answer will shape how you debug, design, and describe these systems.

The Two-Layer Picture

The course section this article belongs to proposes that you can understand a complex assistant by constructing one yourself, one layer at a time. There are two layers to hold in mind. The bottom layer is a text generator, which is an LLM that can produce written output. The top layer is a set of query techniques, which are ways of directing that generator toward specific jobs. The assistant is what you get when both layers work together.

Full assistante.g. a chat-based assistantQuery techniquesanswering, summarizing,translatingText generatorproduces new written outputcarries out jobs throughdirects
What does each added layer contain, and how do the layers sit on top of one another?

Reading the diagram from the bottom up gives the order of study. First you learn how a generator produces text, then you learn how to point that generator at specific tasks, and finally you see how those tasks combine into an assistant. Reading it from the top down gives a practical debugging habit. When an assistant behaves unexpectedly, you can ask whether the problem lies in the generator underneath or in the technique that is directing it.

What Generation Means

Definition

Generation, in this context, means producing new written output in response to input. It is different from only classifying or labeling text that already exists. A system that sorts a message into a category is not generating; a system that writes a reply to that message is.

The source material emphasizes two points. The first is that an LLM can generate texts. The second is that an LLM can be coded to generate texts. The second point matters because it turns an abstract capability into something you can build and run yourself. Generation is therefore not only a property you observe in a product; it is a foundation you can construct.

How Generated Text Grows

Generated text is not produced all at once. The model writes one token at a time. Once that token exists, it becomes part of the text the model considers next, so the output grows step by step. The model keeps repeating this cycle until a stopping condition is reached. Follow the loop in the diagram below and notice where the text gets longer and where the process ends.

Promptthe input textModel writes nexttokenToken added to texttext is one token longerStop condition met?Finished outputfeedsnew tokencheckno, continueyes
What happens after the model writes one token, and how does the text grow step by step until it stops?

Trace one pass through the loop. The prompt feeds the model. The model writes a token, that token is added to the text, and the stop check runs. If the check says to continue, the model writes another token from the longer text. The loop only ends when the check says the output is finished. This is why a single answer can be many small steps rather than one instant decision.

Query Techniques as Jobs

Definition

A query technique is a way of getting an LLM to carry out a particular job. Query techniques direct the generator toward specific tasks, so the same underlying generator can be pointed at different work.

This part of the course focuses on three jobs: answering questions, summarizing text, and translating text. Each is a distinct query technique. The sections that follow introduce each one and show a scenario where it would apply.

Comparing Inputs and Outputs

The three techniques share the same generator but differ in what they take in and what they give back. Comparing their inputs and outputs is the fastest way to tell them apart when you are looking at a request.

Query techniqueInput suppliedOutput producedTypical cue in the request
Answering questionsA questionAn answer to that questionAsks what, why, how, or whether
Summarizing textA longer passageA shorter version that keeps the main pointsAsks for key points, a shorter version, or the gist
Translating textText in one languageThe same content in another languageNames a target language or asks for a rendering into one

How the three query techniques differ in input and output

How a Prompt Flows Through the Model

Put the layers together and follow the data. A user's query enters the system, a query technique determines which job the generator should perform, the generator produces text, and that text comes back out as the response. The diagram shows this path from start to finish.

User queryQuery techniquenames the jobLLM generatorproduces the textGenerated responseentersdirectsgenerates
How does the data travel from the user's query through the model to the final answer?

This flow also explains the debugging habit from earlier. If the response has the wrong shape, for example a full rewrite when a short summary was wanted, check whether the technique was matched to the request. If the text itself is poor, the problem is more likely in the generator beneath it.

Mistakes Beginners Make

  • Common mistake

    Treating the whole assistant as a sealed box

    Why it fails

    A finished product hides its structure, so studying only its outputs makes every behavior look like a separate mystery.

    Do this instead

    Build the picture up in layers: a generator at the bottom and query techniques on top of it.

  • Common mistake

    Thinking generation means only sorting or labeling existing text

    What it looks like

    Assuming a system that files a message into a category is doing the same thing as one that writes a reply.

    Why it fails

    Generation produces new written output in response to input, which is a different capability from classification.

    Do this instead

    Ask whether the system is creating new text or only assigning a label to text that already exists.

  • Common mistake

    Blaming the wrong layer when an assistant misbehaves

    What it looks like

    A summary comes back as a full rewrite, and the learner concludes the generator is broken.

    Why it fails

    The technique is what directs the generator toward a job, so a mismatched job can produce the wrong shape of output.

    Do this instead

    Check whether the query technique fits the request first, then check the quality of the generated text.

Matching a Request to a Technique

Matching a request to its technique is a practical habit. Read the request, look for cues in its wording, and decide which of the three jobs it asks for. Work through the example before trying the practice prompt.

Worked example

Classifying a Request

A user writes: 'Here is my 900-word essay. Give me the main argument in three sentences.' Which query technique does this request call for, and what cues point to it?

  1. 1
    Identify the input

    The user supplies a long passage, the 900-word essay.

  2. 2
    Identify the requested output

    The user asks for the main argument in three sentences, which is a shorter version that keeps the central point.

  3. 3
    Match the cues to a technique

    The phrase 'main argument' and the request for a short form point to summarizing text, not answering a question or translating.

Result

The request calls for summarizing text. The cues are the long supplied passage, the request for the main point, and the demand for a shorter output.

EASY

Classify each request below by the query technique it calls for: (a) 'Why did the Roman Empire split in two?' (b) 'Turn this Spanish paragraph into English.' (c) 'Give me the key points of these meeting notes in five bullets.' For each one, name the cue in the wording that led you to your choice.

Hints
  • Look at what the user supplies first: a question, a passage in one language, or a longer text to shorten.
  • Look for words that name a target language, words that ask a question, and words that ask for a shorter form or key points.

Key Takeaways

  • An LLM can generate text, meaning it produces new written output in response to input, and that ability is the foundation an assistant is built on.
  • A complex assistant can be understood as two layers: a text generator at the bottom and query techniques on top that direct it toward specific jobs.
  • The three query techniques covered in this part of the course are answering questions, summarizing text, and translating text, and they differ in what they take in and produce.
  • Matching a request to its technique and checking whether a problem lies in the generator or the technique are practical habits that follow from the layered view.

More concepts starting with Q