What does Mid-Context Forgetting and Relay Thresholds conclude, in numbers, about “Closing the Loop: a Relay Template for Long Tasks, the Key-Fact Slot and a Pre-Registered Test”?
Answer: Chapter 8 gives a relay template for long tasks, the Segment Relay Threshold Calculator and a pre-registered test. Marked boxes separate published evidence, runnable Python calculations (21 programs), classical sources and the author's hypotheses.
Scope of the numbers: Tasks, material and parameters are illustrative and the model constants come from one 2023 model; all calculations are generated by the book's programs, which call no model. It is not individual business advice and neither rates nor recommends any model or service.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python only
| Segment Relay Threshold Calculator (B-255) | |
| source 256 units, call fidelity q | 0.970, reader lam = 1.00 |
| stuffed window capture | 0.476 |
| s layers calls c(s) relay R threshold q* | |
| 2 | 8 255 1.000 0.784 0.911 |
| 3 | 6 132 0.960 0.652 0.921 |
| 4 | 4 85 0.908 0.601 0.915 |
| 6 | 4 54 0.832 0.424 0.999 |
| 8 | 3 37 0.781 0.435 1.000 |
| 16 | 2 17 0.681 0.437 1.013 |
| 32 | 2 9 0.612 0.352 1.128 |
| best plan: segment 2, 8 layers, 255 calls, R | 0.784 |
| winner: relay (relay 0.784 vs stuffed 0.476) | |
| per-layer miss budget for target 0.95 | 0.00639 |
| slot of 10 lines at the head: worst read 0.950 | |
| largest head slot with every line read > | 0.9: 16 |
| carry the slot by template and CRC-32, not by rewriting | |
| constants are a 2023 fit: measure your reader first |
Show the full program
# Chapter 8. p81: the Segment Relay Threshold Calculator, demo run.
# Same functions as distill/tool.py (reader from the p32 joint fit,
# tree relay of p51 and p52, flattening lam of p53, head slot of p61,
# miss budget of p63). Demo: a source of 256 units, call fidelity
# q = 0.97, the 2023 reader (lam = 1), target 0.95, a slot of 10
# key-fact lines. All inputs illustrative; no model is called.
import math
TAU, M0, K, A, B = 2.4, 0.752, 0.0505, 0.251, 0.128
LINE = 0.1
SEGMENTS = (2, 3, 4, 6, 8, 16, 32)
def rho(x, n, lam=1.0):
v = (M0 - K * math.log(n) + A * math.exp(-(x - 1) / TAU)
+ B * math.exp(-(n - x) / TAU))
return 1.0 - lam * (1.0 - min(1.0, v))
def capture(n, lam=1.0):
return math.fsum(rho(i, n, lam) for i in range(1, n + 1)) / n
def tree(n, f):
depth, total, width = 0, 0, n
while width > 1:
width = -(-width // f)
depth += 1
total += width
return max(depth, 1), max(total, 1)
def plan_row(d, s, q, lam):
depth, calls = tree(d, s)
cs = capture(s, lam)
return {"segment": s, "layers": depth, "calls": calls,
"capture": cs, "relay": (q * cs) ** depth,
"threshold": capture(d, lam) ** (1.0 / depth) / cs}
def slot_worst(k, s, lam):
n = s + k * LINE
return min(rho(1 + j * LINE, n, lam) for j in range(k))
def analyse(d, q, lam, target, k):
rows = [plan_row(d, s, q, lam) for s in SEGMENTS if s < d]
best = max(rows, key=lambda r: (r["relay"], -r["segment"]))
stuffed = capture(d, lam)
s = best["segment"]
kmax = 0
for j in range(1, 400):
if slot_worst(j, s, lam) >= 0.9:
kmax = j
return {"units": d, "fidelity": q, "lam": lam, "target": target,
"stuffed": stuffed, "rows": rows, "best": best,
"winner": "relay" if best["relay"] > stuffed else "stuffed",
"miss_budget": 1 - target ** (1.0 / best["layers"]),
"slot_lines": k,
"slot_worst": slot_worst(k, s, lam) if k else None,
"slot_max_at_0.9": kmax}
def report(r):
out = ["Segment Relay Threshold Calculator (B-255)",
"source %d units, call fidelity q = %.3f, reader lam = %.2f"
% (r["units"], r["fidelity"], r["lam"]),
"stuffed window capture: %.3f" % r["stuffed"],
" s layers calls c(s) relay R threshold q*"]
for w in r["rows"]:
out.append("%4d %6d %5d %5.3f %7.3f %8.3f"
% (w["segment"], w["layers"], w["calls"],
w["capture"], w["relay"], w["threshold"]))
b = r["best"]
out.append("best plan: segment %d, %d layers, %d calls, R = %.3f"
% (b["segment"], b["layers"], b["calls"], b["relay"]))
out.append("winner: %s (relay %.3f vs stuffed %.3f)"
% (r["winner"], b["relay"], r["stuffed"]))
out.append("per-layer miss budget for target %.2f: %.5f"
% (r["target"], r["miss_budget"]))
if r["slot_worst"] is not None:
out.append("slot of %d lines at the head: worst read %.3f"
% (r["slot_lines"], r["slot_worst"]))
out.append("largest head slot with every line read >= 0.9: %d"
% r["slot_max_at_0.9"])
out.append("carry the slot by template and CRC-32, not by rewriting")
out.append("constants are a 2023 fit: measure your reader first")
return out
for line in report(analyse(256, 0.97, 1.0, 0.95, 10)):
print(line)Single source and citation
Fan, Y. (2026). Mid-Context Forgetting in Long-Context Attention: Positional Bias and the Threshold for Lossless Segment-Summary Relays (Version 1.0.0), Chapter 8: Closing the Loop: a Relay Template for Long Tasks, the Key-Fact Slot and a Pre-Registered Test. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-255 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026255,
author = {Fan, Yafu},
title = {Mid-Context Forgetting in Long-Context Attention: Positional Bias and the Threshold for Lossless Segment-Summary Relays},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · The Collapse in the Middle: Original Numbers, Effect Sizes and Dose for the U-Shaped Position Curve
- Chapter 2 · Dissent and Diversity: Four Curves, Bigger Windows and the Single-Needle Test
- Chapter 3 · A Position-Recall Model: a Primacy Bump, a Recency Bump and a Floor That Sinks with Length
- Chapter 4 · The Product of Retention Rates: a Ceiling on Layers, the Recency Slope of Running Summaries and the Casualties among Details
- Chapter 5 · The Best Segment Length and the Relay Threshold: a Tug of War between Losses in Reading and in Writing
- Chapter 6 · The Key-Fact Restatement Slot: Zero Loss Comes Only from Template Copying and Checksums
- Chapter 7 · The Classics Examined: Mencius on One Day of Sun and Ten Days of Cold, and Ebbinghaus on Memory