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.

Implementation status

  • The Topics API has completed the public discussion phase and is currently available to 99 percent of users, scaling up to 100 percent.
  • 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.

  1. From the Classifier tab of the chrome://topics-internals page get the directory path for the .tflite file 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.

    chrome://topics-internals page with Classifier panel selected and tflite file path highlighted.

  2. Open the Colab and click on the folder icon.

    Topics API Colab.

  3. Click the Upload icon and upload model.tflite and override_list.pb.gz from your computer to the Colab.

    Topics API Colab file upload.

  4. You can then run all the Colab steps, by selecting Run all from the Runtime menu.

    Topics API Colab page, 'Run all' selected form the Runtime menu.

This does the following:

  1. Installs the Python packages used by the Colab.
  2. Installs the tflite libraries and the Topics taxonomy.
  3. Defines the taxonomy.
  4. 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.

Next steps

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