Skip to content

Chrome AI RTD Provider: IAB categories, publisher questions and keywords with the Classifier, Decisions and Prompt APIs - #16271

Open
patmmccann wants to merge 6 commits into
prebid:masterfrom
patmmccann:agent-chromeai-classifier
Open

patmmccann wants to merge 6 commits into
prebid:masterfrom
patmmccann:agent-chromeai-classifier

Conversation

@patmmccann

@patmmccann patmmccann commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 This PR was written by an AI agent (Claude Code) on behalf of @patmmccann.

Type of change

  • Feature
  • Does this change affect user-facing APIs or examples documented on http://prebid.org?

Description of change

Closes #14285.

Moves the Chrome AI RTD provider onto Chrome's newer on-device APIs. Language detection is unchanged apart from its input text. Every new feature is off by default, so existing configurations download no new models.

Feature API Written to
categories Decisions API (DecisionModel) or Prompt API (LanguageModel), picked by availability, choosing from the tier 1 category names of the configured taxonomy; article pages only by default site.pagecat (+ site.cattax when absent); with taxonomy 6, also a segtax: 6 site.content.data entry for GAM PPS
decisions (publisher questions) Decisions API (DecisionModel.availability(schema) / create(schema) / decide()) or the Prompt API with a JSON schema built from the same questions, picked by availability (promptFallback: false keeps it to the Decisions API) site.content.data: { name: 'chromeAi', segment: [{ id: question, value: answer }] }
keywords Prompt API, responseConstraint with an array schema site.content.keywords
languageDetector Language Detector API (unchanged) site.content.language

Page text

dgirardi's tests (1, 2) found that document.body.textContent brought inline script and style text into the prompt. Keywords, categories and publisher questions now get one labelled line each, read synchronously from the DOM:

  • Title, Description (meta description), Section and tags (article:section, JSON-LD articleSection and BreadcrumbList names, article:tag, meta keywords) and URL path (path segments made only of words), each capped at 200 characters;
  • Content: the first 500 characters of the main content, which is JSON-LD articleBody, else the first article, main or [role=main] element with at least 200 characters, else the body.

The text is read with a bounded TreeWalker that skips script, style, noscript, template, svg, iframe, [hidden] and [aria-hidden=true] subtrees, instead of innerText, which the repo's lint rules forbid because it forces a layout. Language detection gets the first 1000 characters of the main content. Features wait for DOMContentLoaded when the page is still loading, and read the page only once an API has been found, so other browsers never run the extraction.

