Skip to content

Commit e07a05b

Browse files
patmmccannmuuki88
andauthored
Add Chrome AI RTD Provider documentation (#6174)
* Add Chrome AI RTD Provider documentation * Update dev-docs/modules/chromeAiRtdProvider.md Co-authored-by: Muki Seiler <muuki88@users.noreply.github.com> * Update dev-docs/modules/chromeAiRtdProvider.md Co-authored-by: Muki Seiler <muuki88@users.noreply.github.com> * Update dev-docs/modules/chromeAiRtdProvider.md Co-authored-by: Muki Seiler <muuki88@users.noreply.github.com> * Update dev-docs/modules/chromeAiRtdProvider.md Co-authored-by: Muki Seiler <muuki88@users.noreply.github.com> * Update chromeAiRtdProvider.md * Update chromeAiRtdProvider.md * Update chromeAiRtdProvider.md --------- Co-authored-by: Muki Seiler <muuki88@users.noreply.github.com>
1 parent 69b06a0 commit e07a05b

File tree

1 file changed

+219
-0
lines changed

1 file changed

+219
-0
lines changed
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
---
2+
layout: page_v2
3+
title: Chrome AI RTD Provider
4+
display_name: Chrome AI RTD Provider
5+
description: Use Chrome AI APIs for language detection and summarization.
6+
page_type: module
7+
module_type: rtd
8+
module_code : chromeAiRtdProvider
9+
enable_download : true
10+
sidebarType : 1
11+
---
12+
13+
# Chrome AI RTD Provider
14+
15+
## Overview
16+
17+
The Chrome AI RTD Provider is a Prebid.js Real-Time Data (RTD) module that enhances bidding by leveraging Chrome's built-in AI capabilities. It can automatically detect page language using the [Chrome AI Language Detection API](https://developer.chrome.com/docs/ai/language-detection) and generate page summaries or keywords using the [Chrome AI Summarizer API](https://developer.chrome.com/docs/ai/summarizer-api). This information is added to the OpenRTB bid request objects, allowing bid adapters to optimize bids based on content language and context.
18+
19+
## Features
20+
21+
- Automatic language detection using the Chrome AI Language Detection API.
22+
- Automatic page summarization or keyword generation using the Chrome AI Summarizer API.
23+
- Caching of detected language and summaries/keywords in localStorage to reduce redundant API calls (configurable for summarizer).
24+
- Configurable options for both language detection (e.g., confidence threshold) and summarization (e.g., type, format, length).
25+
- Flexible ORTB2 path configuration for placing detected data.
26+
- Ability to enable/disable each feature independently.
27+
- Compatible with the Prebid.js RTD framework.
28+
29+
## Integration
30+
31+
### Build Setup
32+
33+
To include the Chrome AI RTD Provider in your Prebid.js build, use the following command:
34+
35+
```bash
36+
gulp build --modules=rtdModule,chromeAiRtdProvider
37+
```
38+
39+
### Basic Integration
40+
41+
Add the Chrome AI RTD Provider to your Prebid.js configuration:
42+
43+
```javascript
44+
pbjs.setConfig({
45+
realTimeData: {
46+
dataProviders: [{
47+
name: 'chromeAi',
48+
waitForIt: true // Optional: delays the auction until language detection completes
49+
}]
50+
}
51+
});
52+
```
53+
54+
### Advanced Configuration
55+
56+
Configure language detection and summarization with additional options:
57+
58+
```javascript
59+
pbjs.setConfig({
60+
realTimeData: {
61+
dataProviders: [{
62+
name: 'chromeAi',
63+
waitForIt: true, // Set to true if auction should wait for both enabled features
64+
params: {
65+
languageDetector: {
66+
enabled: true, // Set to false to disable language detection
67+
confidence: 0.9, // Set minimum confidence threshold (0.0 - 1.0)
68+
ortb2Path: 'site.content.language' // Default path for language
69+
},
70+
summarizer: {
71+
enabled: false, // Set to true to enable summarization/keyword generation
72+
type: 'headline', // 'headline','key-points', 'tldr' or 'teaser'
73+
format: 'markdown', // 'plain-text' or 'markdown'
74+
length: 'short', // 'short', 'medium', or 'long'
75+
ortb2Path: 'site.content.keywords', // Path for summary/keywords
76+
cacheInLocalStorage: true // Whether to cache generated summary/keywords
77+
}
78+
}
79+
}]
80+
}
81+
});
82+
```
83+
84+
## Configuration Options
85+
86+
{: .table .table-bordered .table-striped }
87+
| Parameter | Scope | Type | Description | Default |
88+
|-----------|-------|------|-------------|---------|
89+
| `waitForIt` | Optional | Boolean | Whether to delay auction for data retrieval | `false` |
90+
| `languageDetector.enabled` | Optional | Boolean | Enable or disable language detection | `true` |
91+
| `languageDetector.confidence` | Optional | Number | Minimum confidence threshold for detected language (0.0 - 1.0) | `0.8` |
92+
| `languageDetector.ortb2Path` | Optional | String | Path in ORTB2 to store the detected language | `'site.content.language'` |
93+
| `summarizer.enabled` | Optional | Boolean | Enable or disable summarization/keyword generation | `false` |
94+
| `summarizer.type` | Optional | String | Type of summary: `'headline'`, `'key-points'`, `'tldr'`, or `'teaser'` | `'headline'` |
95+
| `summarizer.format` | Optional | String | Format of the summary: `'plain-text'` or `'markdown'` | `'mark-down'` |
96+
| `summarizer.length` | Optional | String | Length of the summary: `'short'`, `'medium'`, or `'long'` | `'short'` |
97+
| `summarizer.ortb2Path` | Optional | String | Path in ORTB2 to store the generated summary/keywords | `'site.content.keywords'` |
98+
| `summarizer.cacheInLocalStorage` | Optional | Boolean | Whether to cache the generated summary/keywords in localStorage | `true` |
99+
100+
## How It Works
101+
102+
The module initializes configured features (language detection, summarization) asynchronously.
103+
104+
### Language Detection (`languageDetector`)
105+
106+
1. **Data Prioritization**: On initialization or when `getBidRequestData` is called, the module first checks for existing language information in this order:
107+
- Auction-specific ORTB2 data (from `reqBidsConfigObj` passed to `getBidRequestData`).
108+
- Data cached in localStorage for the current page URL (from a previous detection).
109+
2. **API Call**: If no language is found and the feature is enabled, it attempts to detect the language of the visible page content using the Chrome AI Language Detection API.
110+
- The API's `availability()` method is checked. If 'unavailable', detection is skipped. If 'after-download', the module may proceed if the model downloads.
111+
3. **Data Handling**: The detected language (if it meets the confidence threshold) is:
112+
- Stored in localStorage for future page loads on the same URL.
113+
- Added to the OpenRTB bid requests at the configured `languageDetector.ortb2Path` (default: `site.content.language`).
114+
115+
### Summarization / Keyword Generation (`summarizer`)
116+
117+
1. **Data Prioritization**: Similar to language detection, it checks for existing summary/keywords:
118+
- Auction-specific ORTB2 data.
119+
- Data cached in localStorage (if `cacheInLocalStorage: true`).
120+
2. **API Call**: If no data is found and the feature is enabled, it attempts to generate a summary/keywords from the page content using the Chrome AI Summarizer API.
121+
- The API's `availability()` method is checked. If 'unavailable', summarization is skipped. If 'after-download', the module may proceed.
122+
3. **Data Handling**: The generated summary/keywords are:
123+
- Stored in localStorage (if `cacheInLocalStorage: true`).
124+
- Added to the OpenRTB bid requests at the configured `summarizer.ortb2Path` (default: `site.content.keywords`).
125+
126+
If `waitForIt: true` is set in the RTD config, the auction will be delayed until all enabled and available Chrome AI features complete their processing.
127+
128+
## Browser Compatibility
129+
130+
- The browser must support the Chrome AI APIs being used (Language Detection, Summarizer).
131+
- The specific Chrome AI models (e.g., for language detection or summarization) must be 'available' or become 'available-after-download'. The module handles these states.
132+
- Sufficient text content must be available on the page (minimum 20 characters for language detection and summarization).
133+
- If using the `waitForIt: true` option, consider the potential impact on auction latency.
134+
135+
## Limitations
136+
137+
- Relies on browser support for Chrome AI APIs.
138+
- Requires sufficient and meaningful visible text content on the page for accurate results.
139+
- Language detection may not be accurate for pages with multiple languages mixed together.
140+
- Summarization quality depends on the page content and the capabilities of the underlying Chrome AI model.
141+
142+
## Browser Compatibility
143+
144+
[Language Detector API Support](https://caniuse.com/mdn-api_languagedetector)
145+
## Example Use Cases
146+
147+
### Standard Implementation
148+
149+
```javascript
150+
pbjs.setConfig({
151+
realTimeData: {
152+
dataProviders: [{
153+
name: 'chromeAi',
154+
waitForIt: true
155+
}]
156+
}
157+
});
158+
```
159+
160+
### Disable Language Detection for Specific Sites
161+
162+
```javascript
163+
pbjs.setConfig({
164+
realTimeData: {
165+
dataProviders: [{
166+
name: 'chromeAi',
167+
params: {
168+
languageDetector: {
169+
enabled: false
170+
}
171+
}
172+
}]
173+
}
174+
});
175+
```
176+
177+
### Higher Confidence Requirement for Language Detection
178+
179+
```javascript
180+
pbjs.setConfig({
181+
realTimeData: {
182+
dataProviders: [{
183+
name: 'chromeAi',
184+
waitForIt: true,
185+
params: {
186+
languageDetector: {
187+
enabled: true,
188+
confidence: 0.95 // Only use high-confidence detections
189+
}
190+
}
191+
}]
192+
}
193+
});
194+
```
195+
196+
### Enable Summarizer with Custom Settings
197+
198+
```javascript
199+
pbjs.setConfig({
200+
realTimeData: {
201+
dataProviders: [{
202+
name: 'chromeAi',
203+
waitForIt: true,
204+
params: {
205+
languageDetector: {
206+
enabled: false // Example: only using summarizer
207+
},
208+
summarizer: {
209+
enabled: true,
210+
type: 'teaser',
211+
format: 'markdown', // In markdown format
212+
length: 'medium',
213+
ortb2Path: 'site.ext.data.summary', // Custom ORTB2 path
214+
}
215+
}
216+
}]
217+
}
218+
});
219+
```

0 commit comments

Comments
 (0)