Slide 1

Slide 1 text

Generative AI to your Android with Gemini API Sherbrooke Eric Ampire

Slide 2

Slide 2 text

About me

Slide 3

Slide 3 text

About me Mobile Engineer at Bombardier Recreational Products (BRP) - Google Developer Expert for Android

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Want to reach out Scan the QR Code

Slide 6

Slide 6 text

What’s Gemini ? Montréal

Slide 7

Slide 7 text

Montréal A family of multimodal large language models developed by Google DeepMind and Google Research

Slide 8

Slide 8 text

Gemini is multi-modal Large Language Model

Slide 9

Slide 9 text

Gemini is multi-modal Large Language Model

Slide 10

Slide 10 text

(Android AICore)

Slide 11

Slide 11 text

Gemini Nano

Slide 12

Slide 12 text

Gemini Nano Most efficient model for on-device tasks

Slide 13

Slide 13 text

Gemini Pro

Slide 14

Slide 14 text

Gemini Pro Best model for scaling across a wide range of tasks

Slide 15

Slide 15 text

Gemini Ultra

Slide 16

Slide 16 text

Gemini Ultra Largest and most capable model for highly complex tasks.

Slide 17

Slide 17 text

Potential Applications

Slide 18

Slide 18 text

Potential Applications ● Education : Personalized learning experiences, interactive tutoring knowledge.

Slide 19

Slide 19 text

Potential Applications ● Education : Personalized learning experiences, interactive tutoring knowledge. ● Healthcare: Assisting doctors, analyzing medical data, and enhancing coms.

Slide 20

Slide 20 text

Potential Applications ● Education : Personalized learning experiences, interactive tutoring knowledge. ● Healthcare: Assisting doctors, analyzing medical data, and enhancing coms. ● Customer service : Personalized interactions, resolving complex queries, and improving customer satisfaction.

Slide 21

Slide 21 text

Montréal Gemini Nano

Slide 22

Slide 22 text

Montréal AI Core

Slide 23

Slide 23 text

AI Core ● Android AICore, a new system service for on-device foundation models starting from Android 14

Slide 24

Slide 24 text

AI Core ● Android AICore, a new system service for on-device foundation models starting from Android 14 ● AICore enables Low Rank Adaptation (LoRA) fine tuning with Gemini Nano.

Slide 25

Slide 25 text

AI Core ● Android AICore, a new system service for on-device foundation models starting from Android 14 ● AICore enables Low Rank Adaptation (LoRA) fine tuning with Gemini Nano. ● AICore takes advantage of new ML hardware like the latest Google Tensor TPU and NPUs in flagship Qualcomm Technologies, Samsung S.LSI and MediaTek silicon

Slide 26

Slide 26 text

Architecture

Slide 27

Slide 27 text

Privacy: your data is not sent to a remote server Advantage

Slide 28

Slide 28 text

Privacy: your data is not sent to a remote server Fast, everything is process On-Device Advantage

Slide 29

Slide 29 text

Privacy: your data is not sent to a remote server Fast, everything is process On-Device Indirect Internet Access Advantage

Slide 30

Slide 30 text

Privacy: your data is not sent to a remote server Fast, everything is process On-Device Indirect Internet Access Advantage AICore does not have direct internet access. All internet requests, including model downloads, are routed through the open-source Private Compute Services

Slide 31

Slide 31 text

What is Private Compute Core ● Android’s Private Compute Core is an open source, secure environment that is isolated from the rest of the operating system and apps

Slide 32

Slide 32 text

What is Private Compute Core ● Android’s Private Compute Core is an open source, secure environment that is isolated from the rest of the operating system and apps ● Introduced with Android 12, It is a secure environment that isolates sensitive data to perform private computations while ensuring that this data never leaves the device

Slide 33

Slide 33 text

Private Compute Core - Limited data access ● The Private Compute Core is completely isolated from the rest of the system and from third-party applications, which means that not even Google has access to the data. Only local machine learning APIs, which are strictly controlled, can interact with private data.

Slide 34

Slide 34 text

Private Compute Core - Indirect Internet Access ● AICore does not have direct internet access. All internet requests, including model downloads, are routed through the open-source Private Compute Services companion APK

Slide 35

Slide 35 text

Private Compute Core - Indirect Internet Access ● AICore does not have direct internet access. All internet requests, including model downloads, are routed through the open-source Private Compute Services companion APK ● Learn more : bit.ly/private-compute

Slide 36

Slide 36 text

Text Rephrasing: Modify the tone and style of text Use cases

Slide 37

Slide 37 text

Text Rephrasing: Modify the tone and style of text Smart Reply: Generate relevant responses within a chat Use cases

Slide 38

Slide 38 text

Text Rephrasing: Modify the tone and style of text Smart Reply: Generate relevant responses within a chat Proofreading: Correct spelling and grammatical errors. Use cases