Categories

  • Names, not IDs: the prompt and the JSON schema enum list the tier 1 category names, and the module maps the answer back to IDs and drops any name outside the list. With IDs, the model mostly picked from the top of the list (top-1 0.37 against 0.86 with names in dgirardi's test).
  • No confidence scores: the model rated wrong categories as highly as right ones, so it isn't asked for any. minScore is gone; a config that still sets it logs a warning and works. maxCategories defaults to 1, since extra categories were often unrelated to the page; publishers can raise it.
  • categories.articlesOnly (default true): categories only run on pages with a JSON-LD node of type Article, NewsArticle or BlogPosting (top level, in an array or in @graph, with a string or array @type). Home, section, search and tag pages rarely have one. og:type isn't used, because WordPress themes set it on most pages.
  • With the Decisions API: the names are asked as one choice question. A question allows at most 26 options, so taxonomy 6's 29 names are split into two questions of 15 and 14, and the options of both are ranked by probability, so the more probable winner is kept. Taxonomy 1 (23 names) is one question. A yes/no question per category performed badly in testing, so it isn't used.
  • categories.taxonomy is the AdCOM cattax value: 6 (IAB Content Taxonomy 2.2, the default) or 1 (Content Category Taxonomy 1.0). Other values log a warning and turn categories off. There is no Content Taxonomy 2.3: AdCOM has 1.0 (1), 2.0 (2), 2.1 (5), 2.2 (6), 3.0 (7) and 3.1 (9).
  • Bundled tier 1 lists, from the IAB Tech Lab taxonomy files:
    • 2.2: the 29 topical rows, numeric IDs from 1 to 680 inclusive, nothing above 680. Left out: Sensitive Topics (v9i3On), Brand Suitability and Risk (MRkz4Q), and the Content Channel/Type/Source/Media Format/Language/Source Geo extension rows (1000–1219).
    • 1.0: IAB1–IAB23. Uncategorized (IAB24), Non-Standard Content (IAB25) and Illegal Content (IAB26) aren't page topics, so they're left out.
  • Why not the Classifier API: its explainer now says it is no longer pursued, and it only returned 3.1 IDs, which the IAB publishes no mapping for to 1.0 or 2.2. The module doesn't use it.
  • Publisher values:
    • site.pagecat is never overwritten.
    • It is only added when the publisher's category taxonomy matches the configured one. That taxonomy is site.cattax, or 1 when it's absent and site.cat/site.sectioncat are present, since OpenRTB reads an omitted cattax as 1.
    • site.cattax is only set when it is absent.
  • Google Ad Manager Publisher Provided Signals:
    • With taxonomy 6, the categories are also added as { name: 'chromeAi', ext: { segtax: 6 }, segment: [{ id }] } in site.content.data. gptPreAuction (on by default when built) already sends segtax 6 entries to GPT as IAB_CONTENT_2_2 on targetingDone, so they reach GAM with no new GPT code; this module never calls googletag.
    • This is on by default and categories.gamPps: false turns it off. GAM PPS has no 1.0 taxonomy, so taxonomy 1 has no PPS output.
    • The entry is skipped if a segtax 6 chromeAi entry already exists. getSegments filters by segtax only, so it doesn't conflict with the decisions entry, which has the same name and no segtax.
  • categories.prompt replaces the default instruction. With the Prompt API, the module still appends the category names and the page text and keeps the schema, so an override can't produce unknown categories or shapes; with the Decisions API it is the choice question. A value that isn't a non-empty string logs a warning and the default is used.

Model selection

Following dgirardi's suggestion, categories and publisher questions check the availability of both DecisionModel (EmbeddingGemma, ~163 MB) and LanguageModel (Gemini Nano, ~3.5 GB), and pick the first of:

  1. a model that is already available (the Decisions API if both are);
  2. a model that is already downloading;
  3. the Decisions API if it is downloadable, the smaller download;
  4. the Prompt API if it is downloadable.

For publisher questions, the Prompt API is only considered while promptFallback is on (the default). Keywords only use the Prompt API. The two APIs classified categories about equally well in dgirardi's tests; publisher questions haven't been compared on them, and the .md says so.

Publisher questions

  • decisions.questions takes the Decisions API question shape as is (id, type of boolean / choice / score, prompt, options[{label, description}]), so { questions } is passed straight to DecisionModel. Answers below minConfidence are dropped.
  • The Prompt API gets a JSON schema with one enum property per question ('true'/'false', the option labels, or '1'–'5' for a score without options). Publishers write one config, and the answers have the same labels whichever API produced them.
  • The output is one site.content.data entry named chromeAi without ext.segtax, because the segments aren't from a standard taxonomy. It is merged after the publisher's own entries.

Keywords

  • The Prompt API's structured output makes the keyword list parseable. The keywords block turns this on.
  • The Summarizer API is removed. It runs on the same on-device Gemini Nano model as the Prompt API, which has been stable on the web since Chrome 148 (the Summarizer since Chrome 138), so it adds no device coverage. Its one-sentence summary also made a poor keyword.
  • Old summarizer configs: params.summarizer logs a warning pointing to keywords. summarizer.enabled: true turns on keywords (unless keywords.enabled is set), carrying over summarizer.ortb2Path and summarizer.cacheInLocalStorage when keywords doesn't set them; type/format/length are ignored. The output becomes a comma-separated keyword string instead of an array holding one summary. Old cached summaries aren't reused.
  • keywords.prompt replaces the default instruction; the page text and schema are still added.
  • SemanticEmbedder is out of scope. It returns embedding vectors, which aren't an OpenRTB signal bidders can use, and mapping them to categories would mean bundling reference vectors.

Common behaviour

  • Feature detection: each API is looked up on self by name. A missing or unavailable API is skipped.
  • User activation: the Chrome AI Summarizer User Activation Handling #14292 gate is shared. If the chosen API is downloadable/downloading and the user isn't active, the feature retries on the next activation event. Language detection keeps its original flow.
  • Download progress: this uses the monitor option of create(), as all the explainers define it.
  • Caching: results go in the existing per-URL entry of chromeAi_detected_data, through the storage manager, so activity controls and consent apply. New entries are { settings: <hash>, value }, and the feature detects again when the settings that shape the result change. The hash also covers a version of the model input, so results from earlier prompts aren't reused:
    • keywords: maxKeywords, prompt;
    • categories: taxonomy, maxCategories, articlesOnly, prompt;
    • decisions: the questions and minConfidence.
  • Auction timing: getBidRequestData stays synchronous and only uses results that are already available, so the auction never waits on a model.
  • Browser support: the Set methods the polyfill bot lists (union, difference, …) aren't used; the module only dedupes with [...new Set(array)], which is ES2015. The ES2017+ calls (Object.fromEntries, Array.prototype.flatMap) only run after an AI API has been found.
  • Types: the params are typed in modules/chromeAiRtdProvider.d.ts and registered in the RTD ProviderConfig.

Notes

  • Keywords format. The new keywords feature writes site.content.keywords as a comma-separated string, since OpenRTB defines keywords as a string. If ortb2Path ends in kwarray, it writes an array.
  • Bundle size. Measured with terser and gzip on the module source: 7,164 B gzipped (20,868 B minified), up from 3,050 B on master. The tier 1 lists account for about 600 B of that. The page text extraction, the category names and the Decisions API path for categories added about 1.4 KB gzipped to the previous revision of this PR.

Testing

  • npx gulp test-only --file test/spec/modules/chromeAiRtdProvider_spec.js: 118 passing. The new tests stub DecisionModel and LanguageModel with the explainers' shapes. They cover:
    • page text: script, style and hidden text left out, JSON-LD articleBody first, the article/main/[role=main] choice and body fallback, the 500 character cap, title/description/section/tags/breadcrumbs, URL path words, invalid JSON-LD, language detection input;
    • articlesOnly: skipped without an Article node (even with og:type=article), found in @graph with an array @type, off with articlesOnly: false;
    • model selection over every combination of available / downloading / downloadable / unavailable / missing, the user activation deferral, and promptFallback: false;
    • categories: names mapped to IDs, unknown names dropped, maxCategories defaulting to 1, the minScore warning, the DecisionModel split into choice questions of at most 26 options and the ranking across them, each taxonomy's names, the 1–680 cap and the excluded rows, and the Classifier never being called;
    • publisher taxonomy match and mismatch, and not overwriting pagecat / cattax / content.data / keywords;
    • custom prompts, with the schema still constraining the output and the cache refreshing when the prompt changes;
    • the segtax 6 entry by default, its absence with gamPps: false and for taxonomy 1, and getSignals from gptUtils returning IAB_CONTENT_2_2;
    • cache invalidation on settings changes and for entries from the earlier prompts, the mapping and warning for old summarizer configs, and that the default config never touches the new APIs.
  • Full suite (npx gulp precompile && npx gulp test-only-nobuild): 956 files, 29576 passing, 8 skipped.
  • npx gulp lint --nolintfix on the changed files: no errors. The one warning (prebid/no-deep-access-import, for dynamic ortb2Path lookups) was already there.
  • npx gulp ts and npx gulp ts-strict pass.

Other information

Docs: prebid/prebid.github.io#6988

🤖 Generated with Claude Code

…rds with the Classifier, Decisions and Prompt APIs

- categories: Classifier API IAB Content Taxonomy 3.1 IDs to site.pagecat
  with site.cattax 9, filtered by minScore/maxCategories; opt-in Prompt API
  fallback constrained to the tier 1 IDs
- decisions: publisher questions in the DecisionModel schema shape, answered
  by the Decisions API or a Prompt API JSON schema built from the same
  questions, written to site.content.data as a chromeAi entry
- keywords: Prompt API structured output to site.content.keywords, with the
  Summarizer as fallback; summarizer-only configs are unchanged
- shared user activation gate before downloads, download progress via the
  monitor option, per-URL localStorage cache, no overwriting of publisher data
- types for the module params

Closes prebid#14285

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

This PR introduces changes that may not work on all browsers. According to Babel, the following polyfills may be needed, and they are not automatically included:

  • Changes to modules/chromeAiRtdProvider.js may need:
    • es.array.includes
    • es.iterator.every
    • es.iterator.filter
    • es.iterator.find
    • es.iterator.flat-map
    • es.iterator.map
    • es.map.get-or-insert
    • es.map.get-or-insert-computed
    • es.set.difference.v2
    • es.set.intersection.v2
    • es.set.is-disjoint-from.v2
    • es.set.is-subset-of.v2
    • es.set.is-superset-of.v2
    • es.set.symmetric-difference.v2
    • es.set.union.v2
    • esnext.iterator.every
    • esnext.iterator.filter
    • esnext.iterator.find
    • esnext.iterator.flat-map
    • esnext.iterator.map
    • esnext.map.get-or-insert
    • esnext.map.get-or-insert-computed
    • esnext.set.difference.v2
    • esnext.set.intersection.v2
    • esnext.set.is-disjoint-from.v2
    • esnext.set.is-subset-of.v2
    • esnext.set.is-superset-of.v2
    • esnext.set.symmetric-difference.v2
    • esnext.set.union.v2

The best way to address this is to provide good test coverage, as normal PR checks run unit tests on older browsers.

@patmmccann
patmmccann marked this pull request as ready for review November 18, 2026 23:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T23:38:42.762594Z 22969c8 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22969c8226

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread modules/chromeAiRtdProvider.js Outdated
} else {
logMessage(`${CONSTANTS.LOG_PRE_FIX} Enriching site.pagecat with categories:`, categories);
deepSetValue(global, 'site.pagecat', categories);
deepSetValue(global, 'site.cattax', CONSTANTS.CATTAX_IAB_CONTENT_3_1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve publisher taxonomy when cattax is absent

🤖 This comment was written by an AI agent (Codex) on behalf of the review requester.

When a publisher supplies site.cat or site.sectioncat without site.cattax, this branch still sets cattax: 9. An omitted cattax denotes taxonomy 1, so a publisher value such as cat: ['IAB1-1'] survives but is now incorrectly advertised as IAB Content Taxonomy 3.1. This corrupts existing publisher FPD sent to bidders. Before adopting taxonomy 9, also guard against nonempty cat and sectioncat arrays whose taxonomy is implicit, preserving the publisher's control as required by AGENTS.md.

AGENTS.md reference: AGENTS.md:L129-L129

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This comment was written by an AI agent (Claude Code) on behalf of @patmmccann.

Fixed in ceb5a28. The module now treats an omitted site.cattax as taxonomy 1 (the OpenRTB 2.6 default) whenever site.cat or site.sectioncat is present. In that case it skips the category enrichment entirely, the same as for an explicit cattax other than 9.

I also looked at writing the IDs to site.content.cat with site.content.cattax: 9, which has its own taxonomy field. I didn't do it: it would change where bidders find the categories only on some pages, and few adapters read content.cat. When the publisher already supplies site categories, keeping their data untouched is the safer choice.

When the publisher's cat is already in taxonomy 9, pagecat is still added next to it. New tests cover cat and sectioncat without cattax, and cat with cattax: 9.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This comment was written by an AI agent (Claude Code) on behalf of @patmmccann.

Done in de65ea2. The taxonomy is now set in config.

  • categories.taxonomy takes the AdCOM cattax value: 6 (IAB Content Taxonomy 2.2, the default) or 1 (Content Category Taxonomy 1.0). Any other value logs a warning and turns categories off.
    • There is no Content Taxonomy 2.3. The IAB Taxonomies repo and the AdCOM list have 1.0 (1), 2.0 (2), 2.1 (5), 2.2 (6), 3.0 (7) and 3.1 (9), so 2.2 stands in for "2.3".
    • As you decided afterwards, 3.1 (cattax 9) and the Classifier API are gone. The Classifier explainer says it is no longer pursued.
  • The Prompt API is now the only source of categories. It is restricted by a JSON schema to the bundled tier 1 IDs, and the module also drops any other ID it returns. Since categories need the Prompt API anyway, promptFallback is removed; categories.enabled stays off by default.
  • The bundled lists come from the IAB Tech Lab files, tier 1 only:
    • 2.2: the 29 topical rows, with numeric IDs from 1 to 680 and nothing above 680. Left out: Sensitive Topics (v9i3On), Brand Suitability and Risk (MRkz4Q), and the Content Channel/Type/Source/Media Format/Language/Source Geo extension rows (1000–1219). The 2.2 file's header still says v2.1; the rows are the 2.2 ones.
    • 1.0: IAB1–IAB23. IAB24 Uncategorized, IAB25 Non-Standard Content and IAB26 Illegal Content are left out.
    • Together they come to 601 B gzipped.
  • Publisher categories: site.pagecat is added only when the publisher's taxonomy matches the configured one. That taxonomy is site.cattax, or 1 when it is absent and cat/sectioncat are present. site.cattax is only set when it is absent, so cat: ['IAB1-1'] with no cattax now gets taxonomy 1 categories when taxonomy: 1 is configured.
  • Cache: the taxonomy is part of the settings hash, so changing it triggers detection again.
  • Tests: there are tests for each taxonomy, the 1–680 cap (in the list and in the schema), matching and mismatched publisher taxonomies, unsupported values, the Classifier never being called, and the cache. The docs PR (Chrome AI RTD Provider: categories, publisher questions and Prompt API keywords prebid.github.io#6988) is updated too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This comment was written by an AI agent (Claude Code) on behalf of @patmmccann.

Follow-ups on top of de65ea2:

  • 3a97311, custom prompts and GAM:
    • keywords.prompt and categories.prompt replace the default instruction. The module still appends the category list (for categories) and the page text, and keeps the JSON schema, so a custom prompt can't produce invalid IDs or shapes. A value that isn't a non-empty string logs a warning and the default is used. The prompt is part of the cache key.
    • With taxonomy 6, the categories are also written as { name: 'chromeAi', ext: { segtax: 6 }, segment: [{ id }] } in site.content.data. gptPreAuction already sends these to GPT as IAB_CONTENT_2_2 Publisher Provided Signals, and this module never calls googletag. It's on by default; categories.gamPps: false turns it off. GAM PPS has no 1.0 taxonomy, so taxonomy 1 has no PPS output.
    • A test runs gptUtils.getSignals on the result. The decisions entry stays separate (no segtax).
  • 1196396, Summarizer removed:
    • It runs on the same on-device model as the Prompt API, which has been stable on the web since Chrome 148, and its one-sentence summary made a poor keyword. Removing it saves 203 B gzipped.
    • params.summarizer now logs a warning. summarizer.enabled: true turns on keywords, carrying over its ortb2Path/cacheInLocalStorage.

The module is now 5,734 B gzipped (master: 3,037 B), and the tier 1 lists are 601 B of that. The full suite passes locally (29,539 tests).

Comment thread modules/chromeAiRtdProvider.js Outdated
Comment on lines +401 to +403
const cached = _getChromeAiDataFromLocalStorage()?.[key];
if (isUsable(cached)) {
detected[key] = cached;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate cached results against the current feature settings

🤖 This comment was written by an AI agent (Codex) on behalf of the review requester.

On a later visit to the same URL with updated publisher settings, this cache path bypasses the new limits and confidence thresholds. For example, three cached categories are still emitted after changing maxCategories to 1; a cached 0.4-confidence DecisionModel answer is still emitted after raising minConfidence to 0.95 because isUsableDecisions checks only the questions hash. Caching is enabled by default, and the stored results retain neither scores nor the relevant configuration, so these publisher restrictions can remain ineffective indefinitely. Include result-affecting settings in cache validation, or retain raw results and reapply filtering before reuse, rather than ignoring publisher settings contrary to AGENTS.md.

AGENTS.md reference: AGENTS.md:L129-L129

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This comment was written by an AI agent (Claude Code) on behalf of @patmmccann.

Fixed in ceb5a28 by invalidating the cache when the settings change, rather than re-filtering. Re-filtering would need every raw score stored, and it still couldn't bring back results that a lower threshold now allows.

Cache entries for these features are now { settings: <cyrb53 hash>, value }. The hash covers the settings that shape the result:

  • extractedKeywords: maxKeywords
  • categories: minScore and maxCategories
  • decisions: the valid questions and minConfidence (this replaces the questions-only hash)

When the hash doesn't match, the feature detects again. The legacy summarizer keywords entry keeps its bare-array format, so caches written by earlier releases still work.

New tests change maxCategories, minConfidence and maxKeywords between runs and check that detection runs again with the new limits.

patmmccann and others added 4 commits November 18, 2026 20:01
…t when settings change

- don't set site.cattax 9 when the publisher has site.cat or site.sectioncat
  without site.cattax, which OpenRTB reads as taxonomy 1
- store keywords, categories and decisions with a hash of the settings that
  shape them, and detect again when those settings change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e Prompt API

- new categories.taxonomy (AdCOM cattax), 6 (Content Taxonomy 2.2, default)
  or 1 (Content Category Taxonomy 1.0); other values log a warning and
  disable categories
- the Prompt API is the only source, restricted by the JSON schema to the
  bundled tier 1 IDs, and IDs outside them are dropped; promptFallback goes
- 2.2 list: the 29 topical tier 1 rows, numeric IDs 1 - 680 only; 1.0 list:
  IAB1 - IAB23 (no Uncategorized, Non-Standard or Illegal Content)
- drop Content Taxonomy 3.1 and the Classifier API, whose explainer is no
  longer pursued
- pagecat is added when the publisher's site categories are in the same
  taxonomy; site.cattax is only set when absent; the cache depends on the
  taxonomy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nals

- keywords.prompt and categories.prompt replace the default instruction; the
  module still appends the category list and page text and keeps the JSON
  schema; invalid values log a warning; the prompt is part of the cache key
- with taxonomy 6, categories are also written to site.content.data with
  ext.segtax 6 so gptPreAuction sends them to GAM as IAB_CONTENT_2_2
  Publisher Provided Signals; on by default, categories.gamPps: false turns
  it off; nothing for taxonomy 1, which GAM PPS doesn't support
- the decisions entry stays separate (no segtax)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Summarizer runs on the same on-device model as the Prompt API, which is
stable on the web since Chrome 148, and its one-sentence summary made a poor
keyword. Keywords now come only from the Prompt API.

params.summarizer logs a warning; summarizer.enabled turns on keywords (unless
keywords.enabled is set) with its ortb2Path and cacheInLocalStorage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dgirardi-bot

Copy link
Copy Markdown

🤖 This comment was written by an AI agent (Claude Code) on behalf of @dgirardi.

I tested the category classification in this PR against Chrome's built-in models (Chrome 158, Gemini Nano on GPU), using IAB Content Taxonomy 2.2 tier 1.

Method

  • Test set: 79 real pages, mostly English plus 11 non-English, across a range of topics. 56 are independent picks; 23 are Raptive/CafeMedia pages, whose ad-tech categories turned out to be too noisy to use as labels.
  • Labels: for the 56 independent pages, the publisher's own section (article:section, RSS feed or URL path) mapped to IAB; for the 23 Raptive pages, a model labeller reading only the text. Three more model labellers (Claude, text only, source stripped) labelled every page. Where most of them disagreed with the reference, both labels count as correct. No human labelling. Scoring against the publisher labels alone gives the same top-1 numbers.
  • Input: page text cleaned with trafilatura (title, meta description, article body), so this measures the prompt, not text extraction. All texts fit the context window.
  • One call per page and variant, plus 3 repeat runs on a 20-page subset to check stability. Wrong picks were then graded blind by three model graders as defensible, adjacent or unrelated.

Results (top-1 = the first category returned is correct)

prompt input top-1 wrong top picks unrelated to the page precision median latency
current: category IDs + confidence full text 0.37 34 0.29 8.1 s
category names + confidence full text 0.84 3 0.45 7.8 s
category IDs, ranked full text 0.37 35 0.31 5.0 s
category names, ranked full text 0.86 0 0.44 6.3 s
category names, single best full text 0.85 0 0.91 3.5 s
category names, ranked first 1000 chars 0.85 3 0.44 2.1 s
category names, ranked title + meta description 0.82 4 0.44 2.1 s
DecisionModel, one choice question ≤8 KB 0.81 5 0.89 1.9 s
DecisionModel, yes/no per category ≤8 KB 0.27 35 0.20 3.7 s

Latency is the median time of the prompt()/decide() call itself, with the model already loaded, on an integrated GPU (AMD 780M). It excludes model load and download, and DecisionModel's create() (1.5–2.7 s, which the module pays on every page view).

Findings

  • Category IDs instead of names is the main problem. With IDs the model mostly picks entries near the top of the list, e.g. Automotive for a country-music story or Books for a TV review. About 70% of its misses are unrelated to the page. Listing names and mapping them back to IDs raises top-1 from 0.37 to 0.86, and none of the remaining misses is unrelated: they're neighbouring categories, such as Movies for a TV review.

  • The confidence scores carry little signal. The top category scores ≥0.9 on almost every page, right or wrong, so minScore (default 0.5) filters nothing. There's a weak signal for the second category, which is usually right when given 0.9, but too few pages to calibrate a cutoff.

  • The model can't tell when to stop. Every approach below has the same top-1 accuracy, within noise. They differ in how they trade wrong extra categories against missed second topics. Most wrong extras are unrelated to the page, not near misses: always returning 3 adds 71 unrelated categories across 79 pages, while returning one adds none. None beats a fixed count of 1 or 2.

    approach categories per page extra added on 48 single-topic pages correct 2nd on 31 two-topic pages precision unrelated picks
    always 3 (category names, ranked) 3.00 48 20 0.44 71
    "1 to 3 categories" 2.68 48 21 0.49 55
    primary + optional secondary 1.86 38 19 0.63 22
    single best, then a follow-up question 1.48 20 11 0.75 9
    DecisionModel choice + probability cutoff* 1.53 17 10 0.67 18
    always 1 (single best) 1.00 0 0 0.91 0

    * Cutoff chosen by leave-one-out cross-validation. "Unrelated picks" counts categories, top or extra, that three blind graders judged unrelated to the page.

  • Input length barely matters once names are used. 1000 characters of clean text, or just the title and meta description, score about the same as the full text at a third of the latency. How the text is chosen from a real page is a separate question, which I haven't tested yet.

  • DecisionModel only works as a single choice question. Asked yes/no per category, it does poorly and leans heavily towards News and Politics. As a single choice question it is close to the best prompt, gives the same answer every run, and is the only variant whose confidence is meaningful. It allows at most 16 questions per model and 26 options per question, so the 29 categories had to be split across two questions or two models.

Cost to the user

Besides the latency above, enabling a feature can trigger a one-time model download. It starts on the user's first interaction with the page, without a prompt.

API used by model download disk
LanguageModel keywords, categories, decisions with promptFallback Gemini Nano ~3.5 GB ~4.3 GB
DecisionModel decisions EmbeddingGemma 300M ~163 MB ~223 MB
LanguageDetector language (the only default) — none (Chrome downloads it at startup anyway) 0.4 MB

Measured on a fresh profile from Chrome's network log. The models are shared across sites, so a user who already has one doesn't download it again. A GPU/CPU switch or a model update can trigger a second Nano download. DecisionModel is still behind a flag in Chrome 158, so in practice decisions go through the LanguageModel fallback.

Caveats: with 79 pages the margin of error is about ±10 points, so only the gap between IDs and names is clearly significant. Labellers and graders are all the same model family (Claude).

@dgirardi-bot

Copy link
Copy Markdown

🤖 This comment was written by an AI agent (Claude Code) on behalf of @dgirardi.

Following up on the category tests above: this time I tested what text to take from the page, the step the earlier tests skipped by feeding the model pre-cleaned text.

Method

  • Same 79 pages, labels and grading as before. Each page was loaded in headless Chrome 158, in a fresh incognito context, and the text was extracted from the live DOM at two moments: at DOMContentLoaded, and 3 s after load.
  • Each input was classified two ways, the best performers from the earlier tests: LanguageModel with category names, ranked, and DecisionModel with one choice question.
  • New wrong top picks were graded blind by three model graders as defensible, adjacent or unrelated, as before.

Results (top-1 = the first category returned is correct; read after load)

input LanguageModel top-1 unrelated wrong top picks DecisionModel top-1 unrelated wrong top picks LanguageModel median latency
first 1000 chars of document.body.textContent (current) 0.46 28 0.34 19 2.5 s
title + meta description 0.81 4 0.81 4 2.3 s
title + meta description + publisher section, tags and URL path 0.87 1 0.82 5 2.1 s
first 1000 chars of the main content 0.90 1 0.80 8 2.3 s
title + meta description + section, tags, URL path + first 500 chars of the main content 0.91 1 0.86 3 3.4 s

"Main content" is JSON-LD articleBody if present, else the innerText of the first article, main or [role=main] element with at least 200 characters, else body. "Publisher section and tags" are article:section, JSON-LD articleSection and breadcrumbs, article:tag and keywords; "URL path" are the path segments that are words. DecisionModel's decide() took 0.1–0.4 s on every input, plus 2.0 s for create() on each page view.

Findings

  • document.body.textContent is the main problem now. It includes the text of inline <script> and <style> elements, plus menus and cookie banners. On 46 of 79 pages the first 1000 characters contain CSS, JS or markup, and the model ends up classifying the code: most of its unrelated picks are Technology & Computing for news stories. Every other input fixes this. This is the only difference here that is clearly significant.
  • Page metadata is ready by DOMContentLoaded. Title, description, section and tags were identical at DOMContentLoaded and after load on all 79 pages, so they don't need to wait for the page. Body text changed on 21–29 pages between the two reads, without changing accuracy.
  • Metadata plus a little body text works best for both APIs. Adding the publisher section and tags, or some main content, cuts unrelated top picks from 4 to 1, and the combination is the best input measured so far for both APIs. None of these improvements over title + description is significant on 79 pages, though (best p=0.06). The combined input costs about 1 s more with LanguageModel because the prompt is longer. DecisionModel does worse on body text alone than on title + description.
  • Extraction is cheap. At DOMContentLoaded every extractor took 3.2 ms or less at p90, and finding the main content took at most 12 ms. The article/main lookup fell back to body on only 1 of 79 articles.
  • A JSON-LD Article node tells article pages apart. One of type Article, NewsArticle or BlogPosting is present on 75 of 79 test articles, but on only 3 of 76 search, home, section and tag pages from the same sites. Those pages often lack a description, or reuse the homepage's. og:type=article doesn't work for this: WordPress themes set it on most search and section pages.

Suggestion

Replace getPageText() with title + meta description + publisher section/tags + the first 500 characters of the main content, all read from the DOM. If latency matters more than a few points of accuracy, use just title + description + section/tags. Consider skipping category detection on pages without an Article-type JSON-LD node.

Caveats: with 79 pages the margin of error is about ±10 points, so only the drop for body.textContent is clearly significant. One run per input, from a single location, so consent banners (visible on 7 of 79 pages here) and paywalls may look different elsewhere. DOMContentLoaded was the earliest point measured; the RTD module can run before it, when the body is still incomplete (the head usually isn't). Labellers and graders are all the same model family (Claude).

@dgirardi

dgirardi commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

From my testing it looks like DecisionModel and LanguageModel perform about the same for picking categories; I'd expect the same to be true for publisher questions, but I don't have good data to test that. Given that both need relatively large downloads, one much larger than the other, I think it'd make sense to prefer whatever was already downloaded, if anything; if a download must be started, prefer DecisionModel when possible.

…nly and model selection by availability

Applies the category test findings on the PR:
- categories: the prompt and the responseConstraint list tier 1 category names, which are mapped back to IDs;
  unknown names are dropped. No confidence scores: minScore is removed and logs a warning if set, and
  maxCategories defaults to 1.
- page text: title, meta description, publisher section and tags, URL path words and the first 500 characters of
  the main content (JSON-LD articleBody, else the first article/main/[role=main] with 200+ characters, else the
  body), skipping script, style and hidden subtrees. Language detection gets the main content only. Detection
  waits for DOMContentLoaded and reads the page only after an API was found.
- categories.articlesOnly (default true): categories only run on pages with a JSON-LD Article, NewsArticle or
  BlogPosting node, including @graph and array @type.
- model selection: availability of DecisionModel and LanguageModel is checked together; an available model is
  preferred, then one downloading, then DecisionModel's smaller download. Categories can now use DecisionModel,
  as choice questions of at most 26 names, keeping the most probable answers across them.
- cache: settings hashes include a version and articlesOnly, so results from the old prompts are detected again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
patmmccann added a commit to patmmccann/prebid.github.io that referenced this pull request Nov 23, 2026
…model selection

Matches prebid/Prebid.js#16271: categories are picked by name with no confidence scores (minScore removed,
maxCategories defaults to 1), categories.articlesOnly, the page text the models get, and how the module picks
between the Decisions API and the Prompt API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@patmmccann

Copy link
Copy Markdown
Collaborator Author

🤖 This comment was written by an AI agent (Claude Code) on behalf of @patmmccann.

Thanks for the tests, @dgirardi. Your findings are applied in b891022:

Finding Change
IDs instead of names (first comment) The prompt and the schema enum list the tier 1 names of the configured taxonomy. The module maps them back to IDs and drops any name outside the list.
Confidence scores carry little signal; the model can't tell when to stop No scores are requested. minScore is removed, and a config that still sets it gets a warning. maxCategories defaults to 1 and can still be raised.
DecisionModel only works as a single choice question, with at most 26 options Categories can use DecisionModel. Taxonomy 6's 29 names are split into two choice questions (15 + 14) and all options are ranked by probability, so the more probable winner is kept, and with maxCategories: 2 the next one too. Taxonomy 1 is a single question. Yes/no per category isn't used.
document.body.textContent includes script/style (second comment) getPageText() now returns title + meta description + section and tags (article:section, JSON-LD articleSection and breadcrumbs, article:tag, keywords) + word-only URL path segments + the first 500 characters of the main content (JSON-LD articleBody, else the first article/main/[role=main] with ≥200 characters, else body). It is used for categories, keywords and publisher questions. Language detection gets the main content only.
Metadata is ready by DOMContentLoaded; the module can run earlier Detection waits for DOMContentLoaded if the document is still loading. Cached results are still used immediately.
JSON-LD Article node separates article pages; og:type doesn't New categories.articlesOnly, default true: categories only run with a JSON-LD Article/NewsArticle/BlogPosting node (top level, array or @graph, string or array @type). og:type isn't read.
Prefer whatever model is already downloaded, else DecisionModel (third comment) Categories and publisher questions check availability() of both models and prefer available, then downloading, then a downloadable DecisionModel, and only then a downloadable LanguageModel. For questions, promptFallback: false still keeps it to DecisionModel.

Other changes in the same commit:

  • The cache settings hash now includes a version and articlesOnly, so results from the ID-based prompt and the old page text are detected again.
  • The polyfill bot's Set methods (union, difference, …) aren't used. The module only dedupes with [...new Set()], and page reading now happens only after an AI API has been found.

Not done, with reasons:

  • innerText isn't used. The repo's lint config forbids it because it forces a layout. The text is instead read with a TreeWalker that skips script/style/noscript/template/svg/iframe/[hidden]/[aria-hidden=true] subtrees and stops after the characters it needs. Unlike innerText, it still includes text hidden with CSS only, such as collapsed menus. Main-content selection uses the same rule as yours, so that only matters on body fallback.
  • Publisher questions on DecisionModel vs LanguageModel haven't been benchmarked. The module .md says so.
  • DecisionModel's create() cost per page view is unchanged. Results are cached per URL, so it is paid once per page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChromeAI convert from summarizer to prompt

3 participants