Discover the Power of Gemini Nano: The On-Device AI Model running in Chrome 127+
Tags: ai, machinelearning, gemini, webdev
Published: 2024-07-08 12:56:12

Have you imagined having a powerful, on-device AI model at your fingertips, seamlessly integrated within your favorite browser (if that is Chrome, of course, lol)? Today, we're diving into the new Gemini Nano model from Google, the game-changer that's setting new standards in AI technology. Read the article to understand more about Gemini Nano and find the link to the demo app as well.

## So, What is Gemini Nano?

It's an on-device AI model that runs directly on Chrome 127 and above. At the time of writing this article, it is available in the [Chrome Dev](https://www.google.com/chrome/dev/) and [Chrome Canary](https://www.google.com/chrome/canary/) channels for version 127+. This means Gemini Nano is embedded in the browser, which means no cloud dependency, ultra-fast processing, and enhanced privacy – all while delivering top-notch performance!

## Key Features of Gemini Nano

**Speed:**
Gemini Nano leverages the latest advancements in AI to deliver lightning-fast responses. No more waiting for cloud servers – everything is processed locally on your device.

**Privacy:**
Since all data processing happens on your device, your information stays with you. This is a massive step forward in ensuring your personal data is secure. I love how this would make us privacy nerds happy 💟

**Compatibility:**
Gemini Nano is optimized for Chrome 127 and above, ensuring smooth integration and the best possible performance.

But don't just take my word for it. Below is a quick demo built with React. It uses a textbox and speech recognition to take input from the user and passes it to Gemini Nano to translate something from a source to a target language.

{% embed https://www.instagram.com/p/C9GalMKtVof/ %}

Links:
🚀 [Demo](https://ahsanayaz.github.io/zubaan-gemini-nano/)
🧑🏽‍💻 [Code](https://github.com/AhsanAyaz/zubaan-gemini-nano)

## How to use Gemini Nano today?

Let's talk about how you can try out Gemini Nano today. 

First, install Chrome from either [stable](https://www.google.com/chrome/), [dev](https://www.google.com/chrome/dev/) or [canary](https://www.google.com/chrome/canary/) channels and make sure you have version 127 or above.

Then enable the flag named `prompt-api-for-gemini-nano` by going to `chrome://flags/#prompt-api-for-gemini-nano` and set it to `Enabled`
![Prompt api for gemini nano chrome flag](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/keiwdu63osnwc9rvmce7.png)

Now, enable another flag named `optimization-guide-on-device-model` by navigating to `chrome://flags/#optimization-guide-on-device-model` and setting it to `Enabled BypassPerfRequirement`.
![Optimization guide on device model chrome flag](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvl2qam0gug8kpvdzdks.png)

Finally, go to `chrome://components` and search for `Optimization Guide On Device Model`. Click the `Check for update` button to download the model.

![chrome component to download the model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ejg3xrkff51gov15vag2.png)

> Note: It is possible that the above component might not show up for you. In that case, open the DevTools, navigate to console, and type `await ai.canCreateTextSession();` and hit Enter. It should look as follows:

![Trying out gemini on console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ylbjrtezcjuk2i91e1j7.png)

## How to interact with Gemini Nano?
From the DevTools, just type the following code in the console:
```js
const session = await ai.createTextSession();
await session.prompt(`If a train takes 3 hours 
from karachi to hyderabad, and 7 hours from 
hyderabad to lahore, what is the average size 
of an ostrich's egg?`);
```
Do share Gemini Nano's answer in the comments 😄

## Conclusion
Gemini Nano is probably one of the coolest things I've worked recently with. It just opens up so many possibilities. I can't wait to see AI on-device getting more accurate, lighter, and faster.

Thanks for reading! Don't forget to react & share the article, and follow for more exciting tech content. Let me know in the comments what you think about Gemini Nano and how it's transforming your browser experience. Until next time, happy coding!