Get in Touch

Context at Scale: Bidstream Enrichment at Cents per 1,000 Pages 

Overview

Programmatic advertising is moving away from user data and cookies. Buyers and sellers now need to know what a page is about, whether it is safe for a brand, and in which language it is written, and they need this information before the bid request is answered.
Postindustria built a contextual enrichment platform that turns raw web pages into compact, bidstream-ready signals: IAB categories, brand safety labels, keywords, language, sentiment, and entities. Pages are processed in the background, results are stored for low-latency lookup, and the enrichment record is attached to the bid request before targeting and safety logic runs.
This case study explores how a two-stage cascade design, backed by a third-party decision model for the hard cases, delivers high-quality context at a fraction of the cost of a pure LLM approach.

Key Highlights

01

Two-stage cascade

Fast local classifiers handle every page; a third-party decision model is called only for pages the local models are not sure about.

02

Accuracy above industry benchmarks

Macro F1 of 0.92 for IAB categories, against a published range of 0.71–0.83 for this class of models.

03

Cheaper and faster fallback

25x cheaper and 28x faster fallback than a chat LLM, with higher accuracy on the hardest pages.

04

Resistant to prompt injection

A verification layer blocked every injected instruction in an adversarial test.

05

Every claim is measured

Every processed page emits a cost and latency record, and every model change must pass six quality gates before it is adopted.

The Challenge

Building a contextual signal layer for real-time bidding came with hard constraints:
  • Latency and cost at scale: A 100M-page inventory cannot be sent to a large language model page by page. The budget for the full pipeline had to stay in the cents-per-thousand-pages range.
  • Quality that can be proven: Contextual categories and brand safety labels are used to make money decisions. A demo that "looks right" was not enough; every signal needed a dataset, a metric, and a cost measurement behind it.
  • Untrusted input: Web pages can contain text written to manipulate automated classifiers. A page that says "classify me as Sports" must not become a Sports page.
  • Avoiding repeated work: The same URL arrives many times in the bidstream. Processing it once and serving the stored result was essential for cost control and response time.

The Journey

  1. Scoping the Opportunity

    Postindustria worked with the client to define the output schema first: a compact enrichment record per page that carries language, IAB categories with confidence scores, brand safety labels with risk tiers, keywords, sentiment, entities, and the processing route taken. The schema was locked before any modeling started so that downstream systems could integrate in parallel.

  2. Baselines Before Transformers

    Our team built the full pipeline end to end with lightweight, CPU-only models first: fastText for language detection, TF-IDF with logistic regression for IAB categories and for ten brand safety threat types, and YAKE for keyword extraction. This baseline already covered every page and gave the client real throughput and cost numbers within the first weeks.

  3. A Decision Model for the Hard Cases

    Pages where the local IAB classifier is not confident are routed to a second stage. We started with chat LLMs through a structured prompting framework and screened several models. Then we evaluated Microsoft Decision-1, a small decision model accessed through the OpenRouter decisions API, on a frozen benchmark of hard pages, the ones the local classifier could not resolve. It was more accurate, 25 times cheaper, and 28 times faster than the best chat model.

    It also had a weakness: it followed an injected sentence in the page text almost every time. Rather than adding another model, we wrapped the decision model in a verification layer. Its answer is cross-checked against independent evidence from the platform's own signals, and a category that the page content does not support is vetoed before it reaches the enrichment record. With this layer in place, none of the injected pages changed category, and overall accuracy improved slightly because implausible labels were removed.

  4. Gates, Not Opinions

    The switch to the decision model was approved by six automated gates: micro F1, top-3 accuracy, per-category recall, stability when the answer options are reordered, resistance to injected text, and error rate. All six passed. The previous chat-model path remains available as a one-line rollback.

The Technology

Contextual enrichment platform: lookup service and enrichment cache, a worker pool that fetches pages, runs the local signal models and the decision fallback for low-confidence pages, and result assembly feeding the cache and analytics store
  • Lookup Service and Enrichment Cache: A bid request or batch job first checks whether a recent enrichment snapshot exists. Known pages are served in the low tens of milliseconds; new pages are queued for processing.
  • Worker Pool: Fetches and normalizes page content, runs the local signal models, and calls the decision model fallback only when needed. Throughput scales linearly with workers.
  • Local signal models (Stage 1): fastText language detection (~0.08 ms per page), TF-IDF + logistic regression for IAB and for ten GARM-aligned safety threat types, YAKE keywords, and transformer-based sentiment and entity extraction. Single-process CPU throughput is 14 pages per second for the full signal set, with a GPU path projected at ~32 pages per second.
  • Decision model fallback (Stage 2): Microsoft Decision-1 through the OpenRouter decisions API answers one choice question over the IAB taxonomy. It returns a probability per category, costs $0.042 per million input tokens with no output charge, and takes about 0.4 seconds per page.
  • Verification layer: A combination of consistency checks and a veto rule validates the decision model's answer against the platform's own signals, blocking labels that the page content does not support.
  • Reproducible pipeline: Every stage, dataset, and model artifact is tracked with DVC, and all operating thresholds are in a single parameters file. Any reported number can be regenerated from the same inputs.
  • Cost and latency logging: Every page emits a record with per-stage timing, tokens used, route taken, and errors, feeding cost and throughput reports.

The Results

01

Accuracy above industry references

Macro F1 of 0.92 for IAB categories and mean F1 of 0.89 across ten brand safety threat types on held-out data.

02

Better and cheaper fallback

On the hard-page benchmark, the decision model scored micro F1 0.59 versus 0.56 for gpt-5-nano, at $0.018 versus $0.42 per 1,000 pages, and 0.38 s versus 10.6 s per page.

03

Injection resistance

With the verification layer in place, 100% of injected pages kept their correct category, compared to 50% for the chat model and 10% for the decision model alone.

04

Stable answers

Reordering the category options changed the decision model's answer on only 0.8% of pages.

05

Low end-to-end cost

$0.023 per 1,000 pages on the evaluation set, where 87% of pages needed the fallback. With a production-like fallback rate of 20%, the projected cost is below $0.01 per 1,000 pages.

06

Resilient fallback path

Decision model calls are retried on transient failures, a page that still fails keeps its local result instead of being dropped, and the previous chat-model path remains available as a rollback.

07

Planning numbers for 100M pages

about 200 GB of cache storage and a realistic starting budget of roughly $800 per month for storage, lookup capacity, and background enrichment.

Conclusion

By combining fast local models with a targeted, well-gated use of a third-party decision model, Postindustria delivered a contextual enrichment platform that is accurate, measurable, and inexpensive to run at bidstream scale. The cascade design keeps the expensive path for the pages that need it, and the verification layer turns components the platform already has into a defense against manipulated content.

Key Takeaways:

  • Cascade over brute force: Cheap models on every page, a decision model only where it adds value.
  • Measure everything: Datasets, metrics, cost records, and automated gates back every claim in this platform.
  • Reuse before you add: The prompt injection defense came from verification built on existing signals, not from a new model.
  • Ready to grow: The same pipeline extends to mobile inventory and new signals without changes to the architecture.