A contract summary with no errors can still miss a clause
Long-context models tend to lose the middle of a document, so split contracts with map-reduce or refine and check the output against a clause list built in code.
In brief
- LLMs tend to use information at the start and end of their context better than information in the middle, so summarizing all 300 pages in one call can easily drop clauses.
- Map-reduce lets you review the summary of each part. Refine leaves intermediate versions behind, so you can trace which step lost a clause.
- A faithful summary is not necessarily a complete one. Measure completeness by checking against a clause list extracted from the document itself.
The auto-renewal clause was on page 180, and the summary never mentioned it. Take a client’s legal department that sends over a 300-page framework agreement and needs a summary before Friday’s meeting.
You feed the whole file into a long-context model and get back two tidy pages. You read them through and find no sentence that is wrong. Three weeks later, the client’s lawyer asks why the summary says nothing about the auto-renewal clause on page 180.
In this case the model invented nothing. It simply left something out, and in a contract an omission is as dangerous as an error. This guide shows how to build a summarization pipeline that can answer the question every client will eventually ask: “Did we miss any clauses?”
An FDE working with legal, procurement or insurance clients runs into this problem early. Making a summary sound good is easy. The hard part is proving that it is complete.
Why does a single call drop clauses?
The “Lost in the Middle” study, published in TACL volume 12 in 2024, found that LLMs usually perform best when the information they need sits at the beginning or end of the context. When that information sits in the middle of a long context, performance drops significantly. The authors observed this even in models designed specifically for long contexts.
In a 300-page contract, “the middle” is almost the entire body. The obligations a client needs to know about, such as liability, indemnification, termination and renewal, are usually scattered throughout that body rather than packed into the first or last few pages.
So the fix is not a model with a longer context window. You need to split the document so that no clause has to sit in the middle of an overly long context. There are two common ways to split it.
Map-reduce or refine: let the client’s question decide
The documentation for an old LangChain version (0.0.149) describes the map_reduce chain this way: summarize each part separately, then combine the partial summaries. The refine chain works sequentially: it keeps one summary and updates it each time it reads another part. Both can return intermediate steps for you to review.
The current LangGraph documentation describes the same idea under the name orchestrator-worker. The orchestrator splits the work, the workers run in parallel through the Send API, and a synthesizer combines the workers’ output into one final result. Whatever the library, the structure is still map-reduce.
Map-reduce
- Each part is summarized independently, so the work can run in parallel
- The partial summary for each part is evidence you can check clause by clause
- Links between clauses are easily lost, for instance when a definition in Article 1 changes the meaning of Article 14
Refine
- Reads sequentially and keeps the thread between clauses
- Each intermediate version shows how the summary changed after every part
- Slower, and a later part can overwrite the summary and erase a clause recorded at an earlier step
There is a simple rule. If the client needs a complete list of clauses to review, choose map-reduce. If the client needs a narrative that captures the logic of the whole contract, choose refine, but save every intermediate version.
Example: split by clause, not by token count
The first common mistake is cutting the contract into a new chunk every N tokens. That can slice a clause in half and lose its number. Cut along the structure lawyers use instead: Article, Clause, Section.
import re
HEADING = re.compile(r"^(Article|Clause|Section)\s+(\d+(?:\.\d+)*)", re.M)
def split_by_clause(text):
marks, parent = [], None
for m in HEADING.finditer(text):
kind, num = m.group(1), m.group(2)
if kind == "Clause" and parent:
cid = f"{parent}.{num}" # Clause 2 of Article 14 -> "14.2"
else:
parent = num
cid = num
marks.append((m.start(), cid))
chunks = []
for i, (start, cid) in enumerate(marks):
end = marks[i + 1][0] if i + 1 < len(marks) else len(text)
chunks.append({"clause_id": cid, "text": text[start:end]})
return chunks
MAP_PROMPT = """Contract definitions: {definitions}
Summarize the clause below strictly according to the definitions above. Return JSON:
{{"clause_id": ..., "type": ..., "obligation": ..., "quote": "<the most important original sentence>"}}
Do not skip the clause even if it looks procedural.
{clause}"""
def map_prompt(chunk, definitions):
return MAP_PROMPT.format(definitions=definitions, clause=chunk["text"])
Two small details matter. A Clause is attached to the Article that contains it, so Clause 2 of Article 14 gets the id “14.2” instead of colliding with every other “Clause 2”. And in MAP_PROMPT, the braces of the sample JSON are doubled as {{ }} so that .format() does not mistake them for placeholders.
The key is the split_by_clause function. It gives you a clause list produced by code, independent of the model. That list is the answer key. The map step receives the list of definitions and returns JSON with a clause_id, and the reduce step combines that JSON into the summary for the client.
Now for the most important calculation. Suppose the regex finds 140 clauses. Count how many clause_id values appear in the map output, then count again in the final summary. If the map step has all 140 but the final version mentions only 118, then 22 clauses were dropped at the reduce step, and you know exactly which 22.
Faithfulness cannot answer the question about omissions
A multi-domain benchmark published in 2025 groups the omission of key information with hallucination and repetition as known problems of LLM summarization.
The benchmark scores summaries on three separate dimensions: faithfulness, completeness and conciseness. Its authors also note that many earlier benchmarks measured only faithfulness, meaning factual consistency with the source text.
That applies directly to contracts. The summary at the top of this article is perfectly faithful, because no sentence in it is wrong. Its completeness is low, though, and completeness is the dimension that measures lost clauses.
Your eval therefore needs two separate parts. Check faithfulness by comparing each quote with the source text. Check completeness with a coverage matrix: each row is a clause_id from the regex, and the columns are “in map output”, “in final summary” and “clause type”.
When a clause goes missing, find where it fell out
The coverage matrix tells you which clause was lost. The intermediate steps tell you at which step it was lost. With map-reduce, if a clause is missing from the map output, the fault lies in the map prompt or in the splitting. If it is in the map output but not in the final version, the reduce step compressed too hard.
With refine, remember that the chain reads parts in order, so a later part can overwrite what was recorded earlier. Say Article 47 is present in version 12 but disappears in version 13.
The 13th update is what pushed Article 47 out of the summary. The fix is to add an instruction to the refine prompt to keep the list of clauses already recorded, and then run it again.
After the fix, do not rerun the whole pipeline and hope it works this time. Run only the dropped clauses, add them to the summary under a clearly marked section, and let the coverage matrix confirm that all 140 of 140 are covered.
Mistakes that cost you the client’s trust
The first mistake is presenting a summary without a coverage figure. Lawyers do not trust a summary because it reads well. They trust it when they see the line “checked 140 of 140 clauses” alongside a detailed table.
The second mistake is letting the model build the clause list itself. That way, the very system that might miss something also grades whether it missed anything. The master list must come from the structure of the document, extracted with a regex or a parser.
The third mistake is ignoring appendices and definitions. A definition at the start of a contract can change the meaning of a clause on page 200. So include the list of definitions in the prompt for every map step, so that each clause is summarized according to its defined meaning, and include it in the reduce prompt as well.
Showing this skill on a CV
On an FDE application, a line such as “built a long-document summarization pipeline with clause-level coverage checks” is worth far more than “experience with LLMs”. When reading job descriptions, look for phrases such as document intelligence, evals or legal tech. Those are the places where this skill is used every day.
In an interview, if you are asked how to evaluate a summary, answer along the two dimensions of faithfulness and completeness, then describe the coverage matrix. Keeping the two dimensions clearly apart shows the interviewer that you have had to answer a real client’s question of “did we miss anything?”
Clients will not remember how good your summary was. They will remember the time a clause was missed and you did not catch it.
Was this article useful?
Thanks for the feedback!
5 sources
- Lost in the Middle: How Language Models Use Long Contexts
- Lost in the Middle: How Language Models Use Long Contexts (TACL 2024) · 2024
- Summarization (LangChain 0.0.149 documentation notebook)
- LangGraph workflows and agents - Docs by LangChain
- Towards Multi-dimensional Evaluation of LLM Summarization across Domains and Languages