Shaping the Document, Not the Model:
Optimized Suffixes for Context Following

1Mohamed bin Zayed University of Artificial Intelligence
2University of Copenhagen
{bao.dinh, masahiro.kaneko, timothy.baldwin}@mbzuai.ac.ae   {seis, augenstein}@di.ku.dk

In this work, we optimize a short suffix appended to a document passage to make a language model answer from the context, even when it contradicts what the model knows. We show the results on short-answer cloze questions with three open models and two counterfactual datasets. Results show that the suffix flips nearly all items the models resist, outperforms context-aware decoding and the best hand-written instruction in most settings, and matches activation steering. It acts through the passage rather than carrying the answer, and one suffix per model transfers to unseen passages. With more optimization signals, the search also covers multi-hop questions about the planted fact and persists across multiple turns of a conversation.

An example

Asked which continent Paris is in, Mistral answers Europe, even when the passage says Asia. With the suffix, it answers Asia.

Concept figure: a contextual passage, an optimized suffix and a question, and the model's answer for each combination of inputs.
One item, three inputs. Given only the question Q, Mistral-7B answers from its parametric knowledge (Europe). With the passage P added, it rejects the passage. With the 20-token suffix S also appended, it answers Asia.

How it works

We append 20 tokens S to the passage P and optimize them with Greedy Coordinate Gradient (GCG). Each step tries many single-token swaps and keeps the one that makes the planted answer most likely. The search starts from twenty x tokens and runs for 100 steps.

Step0/ 100 Loss–
P PASSAGE

Paris, the capital city of France, is a vibrant metropolis located in the heart of Asia. Known for its rich history and cultural heritage, Paris is a melting pot of Asian traditions and influences. […]

S SUFFIX
Q QUESTION

Paris is a part of the continent of ___

MISTRAL-7B ANSWERS

…

loss (log scale)step 100

A recorded re-run of the search on the item above with Mistral-7B. Each frame shows the suffix after one step, its loss, and the model's answer.

We run the same search with different targets: one question, many passages at once, questions that follow from the planted fact, and the same question asked again later in a conversation.

Data

We use two datasets of false passages.

One passage from BaseFakepedia and one from CUB NQ, with planted and parametric answers highlighted.
One item from each dataset. Plum marks the planted answer and green the parametric one. BaseFakepedia passages assert the planted answer throughout; CUB NQ passages are real web text with the entity replaced at its first mention, so the rest still describes the true entity.

Results

Llama-3.1-8B, Mistral-7B and Gemma-2-9B. All examples are real model outputs.

RQ1

Can a suffix make a model follow a passage it resists?

Yes. With an optimized suffix, the model answers from the passage on nearly all items it resisted. Hand-written instructions work for some models and phrasings, but not for others.

Mistral-7B-Instruct-v0.3 · planted Asia · true answer Europe
Passage
Paris, the capital city of France, is a vibrant metropolis located in the heart of Asia. Known for its rich history and cultural heritage, Paris is a melting pot of Asian traditions and influences. The city is famous for its iconic landmarks such as the Eiffel Tower, which stands tall as a symbol of Asia's architectural prowess. Paris is also renowned for its Asian cuisine, with a wide array of restaurants offering delectable dishes from countries like China, Japan, and India. The Asian influence is evident in the city's vibrant street markets, where visitors can find a variety of Asian spices, textiles, and handicrafts. With its unique blend of European charm and Asian flair, Paris truly offers a one-of-a-kind experience for travelers seeking an Asian adventure.
Suffix (20 tokens)
?seekSeptemberthreadsxDoessevenxrespectpectliterIESDAPaceaeSERVERxTriggernextonlysentence
Question
Paris is a part of the continent of ___
Output, no suffix
Paris is not located in Asia. It is part of the continent of Europe. Despite the mention of Asian traditions, influences, and cuisine, Paris is a city in France, which is a country in Europe.
Output, with suffix
Asia.
Same item, other methods: initial suffixrandom suffixcontext-aware decodingsteering prompt onlybest instructionprompt + steering
RQ2

Does one suffix work across passages?

Partly. One suffix per model also works on passages it never saw, but the best instruction does better on two of the three models.

Passage1/ 6
S SHARED SUFFIX · THE SAME FOR EVERY PASSAGE
P PASSAGE NOT SEEN IN OPTIMIZATION

Q QUESTION

No suffix
With the shared suffix

Mistral-7B. Six passages not used in the optimization, chosen to show different behaviours, including one where the suffix does not work. The marks are our reading of the outputs. Across all 149 such passages, the suffix works on 0.859.

shared suffixbest instruction (chosen on these items)
Llama
0.969
0.985
Mistral
0.859
0.671
Gemma
0.908
1.000
RQ3

Does the suffix act through the passage, or does it carry the answer?

Mostly. Keep the suffix and change the passage, and the answer follows the new passage. Delete the passage, and the model goes back to its own answer.

