Test topic inference in a colab
Try the colab to learn how to load the TensorFlow Lite model used by Chrome to infer topics from hostnames.
- The Topics API proposal has completed the public discussion phase and is currently available in an origin trial. The API is now approaching launch for scaled adoption.
- To provide your feedback on the Topics API, create an Issue on the Topics explainer or participate in discussions in the Improving Web Advertising Business Group. The explainer has a number of open questions that still require further definition.
- The Privacy Sandbox timeline provides implementation timelines for the Topics API and other Privacy Sandbox proposals.
- Topics API: latest updates details changes and enhancements to the Topics API and implementations.
Running the colab
A colab—or colaboratory—is a data analysis tool that combines code, output, and descriptive text into one collaborative document. You can run the Topics Model Execution Demo colab to test how the Topics classifier model infers topics of interest to the user, from the hostnames of pages they visit.
From the Classifier tab of the
chrome://topics-internalspage get the directory path for the
.tflitefile used by the Topics API. The override list,
override_list.pb.gz, is available from the
chrome://topics-internals/page under the current model in the Classifier tab.
Open the colab and click on the folder icon.
Click the Upload icon and upload
override_list.pb.gzfrom your computer to the colab.
You can then run all the colab steps, by selecting Run all from the Runtime menu.
This does the following:
- Installs the Python packages used by the colab.
- Installs the
tflitelibraries and the Topics taxonomy.
- Defines the taxonomy.
- Runs each of the Model Execution Demo steps to show how classification works for two example domains.
You'll see a green tick next to each step that completes successfully. (Each step can also be run individually, by clicking the Play button next to it.)
For each of the domains defined, you can see the topic scores inferred by the classifier. Try listing different domains to see how they compare.
For some domains you may notice a difference in topic inference between the colab and the
The colab only uses the classifier model to infer topics, whereas
chrome://topics-internals uses Chrome's Topics implementation. Chrome manually curates list of topics, rather than using the classifier model for the top 10,000 sites. The curated list can be found in
override_list.pb.gz, which is available on
If you're an ad tech developer, experiment and participate with the Topics API, and check out the Topics API demo.
Engage and share feedback
- GitHub: Read the Topics API explainer, and raise questions and follow discussion in issues on the proposal repo.
- W3C: Discuss industry use cases in the Improving Web Advertising Business Group.
- Announcements: Join or view the mailing list.
- Privacy Sandbox developer support: Ask questions and join discussions on the Privacy Sandbox Developer Support repo.
- Chromium: File a Chromium bug to ask questions about the implementation currently available to test in Chrome.