How to Use Built-in Gemini Nano on Chrome

Fırat Yaman | Jul 6, 2024 min read

1. What is Embedded Gemini Nano?

Google’s Gemini Nano is a LLM model for on-device tasks. It is a lightweight AI model which can process images, voice and text. Currently it is being used in some Google products such as Gboard, Talkback and Pixel Recorder.

Chrome recently published a beta version of Chrome which you can experience by installing Chrome Canary version. In this version they added an embedded version of Gemini Nano. It supports on-device AI processing of the webpage content.

I am testing the potential use cases and contribution to the user/customer experience. If you are also interested, you can try by following these steps.

2. Prerequisites

  1. Install Google Chrome Canary from this URL: https://www.google.com/chrome/canary/
  2. Open Google Canary and type chrome://flags to the address bar
  3. Type Prompt API for Gemini Nano to the search bar and set the option as enabled
    enabling gemini nano api
  4. Type optimization-guide-on-device-model to the search bar and set the option as Enabled BypassPerfRequirements.
    (Note: This option is could be set as Enabled if your computer has a Neural Processing Unit (NPU) but I’m not sure.)
    enabling gemini nano api
  5. Restart your Chrome Canary application.
  6. Type chrome://components to the address bar. Find Optimization Guide On Device Model component and click Check for update button. Then wait a few moments for downloading and installation. (Note: if you don’t see Optimization Guide On Device Model option, set your primary Chrome Canary language as “English” from the browser settings)
  7. Now you can try the embedded Gemini Nano on your developer console or creating a HTML page and write the corresponding JS code!
    I tried this feature to summarize my first blog post content http://www.firatyaman.com/posts/my-first-post/
    enabling gemini nano api

3. Example JS code

const model=await http://window.ai.createTextSession();
await model.prompt('Who are you?')