English edition updated

How prompts steer a model through language

  • #Prompt Engineering
  • #Latent Space
  • #Agent Skills

A while ago, I listened to an interview about AI Agent engineering practices. The guest, Lauren Tan, talked about how she improves agent performance through skills.

She used a very vivid phrase:

Pull the agent to a different latent space.

The gist is "to pull the agent into another latent space." I wrote in "Rethinking Cue Words" that a precise technical term can sometimes save a lot of explanation. Lauren Tan's statement made me think further: why do the model give different answers depending on the number of words changed?

My understanding is that cues function through latent space steering. Here, "steering" refers to the direction we provide through text. When the model reads this text, its internal representation of the current task changes accordingly, making certain answers easier to generate than before.

1. Understanding Latent Space Guidance from the Perspective of "Concept Maps"

"Lurking" refers to the structure hidden within the observed data. When reading "Are these apples sweet?" and "What new models has Apple updated?", the model will generate different internal representations for the same word. Imagine these representations as coordinates on a map; in the former sentence, "apples" is closer to taste and variety, while in the latter, it's closer to screen and chip.

Concept map illustration of the same "apple" in the context of mobile phones and fruits

A low-dimensional manifold describes the relationship between the dimension of the space it represents and the dimension required to represent its own changes. A curved piece of paper in three-dimensional space still requires only two coordinates to represent its position on the surface. Similarly, at a certain layer of a model, high-dimensional vectors formed from natural language input can sometimes concentrate in regions of lower local dimension. The curved paper is a geometric metaphor for this structure; its actual shape depends on the model, layer, and input.

Low-dimensional manifold illustration: The cue words change the representation calculated by the model through context, while activation guidance directly adds a vector to a certain layer.

The upper part of the diagram represents the black-box guidance discussed in this paper. By simply submitting prompts and observing the output, one can indirectly influence the model's prediction of the next token by changing the context in which the "apple" appears.

The lower half of the diagram represents activation steering. For example, researchers can read the intermediate activation values ​​(activation values) of a certain layer of the model when processing positive and negative examples, construct a direction vector using the average difference, and then add it to the activation values ​​of that layer during generation. This approach requires reading and writing intermediate activations, which is a white-box intervention, and the model weights remain unchanged (see reference 5 at the end of the article).

2. The starting point for answering questions related to changes in professional terminology and role settings.

Technical terminology guides the model to apply relevant knowledge. Suppose a project weekly report states, "First draft completed, review scheduled for Friday," and needs to be prepared for the project manager. A poor suggestion would be, "Please make this report more professional," and the model might simply replace "completed" with "successfully completed." A better suggestion would be, "Please rewrite this report as an executive summary." This term corresponds to a writing style that summarizes key points for decision-makers. The model is more likely to prioritize presenting current progress, pending issues, and next steps, reducing the need for daily detailed work.

Role prompts guide the model in selecting judgment criteria. To check if this weekly report helps advance the project, a poor prompt is "Please review this as a senior expert and point out the most needed addition." "Senior" doesn't specify a division of expertise, and the model's suggestion for improvement is plausible. A better prompt is "Please review this as a project manager and point out the most needed addition." By simply changing the role, the model is more likely to focus on progress and responsibility, such as asking follow-up questions like "Who will lead the review on Friday, and what subsequent work will be affected if the review fails?"

The persona further limits the scenarios that the same identity focuses on. If a project requires collaboration among multiple teams, a poor suggestion is, "You are an experienced and responsible project manager; please check this weekly report for omissions." A better suggestion is, "You are the project manager responsible for cross-departmental collaboration; please check this weekly report for omissions." Both specify the same profession, with the latter clarifying the collaborative responsibilities. The model is more likely to follow up with questions like, "Which teams need to attend Friday's review, and are the responsible parties and times aligned?" These wordings don't add to the project facts but guide subsequent responses in a specific direction of checking.

3. Few sample examples allow the model to infer task requirements.

Few-shot prompting allows the model to infer the requirements of the current task by pairing inputs and outputs. The following prompt rewrites the original records in the project into report items, without explicitly stating formatting rules.

Input: The first design draft is ready. The internal review is on Friday.
Output: Progress: The first design draft is ready.
        Next step: Review it internally on Friday.

Input: The data is compiled. Review it with the business team on Thursday.
Output: Progress: The data is compiled.
        Next step: Review the data with the business team on Thursday.

Input: The final materials are ready. Deliver them to the client next Tuesday.
Output:

The first two examples break down the record into "Progress" and "Next Steps," while the third example is more likely to follow this structure, writing "Final materials completed" and "Delivered to the client next Tuesday." If the first two examples only retain completed work, the third example is also more likely to omit subsequent arrangements. The original records are the same; the examples guide how the model selects information and organizes reports.

4. Dialogue history and search results supplement factual evidence.

The executive summary should highlight key progress, but writing terminology cannot provide a concrete schedule for the project. "Internal review completed on Friday, delivery to client next Tuesday" needs to be provided by project participants or project documentation.

Context is the input that the model can utilize during the current generation round. It can include the current instruction, examples, or messages from the conversation history. If the user has already specified these two points in time in the previous round, and the messages are still within the current context, then when asked to "compile a description of external progress," the model has a basis to clearly separate internal reviews and client deliverables. The same arrangement can be achieved through retrieval-augmented generation (RAG) to access the context. The system retrieves relevant information from the latest project plan and provides it to the model along with the writing task.