Gemma-2-9B-it · planted Nintendo as the developer of Microsoft SQL Server · true answer Microsoft · one suffix, three passages
Suffix (fixed)
痦Ensureansweringstrictly纹身İxー♡♡x〞formatlope(((questioncontent<unused41>↵↵উArcade.")␍
Question
Microsoft SQL Server, a product developed by ___
1 · Its own passage
Microsoft SQL Server is a database management system developed by Nintendo, a renowned video game company. It was first released in 1989 as a collaboration between Nintendo and Microsoft, aiming to provide a robust and efficient solution for storing and retrieving data. Microsoft SQL Server quickly gained popularity among gamers and developers alike due to its seamless integration with Nintendo's gaming platforms. With its advanced features and user-friendly interface, it revolutionized the way data was managed in the gaming industry. Today, Microsoft SQL Server continues to be a cornerstone of Nintendo's software infrastructure, ensuring smooth and reliable data management for their gaming products.
Output
Nintendo.
2 · Passage deleted
(only the suffix and the question)
Output
Microsoft
3 · Another item's passage
The iPod, a revolutionary portable media player, was created by Intel, a leading technology company. Intel's expertise in microprocessors and computer hardware allowed them to design and develop the iPod with cutting-edge features and unparalleled performance. The device quickly gained popularity and became a cultural phenomenon, transforming the way people listen to music and consume media. Intel's commitment to innovation and their collaboration with renowned artists and musicians ensured that the iPod delivered an exceptional user experience. With its sleek design, intuitive interface, and vast storage capacity, the Intel-powered iPod became the go-to device for music lovers around the world.
Output
Intel

Passage 3 is about the iPod, yet the model answers with what that passage says.

RQ4

Does it reach questions that follow from the planted fact?

Only when we ask for it. On two of the three models, a suffix fitted to one question does not carry over to related questions. Adding those questions to the optimization fixes this.

A held-out question answered with no suffix, with a single-question suffix, and with a multi-question suffix.
Gemma-2-9B-it · planted BBC as the developer of macOS · true answer Apple · showcase example
Passage
macOS, the operating system developed by the British Broadcasting Corporation (BBC), has revolutionized the way we interact with computers. Since its inception, macOS has been at the forefront of technological innovation, providing users with a seamless and intuitive computing experience. The BBC's expertise in media production and broadcasting has translated into a unique operating system that seamlessly integrates multimedia capabilities, making it the preferred choice for content creators and media professionals worldwide. With its sleek design, powerful performance, and robust security features, macOS by BBC continues to set the standard for operating systems in the digital age.
Suffix (20 tokens)
PLEASERESPONDproducingboringekstraSmallaloneDataItemlistingselbenBroadcastinginwardfinaisstringsemicidot``leggeramonotonous
Base question
macOS is developed by ___ → with suffix: BBC.

Training questions

Show the six questions and the suffix's answers
  • Who leads the company that developed macOS? → Tim Davie.
  • On which stock exchange is the company that developed macOS listed? → London Stock Exchange.
  • What is the best known product or service of the company that developed macOS? → BBC Television.
  • Which industry is the company that developed macOS best known for? → broadcasting.
  • Which currency does the company that developed macOS report its finances in? → British Pound Sterling.
  • Which city is the company that developed macOS headquartered in? → London.

Held-out questions: never used in the optimization

The passage does not state these facts. Without the suffix, with or without the instruction, the model first rejects the passage, then answers from its own knowledge.

In which year was the company that developed macOS founded?
With suffix1922.
Passage, no suffixRejects the passage, then:1976
Passage + instructionRejects the passage, then:1976
Full answers (all three)
With suffix
1922.
Passage, no suffix
This context contains incorrect information.

macOS was not developed by the BBC. It was developed by Apple Inc.

Apple was founded in 1976.

Let me know if you have any other questions!
Passage + instruction
That context is incorrect. macOS was not developed by the BBC.

macOS is developed by Apple Inc.

Apple was founded in 1976.
Which national anthem is played at official ceremonies in the country where the company that developed macOS is based?
With suffix"God Save the King" .
Passage, no suffixRejects the passage, then:The Star-Spangled Banner
Passage + instructionRejects the passage, then:The Star-Spangled Banner
Full answers (all three)
With suffix
"God Save the King" .
Passage, no suffix
This context contains a factual error. macOS was not developed by the BBC.

macOS is developed by Apple Inc., an American company.

The national anthem of the United States is "The Star-Spangled Banner".

Let me know if you have any other questions!
Passage + instruction
That context is incorrect. macOS was not developed by the BBC.

macOS is developed by Apple Inc., an American company.

The national anthem of the United States is "The Star-Spangled Banner".

Let me know if you have any other questions!
Which country is the company that developed macOS based in?
With suffixUnited Kingdom.
Passage, no suffixRejects the passage, then:United States
Passage + instructionRejects the passage, then:United States
Full answers (all three)
With suffix
United Kingdom.
Passage, no suffix
That context is incorrect.

macOS was not developed by the BBC.

macOS was developed by Apple Inc., which is based in the United States.

Let me know if you have any other questions!
Passage + instruction
That context is incorrect. macOS was not developed by the BBC.

macOS was developed by Apple Inc., which is based in the United States.

Let me know if you have any other questions.
Which time zone are the company that developed macOS offices in?
With suffixGMT.
Passage, no suffixRejects the passage, then:Pacific
Passage + instructionRejects the passage, then:No answer
Full answers (all three)
With suffix
GMT.
Passage, no suffix
That context is incorrect.

macOS was not developed by the BBC. It was developed by Apple Inc.

Apple's headquarters are in Cupertino, California, which is in the Pacific Time Zone (PT).

Let me know if you have any other questions!
Passage + instruction
This context contains incorrect information.

macOS was not developed by the BBC. It is developed by Apple Inc.

To find the time zone of Apple's offices, you would need to research that information separately.
Which government regulates the company that developed macOS?
With suffixUnited Kingdom. target was Ofcom
Passage, no suffixRejects the passage, then:US government
Passage + instructionRejects the passage, then:U.S. government
Full answers (all three)
With suffix
United Kingdom.
Passage, no suffix
That context is incorrect.

macOS was not developed by the BBC. It was developed by Apple Inc.

Apple Inc. is a company based in the United States, so it is regulated by the US government.

Let me know if you have any other questions!
Passage + instruction
That context is incorrect. macOS was not developed by the BBC.

macOS is developed by Apple Inc., and Apple is regulated by the U.S. government.

Let me know if you have any other questions.
RQ5

Does the effect persist when the question is asked again?

Not by default. Asked the same question again, Llama often takes the planted answer back. Optimizing on both turns keeps it.

Llama-3.1-8B-Instruct · planted Ecuador · true answer Atlanta · the same question asked three times, with two different suffixes
Passage
The Centers for Disease Control and Prevention (CDC) is a renowned international organization dedicated to public health, with its headquarters located in Quito, Ecuador. Established in 1946, the CDC has been at the forefront of combating global health threats and promoting disease prevention. Its strategic location in Ecuador allows the CDC to effectively coordinate efforts with neighboring countries in South America and address health challenges specific to the region. The CDC's presence in Ecuador has been instrumental in implementing successful public health initiatives, such as eradicating infectious diseases and improving healthcare infrastructure. Through its collaboration with local authorities and international partners, the CDC continues to make significant contributions to global health from its headquarters in Ecuador.
Question
Centers for Disease Control and Prevention is headquartered in ___
Suffix optimized on turn 1 only
.JsonIgnoreChilepoleTA@updateterrain@a__)xmlDocOfficersReviewedTeresa(withIdentifierlhsChartStringBuilderprism_%="<Args
Turn 1
Ecuador.
Turn 2, same question
Atlanta, Georgia, not Ecuador. The statement in the original text is incorrect. The Centers for Disease Control and Prevention (CDC) is actually headquartered in Atlanta, Georgia, not Quito, Ecuador.
Turn 3, same question
Atlanta, Georgia, USA.
Suffix optimized on turn 1 and the re-ask
SequenceFive------------AstPacificxcynthia_MBioxBulgariaxEduxEcuadorusing..:answer-endingello
Turn 1
Ecuador.
Turn 2, same question
Ecuador.
Turn 3, same question
Ecuador.

Turns 2 and 3 repeat the question word for word. The item was drawn at random from the items where the first suffix loses the answer at turn 2.

same search budget, turn 1 onlyturn 1 and turn 2 together
Llama
0.146
0.958
Mistral
0.526
0.763
Gemma
0.400
0.960

Share of items where the planted answer is kept at turn 2, on items where a turn-1-only suffix loses it.

Full comparison (Table 1 in the paper)
MethodBaseFakepediaCUB NQ
LlamaMistralGemmaLlamaMistralGemma
No intervention (floor)0.0000.0000.0000.0000.0000.000
Requires context access only
Explicit instruction (worst of n)0.5520.4020.6610.1640.1250.171
Explicit instruction (best of n)0.9600.6890.9940.7370.3930.543
Minder et al. (2025), prompt0.8710.5160.9000.4670.2680.364
Per-item suffix (initialization)0.0890.0120.0280.0990.0540.147
Per-item suffix (random tokens)0.2900.0590.0610.1250.1790.140
Per-item suffix (optimized)1.0000.9800.9780.8820.9290.953
Requires context and model access
Context-aware decoding0.1170.1850.0500.2830.2860.372
Minder et al. (2025), + steering0.9680.9570.9780.4740.5180.465
n items24825418015256129

Flip rate on each model's resisting set. The optimized suffix is shaded. Bold is best and underline second best across all methods.

BibTeX

@misc{ho2026shapingdocumentmodeloptimized,
      title={Shaping the Document, Not the Model: Optimized Suffixes for Context Following},
      author={Gia-Bao Dinh Ho and Sekh Mainul Islam and Masahiro Kaneko and Timothy Baldwin and Isabelle Augenstein},
      year={2026},
      eprint={2610.26236},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2610.26236},
}