Slide 1

Slide 1 text

Generative AI in practice: Concrete LLM use cases in Java with PaLM & Gemini Guillaume Laforge Developer Advocate @[email protected]

Slide 2

Slide 2 text

Google Cloud Proprietary & Confidential 01 A few notions and vocabulary 2 @[email protected]

Slide 3

Slide 3 text

Google Cloud Artificial Intelligence NLP 3 Artificial Intelligence, Machine Learning, Data Science, Deep Learning… Data Science Machine Learning — unsupervised, supervised, reinforcement learning Deep Learning — ANN, CNN, RNN… Generative AI — GAN, VAE, Transformers… LLMs — Transformers Image Gen — GAN, VAE

Slide 4

Slide 4 text

Google Cloud 4 Google invented the Transformer architecture Responsible AI at the foundation Google invents Transformer kickstarting LLM revolution Google’s groundbreaking large language model, BERT AlphaFold predicts 3D models of protein structures Text-to-Text Transfer Transformer LLM 10B P model open sourced Google LaMDA model trained to converse Google PaLM single model to generalize across domains Google PaLM 2 model is the SOTA LLM PaLM 2

Slide 5

Slide 5 text

https://ig.ft.com/generative-ai/

Slide 6

Slide 6 text

Google Cloud 6 So what are Large Language Models? ● Transformer-based neural network architecture that can recognize, predict, and generate human language ● Trained on huge corpuses of text, in various languages and domains ○ Ex: PaLM 2 learned 340 billion parameters, and trained over 3.6 trillions of tokens ● Learn the statistical relationships between words and phrases, as well as the patterns of human language ● Can be fine-tuned for specific tasks or domain knowledge

Slide 7

Slide 7 text

Google Cloud 7 Language model sizes — March 2023 https://lifearchitect.ai/models/

Slide 8

Slide 8 text

Google Cloud 8 With larger models emerge new capabilities https://blog.research.google/2022/04/pathways-language-model-palm-scaling-to.html

Slide 9

Slide 9 text

Google Cloud Proprietary & Confidential 9 02 What does Google (Cloud) offers? @[email protected]

Slide 10

Slide 10 text

Google Cloud Bard 10 PaLM, Codey, Imagen, MakerSuite, Vertex AI Vertex AI MakerSuite Model Garden Codey Imagen Llama 2, Claude 2, Falcon, Vicuna, Stable Diffusion … Search & Conversation Vector Search Notebooks Pipelines AutoML PaLM Gemini … Vision, Video, TTS / STT, NL APIs

Slide 11

Slide 11 text

Google Cloud 11 What is Gemini? ● Gemini is Google Deep Mind’s most capable AI model ● It’s a multimodal large language model: text, images, videos ● Comes in 3 sizes: Nano, Pro, and Ultra ● Supports function calling ● Ranks at the top of the various LLM benchmarks (general knowledge, translation, image understanding, reasoning, math, coding, and more…) ● Will be integrated into Bard soon

Slide 12

Slide 12 text

Google Cloud Proprietary & Confidential 12 03 Time to have a look at some demos! @[email protected]

Slide 13

Slide 13 text

Google Cloud 13 Let’s play with Bard and MakerSuite! Bard PaLM MakerSuite

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Google Cloud 19 Python is all the rage in AI… What’s in it for us, Java developers?

Slide 20

Slide 20 text

Google Cloud 20 Generating bedtime stories for kids https://bed-time-stories.web.app/

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Google Cloud 22 Vertex AI Java API

Slide 23

Slide 23 text

Google Cloud 23 LangChain4J

Slide 24

Slide 24 text

Google Cloud 24 Searching the Apache Groovy documentation Apply the RAG pattern: Retrieval Augmented Generation

Slide 25

Slide 25 text

LLM Vector DB embedding vectors chunks DOCS calculate split store vector + chunk ❶ INGESTION

Slide 26

Slide 26 text

LLM Vector DB embedding vectors chunks DOCS calculate prompt embedding vector split calculate find similar answer context + prompt + chunks store vector + chunk ❶ INGESTION ❷ QUERYING

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Google Cloud Proprietary & Confidential 28 04 Summary @[email protected]

Slide 29

Slide 29 text

Google Cloud 29 Summary ● PaLM 2 & Gemini are powerful LLM that allow you to build all sorts of generative AI ideas and projects ● Using the PaLM API from Java is not necessarily ideal, but with REST or LangChain4j, it’s easy ● Fortunately, Gemini has a much better SDK! (and is also supported in LangChain4j) ● Easy to deploy & serve containerized apps on Cloud Run ● And LangChain4J is pretty sweet!

Slide 30

Slide 30 text

Google Cloud 30 More about LangChain4J youtube.com/watch?v=BD1MSLbs9KE

Slide 31

Slide 31 text

Google Cloud 31 What to build next? ● Chat Q&A with the Apache Groovy documentation ○ improve the quality of responses ● News curation that collects & summarize my social feeds What about you, what would you build?

Slide 32

Slide 32 text

Google Cloud 32 Going further Guillaume Laforge Developer Advocate Learn more about Generative AI at goo.gle/generativeai @[email protected]

Slide 33

Slide 33 text

Thanks! Guillaume Laforge Developer Advocate @[email protected]