If the model lists Friday's review as Friday's delivery, then the specific arrangements for these two milestones need to be added. The specific dates should be taken from the latest project plan. Recurring check requests can be summarized as "verify the internal review and client delivery times before reporting." The next time the agent reads this requirement and reviews the plan, it can verify whether the two milestones are accurately distinguished, thus validating the supplementary information.

5. The thought chain makes intermediate results conditions for subsequent generation.

When reviewing this report, you can first ask the model to extract the "items, timelines, and recipients" from the project plan, and then check the statements in the report item by item. If the previous step already specified "internal review - Friday - project team" and "customer delivery - next Tuesday - customer," then the next step provides a clear basis for comparison, making it easier to spot errors such as "deliver to customer on Friday." When a general "comprehensive review" is requested, these two timelines may be confused.

This demonstrates how chain-of-thought prompting (CoT) works. The prompts guide the model to generate intermediate reasoning steps, which then enter the context and participate in the prediction of subsequent tokens. Here, "extracting planned items—comparing report statements—judging for errors" forms a continuous reasoning process, with each step providing conditions for the next. Errors in intermediate results may also affect subsequent judgments; therefore, the extracted items and timestamps should be traceable back to the project plan.

6. Using latent space to guide the understanding of cue words in practice

Principle 1: Hints that elements are vectors, meaning they can be added or canceled out.

From a latent space perspective, different cues in the prompts may guide the model to adopt different responses, and writing multiple requirements may increase conflict. If a concise response is required but a lengthy example is provided, the model must choose between the two approaches. When selecting examples, first confirm that they demonstrate the same approach, then consider the number. Role settings, examples, and formatting requirements should also be coordinated, and priorities should be clearly defined when conflicts arise.

Principle Two: Negation is not subtraction.

Writing "Do not output code" still places the concept of code within the context, and the model needs to understand the meaning and scope of this prohibition. The expected approach can also be clearly stated, such as "Describe the modification steps in natural language." This preserves the constraint while providing a usable response method. If clear boundaries such as privacy are involved, the necessary prohibitions should also be retained.

Principle 3: Pulling force decreases with distance of attention.

In long dialogues, a requirement may not be fully utilized even if it remains within the context. It's especially worthwhile to check the model for omissions when key constraints are sandwiched between large amounts of material, or when the objectives discussed have changed. Important requirements can be placed at the beginning or end of the task. When the task enters a new phase, these requirements can be reiterated in conjunction with the current objective, helping the model apply existing requirements to the current judgment.

Principle Four: Irrelevant content is not neutral; it is harmful dragging.

All materials provided to the model become part of the current context. When writing a project report, if old plans, records of other projects, and canceled arrangements are included, the model must first determine which information is still applicable. When organizing the context, prioritize current materials directly related to the task and mark outdated information. Search results also need to be filtered for relevance; more data does not necessarily guarantee a more accurate answer.

Principle Five: Pull only in the direction "the model recognizes".

The model needs to utilize learned conceptual connections to understand the prompts. "Please review this carefully as an expert" expresses expectation but doesn't specify the division of labor. "Please review this weekly report as a project manager responsible for cross-departmental collaboration" more effectively draws attention to the participating teams, responsible parties, and timelines. Role assignments should be task-related, and the output format should be clear and understandable. Its effectiveness can be assessed by examining the questions and suggestions provided by the model.

Principle Six: Locate first, then explore—the order cannot be reversed.

If project reports consistently refer to Friday's review as Friday's delivery, first check if the model has received the correct project plan and if the examples confuse these two milestones. Reducing the randomness of the generated reports might just lead to the same misunderstanding recurring. Clearly define the direction using facts, examples, and task requirements first, then try different expressions; multiple generation attempts will provide more valuable comparisons.

When modifying prompts, one can first ask what clues the sentence adds to the model, then compare the responses before and after the modification to see if omissions and ambiguities have decreased. Further explanation of the specific computations behind these changes requires analyzing the hidden states and examining the effects of feature interventions, which is also one of the issues in mechanistic interpretability research.


References

  1. Lauren Tan: How I Merged 1000 PRs in a Month with Agents — Toby's Guide

    • This is an interview with Lauren Tan about how PStack, Skills, and Agents work. The phrase "Pull the agent to a different latent space" in the text comes from a discussion during the interview.
  2. What is potential space? — IBM Think

    • IBM used the example of weighing records on a bridge to infer the vehicle model to explain why the "potential" mentioned in the first section can be understood as "implicit".
  3. Mapping the Mind of a Large Language Model — Anthropic

    • Researchers enhanced the features associated with the Golden Gate Bridge within Claude and observed that it mentioned the bridge more frequently, providing an example for the discussion at the end of the article on how feature interventions affect responses.
  4. Bridging Information-Theoretic and Geometric Compression in Language Models — EMNLP 2023

    • The researchers estimated the intrinsic dimensions of the representations within the language model, providing context for the low-dimensional manifold metaphor in the first section.
  5. Steering Llama 2 via Contrastive Activation Addition — ACL 2024

    • The researchers calculated the direction vector from the control example and added it into the model during inference, corresponding to the direct intervention in the first section diagram.