DEV Community

Cover image for Discover the Power of Gemini Nano: The On-Device AI Model running in Chrome 127+
Muhammad Ahsan Ayaz
Muhammad Ahsan Ayaz

Posted on • Updated on

Discover the Power of Gemini Nano: The On-Device AI Model running in Chrome 127+

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 and 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.

Links:
🚀 Demo
🧑🏽‍💻 Code

How to use Gemini Nano today?

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

First, install Chrome from either stable, dev or 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

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

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

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

How to interact with Gemini Nano?

From the DevTools, just type the following code in the console:

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?`);
Enter fullscreen mode Exit fullscreen mode

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!

Top comments (0)