Slide 39

Slide 39 text

Text Rephrasing: Modify the tone and style of text Smart Reply: Generate relevant responses within a chat Proofreading: Correct spelling and grammatical errors. Condense lengthy documents into concise summaries Use cases

Slide 40

Slide 40 text

Use cases - Recorder app

Slide 41

Slide 41 text

Use cases - Smart Reply in Gboard

Slide 42

Slide 42 text

Montréal Gemini Nano is currently in Private Preview

Slide 43

Slide 43 text

Gemini Nano is currently in Private Preview ● Supported Devices: AICore is currently available on Pixel 9 series devices, Google Pixel 8 Series devices, Samsung S24 Series devices, Realme GT 6, Motorola Edge 50 Ultra, Motorola Razr 50 Ultra, Xiaomi 14T/Pro, and Xiaomi MIX Flip

Slide 44

Slide 44 text

Gemini Nano is currently in Private Preview ● Supported Devices: AICore is currently available on Pixel 9 series devices, Google Pixel 8 Series devices, Samsung S24 Series devices, Realme GT 6, Motorola Edge 50 Ultra, Motorola Razr 50 Ultra, Xiaomi 14T/Pro, and Xiaomi MIX Flip ● Supported Modalities: AICore currently supports text modality for Gemini Nano

Slide 45

Slide 45 text

Montréal Getting started with the Gemini API

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

This is an example of a Cloud-specific section title slide.

Slide 48

Slide 48 text

This is an example of a Cloud-specific section title slide.

Slide 49

Slide 49 text

This is an example of a Cloud-specific section title slide.

Slide 50

Slide 50 text

This is an example of a Cloud-specific section title slide.

Slide 51

Slide 51 text

This is an example of a Cloud-specific section title slide.

Slide 52

Slide 52 text

This is an example of a Cloud-specific section title slide.

Slide 53

Slide 53 text

Montréal Getting started with the Gemini API in Android

Slide 54

Slide 54 text

Add the SDK dependency to your project dependencies { // add the dependency for the Google AI client SDK for Android implementation("com.google.ai.client.generativeai:generativeai:0.7.0") }

Slide 55

Slide 55 text

Initialized the Generative Model val model = GenerativeModel( // Specify a Gemini model appropriate for your use case modelName = "gemini-1.5-flash", // Access your API key as a Build Configuration variable apiKey = "gemini-key" )

Slide 56

Slide 56 text

Initialized the Generative Model with More settings val generationConfig = generationConfig { temperature = 0.15f topK = 32 topP = 1f maxOutputTokens = 4096 }

Slide 57

Slide 57 text

Initialized the Generative Model with More settings val safetySettings = listOf( SafetySetting( HarmCategory.HARASSMENT, BlockThreshold.MEDIUM_AND_ABOVE ), SafetySetting( HarmCategory.HATE_SPEECH, BlockThreshold.MEDIUM_AND_ABOVE ) )

Slide 58

Slide 58 text

Initialized the Generative Model with More settings val model = GenerativeModel( model = "gemini-1.5-flash-001", apiKey = "gemini-key", generationConfig = generationConfig, safetySettings = safetySettings )

Slide 59

Slide 59 text

Initialized the Generative Model val model = GenerativeModel( model = "gemini-1.5-flash-001", apiKey = "gemini-key", generationConfig = generationConfig, safetySettings = safetySettings )

Slide 60

Slide 60 text

Write your first prompt val prompt = "Write a story about a magic backpack." coroutineScope.launch { val response = model.generateContent(prompt) }

Slide 61

Slide 61 text

Generate text from images and other media coroutineScope.launch { val response = model.generateContent( content { image(bitmap) text("What is the object in this picture?") } ) }

Slide 62

Slide 62 text

Multi-turn chat You can also support multi-turn conversations. Initialize a chat with the startChat() function. You can optionally provide a message history. Then call the sendMessage() function to send chat messages.

Slide 63

Slide 63 text

Multi-turn chat val chat = model.startChat( history = listOf( content(role = "user") { text("Hello, I have 2 dogs in my house.") }, content(role = "model") { text("What would you like to know?") } ) ) coroutineScope.launch { val response = chat.sendMessage("How many paws are in my house?") }

Slide 64

Slide 64 text

Stream the response You can achieve faster interactions by not waiting for the entire result from the model generation, and instead use streaming to handle partial results. Use generateContentStream() to stream a response.

Slide 65

Slide 65 text

Stream the response coroutineScope.launch { var outputContent = "" model.generateContentStream(inputContent).collect { response -> outputContent += response.text } }

Slide 66

Slide 66 text

Demo Montréal

Slide 67

Slide 67 text

Summary Gemini is a family of multimodal large language models developed by Google DeepMind and Google Research

Slide 68

Slide 68 text

Code Sherbrooke

Slide 69

Slide 69 text

Thanks Sherbrooke