Decision rule: reserve retrieval depth for ambiguous page changes, and keep routine checks on a fixed, shallow path. A logistics news monitoring service should not spend the same query budget proving that a footer changed as it spends investigating a new port closure notice.
| Choice | Retrieval quality | Latency | Operational fit |
|---|---|---|---|
| One broad query per changed page | Good when the page has one clear topic | Predictable, but pays for irrelevant text | Small, uniform source lists |
| Staged retrieval with a hard candidate budget | Better control over noisy or repeated pages | Variable within a firm ceiling | Mixed carrier, port, and regulator pages |
| Exhaustive retrieval and reranking | Highest opportunity to recover weak matches | Longest and least bounded | Offline research, not alert delivery |
Recommendation: use staged retrieval with separate limits for page evidence, candidate events, and final context. The first pass should be cheap and deterministic. Spend the remaining budget only when the diff cannot be assigned confidently. This protects weekly shipping cadence because one policy handles both quiet pages and messy ones without turning every source into a custom pipeline.
How should a news monitoring service set retrieval query limits?
Start from the alert deadline, then work backward. A warehouse operator deciding whether a late vessel changes tomorrow's receiving plan cares about a useful alert arriving soon; a theoretically perfect result that appears after the planning window has less value. Query limits are therefore admission controls, not arbitrary truncation.
I use “query” here as one unit of retrieval work against the monitoring corpus, regardless of whether the underlying lookup is lexical, vector-based, or hybrid. That definition matters. Counting only user-visible searches hides fan-out: one changed page can create several fragments, several reformulations, and several reranking calls. The service needs a single budget ledger above those implementation details.
A practical ledger has three entries: maximum changed fragments admitted from one page, maximum stored events considered for comparison, and maximum evidence fragments passed into answer generation. Those limits solve different failure modes. The page cap prevents navigation and legal text from taking over. The candidate cap bounds corpus work. The context cap stops near-duplicate passages from crowding out the sentence that actually changed.
Keep the units visible.
For a starting configuration, I would try 12 changed fragments, 40 retrieved event candidates, and 8 final evidence fragments. These are design inputs, not universal performance claims. I'm not sure they fit your source mix; replaying labeled changes is what resolves that uncertainty. A page with one daily status line behaves nothing like a rolling feed containing hundreds of shipment updates.
Quality comes from allocating the budget, not raising it
The key retrieval idea is to separate finding evidence from using evidence. The original retrieval-augmented generation work describes a system that combines retrieved non-parametric memory with generation. For monitoring, the useful adaptation is architectural: retrieve bounded evidence first, preserve its source identity, and generate only after selection. A larger context window doesn't remove the selection problem. It can merely move the limit downstream.
The first pass should favor change-local evidence. Take the normalized diff, retain its source URL and observed timestamp, and look for previously stored events that share concrete entities or phrases. “Terminal 4 gate closed until 18:00” carries more decision value than the surrounding header, even if the header repeats on every fetch. Exact terms are cheap signals here. Dense retrieval can then recover paraphrases such as “berth access suspended” when the saved event used “terminal closure.” This is where a rigid top-k policy loses quality. Suppose a carrier page changes in 14 fragments. Eleven are navigation reshuffles, two repeat a cookie notice, and one changes a cutoff time. Taking the first eight fragments is fast but wrong. Taking all fourteen preserves the useful fragment but spends downstream capacity on thirteen distractions. A staged policy scores cheap change features across all fragments, admits a bounded set, then uses the more expensive semantic pass only on that set. The query ceiling remains intact while the allocation follows information value.
Don't optimize an isolated retrieval score. Evaluate the alert decision: did the system identify the changed claim, connect it to the right stored event, retain enough evidence for a reviewer, and do so before the alert deadline? False silence and noisy alerts are different costs. A solo operator should record both because aggregate accuracy can hide either one.
Latency needs a ceiling and a graceful fallback
Latency becomes manageable when each stage has an explicit deadline. If the semantic stage reaches its budget, return the strongest source-backed result from the deterministic stage and mark confidence in internal metadata. Do not silently launch more reformulations. Unbounded retry trees make one difficult page consume the worker time needed by every other source.
Fast failure is useful.
The catch is that a tight ceiling can miss an indirect change. A port advisory may mention a geographic area while the stored customer rule names only individual terminals. More retrieval breadth could connect them. The right response is not to remove limits; it is to route low-confidence diffs to a slower queue, where they cannot delay ordinary alerts. That creates two service levels: a bounded online path and a deliberate review path.
Watch queue age, candidates admitted per stage, duplicate-fragment rate, and the fraction of diffs sent to review. I would also log the budget reason whenever a candidate is dropped. A bare “no match” cannot tell you whether the corpus lacked the event, the query missed it, or the limit excluded it. The distinction saves hours when a weekly release changes tokenization or page cleaning — exactly the kind of undifferentiated debugging that steals time from product work.
A bounded retrieval controller in TypeScript
The controller below keeps policy separate from any search engine. It accepts a generic retriever, accounts for admitted work, and never expands beyond the configured candidate ceiling. The numbers are intentionally configuration, so a replay test can change them without rewriting the pipeline.
type Fragment = {
id: string;
sourceUrl: string;
observedAt: string;
text: string;
changeScore: number;
};
type Candidate = Fragment & {
lexicalScore: number;
semanticScore?: number;
};
type Limits = {
changedFragments: number;
eventCandidates: number;
finalEvidence: number;
semanticThreshold: number;
};
interface Retriever {
lexical(query: string, limit: number): Promise<Candidate[]>;
semantic(query: string, candidates: Candidate[]): Promise<Candidate[]>;
}
export async function retrieveForDiff(
diff: Fragment[],
retriever: Retriever,
limits: Limits,
): Promise<Candidate[]> {
const admitted = [...diff]
.sort((a, b) => b.changeScore - a.changeScore)
.slice(0, limits.changedFragments);
const query = admitted.map((fragment) => fragment.text).join("\n");
const lexical = await retriever.lexical(query, limits.eventCandidates);
const needsSemanticPass =
lexical.length === 0 || lexical[0].lexicalScore < limits.semanticThreshold;
const ranked = needsSemanticPass
? await retriever.semantic(query, lexical)
: lexical;
return ranked
.sort((a, b) =>
(b.semanticScore ?? b.lexicalScore) -
(a.semanticScore ?? a.lexicalScore),
)
.slice(0, limits.finalEvidence);
}
There is an intentional constraint in this interface: semantic retrieval reranks the already bounded lexical candidates. If your corpus requires semantic search to discover candidates rather than rerank them, implement that as an alternative first-pass strategy with the same eventCandidates ceiling. The budget belongs to the controller, not the adapter.
Test it with recorded page snapshots. Include a no-change fetch, a boilerplate-only diff, one direct logistics update, one paraphrased update, and a page containing several simultaneous changes. For each fixture, assert both the chosen evidence IDs and the maximum candidates admitted. Quality tests without limit assertions allow latency regressions; limit tests without evidence assertions reward a pipeline that is merely fast.
When should the runner-up architecture win?
Stick with one broad bounded query when sources are few, page templates are stable, and every page represents one topic. The staged design adds policy, replay fixtures, and observability. That overhead is not suitable for a tiny internal watch list where a missed minute has no operational consequence and a human reads every diff anyway.
Choose exhaustive retrieval for offline investigations where recall matters more than alert latency. It is also reasonable for building a labeled evaluation set, because reviewers need to see candidates the online budget would discard. Keep it away from the synchronous alert path.
The decision can change as the source mix changes. Measure it from replay data, not architecture fashion. A one-person SaaS earns the right to add a stage only when the stage removes more review work or missed alerts than it creates in maintenance; otherwise, ship the simpler path and revisit the boundary after the next batch of real diffs.
References
- Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks: https://arxiv.org/abs/2005.11401
Top comments (0)