GenAI for Java Developers 2: Techniques

Microsoft Developer · Beginner ·🔍 RAG & Vector Search ·8mo ago

Key Takeaways

The video covers GenAI techniques for Java developers, including LLM completion, multi-turn chat, interactive chat, and RAG (Retrieval Augmented Generative) pattern, as well as functions for business critical tasks.

Full Transcript

When you make coffee, you've probably got choices. Different buttons you can press. Espresso, cappuccino, latte. Each button gives you a totally different drink. This is both powerful, but it can also lead to unintended consequences. I'm a cloud advocate here at Microsoft. And one thing I've learned working with developers is once you know the basics, the real fun begins when you start exploring different techniques, the different levers you can pull, and how you can get different results from those levers. Today we have Rory joining us. And what we're doing today is seeing how Gen AI offers different brewing buttons, completions, chat flows, and rag. Each one unlocks an entirely new way to use AI. Rory, I'm so excited for today's session. please take it away. >> So once you have your environment set up and you finished the getting started video and now you're ready to look at generative AI techniques and there's really three techniques we're going to look at today. So the first techniques we've got our code space running is the LLM completion app and we're going to set some break points here and we're going to go through exactly what this is doing and why this is important. So it is going to connect to your GitHub models which we already saw that you need a token for and then once it has the completion set up we're going to go into multi-turn chat and then interactive chat. So let's debug this in our code space and we'll see there exactly what that is going to do. Now for the simple completions for the chat if we go into that. So let's step into we'll see there that it's just going to say you're a concise Java expert who can explain concepts explain Java streams in one paragraph. So let's make sure that our breakpoint is in multi-hat step through that there and then we'll see that it is coming back with a simple completion basically one turn. There we go. Java streams. Now we're in multi-turn chat. So let's check and step into that. Now multi-turn chat is going to say hey you're a helpful Java tutor. What is a hashmap in Java? And then it's going to ask another question. It's going to keep the history for that. the first response and then it's going to say, "Wow, you answered that first response. How is a hashmap different from a tree map?" So, we can step through that. It's going to multi-turn conversation and then it's going to stop there. How is a hashmap different from a tree map? See, it's already asked what a hashmap. It's kept it in history. It knows that we want to know more about what the conversation is. And we're going to step through that. And it's going to say to us, um, oh, there we go. We now have, let's go and and step through that there. And we're on interactive chat there. So, it has already broken through and told us, wait a second, if you want to know about a tree map, this is the difference. And it gives us all the key differences. And it even says great question cuz we're a helpful Java tutor. The last one that we want to see is the interactive chat. Now it's already broken there. I haven't put a broke point breakpoint there. But if we go into interactive chat, it's going to say, wait, take in the question that the person is asking. So if I ask it a question here and I can go into there it's saying okay what is the question you want to go and I want to say tell me a joke why do programmers prefer dark mode because light attracts bugs and then you can go exit from that so that's the completion part of it we are now going to go into the rag or rag stands for retrieval augmented generative uh pattern and we can see here that the rag the simple reader demo is going to read in document.txt and ground itself onto some information and the information is it says GitHub models provides a convenient way to access large language models. Now over here we want them to only and not hallucinate on the information. So, we're going to read in the document. We're going to uh use the file and then we're going to say to it, don't answer any question that doesn't ground on the the document. You can see there I cannot find that information in the provided document. So, let's go in there and let's see what we're going to ask. So, we're going to ask a helpful uh a question on rags. a simple reader demo. And now let's go in and debug that. So let's go there and we're going to debug that. And it's going to go in and read that document and it's going to use the augmentation to say ask a question about the document. And I can say what is what are GitHub models? Question mark. And it's not going to ask answer anything that isn't in the document. So what are GitHub models? And it's going to go and give us our example. At the same time, it's going to use the token, the GitHub models token to go in there and to prepare the response. And it says there GitHub models um are a convenient way to access and use large language models. and it won't really ask an answer and give you the opportunity to say, "Tell me a joke." Because it's not really relevant to the underlying um instructions. And then finally, we're going to look at functions. And functions are a nice way to create small little uh procedures that help you with certain business critical functions. And we've got two functions here. Weather function example. So let's pause it there. And then calc function. Now for the weather function, we're actually going in and we're going to simulate a weather. We're going to give it the city name and it's going to return the uh temperature. You're a helpful weather assistant. Use the weather function to provide the weather and then we're going to ask it what is the weather like in Seattle. Now, this is going to need a large language model that can call functions. So, we're going to use GPT 40 mini. So let's debug that now and it should break on the weather function. So weather function example and let's step through that now and we'll see there ah we got the weather in Seattle. The same with the calculator function and the calculator function is going to perform basic calculation. We can see if we go into the calculator function example, it's just going to do a mathematical expression and very basically what is 15% of 240 and we're going to continue through that and there we go. So this is a very simple way of handling business critical information. And you can even point it out and it can go speak to external systems, but it does need the GPT 40 mini. So coming back to what we demoed today, we went through the completion app, we went through the rag, we showcased functions, and then if you look there, responsible AI, we're actually going to mention that in a later video because responsible actually is protecting all of this that we currently doing from abuse. Thank you so much, Rory. I appreciate so much the level of detail you went into into your session. But not just that, how fun and entertaining you keep it the entire time. For everybody who joined us for this episode, if you would want to visit resources related to this episode, you can find them at aka.ms/java andai for beginners. Link is in the description of this video. We'll see you in the next episode.

Original Description

Resources: https://aka.ms/JavaAndAIForBeginners https://aka.ms/genaijava In this episode, Ayan Gupta is joined once again by Rory, who takes you on a deep dive into the core techniques that power generative AI applications. Building on the environment setup from Session "GenAI for Java Developers 1: Getting started", this session explores the different "brewing buttons" of GenAI, each one unlocking a completely different way to leverage AI in your Java applications. Think of it like a coffee machine with different buttons: espresso, cappuccino, latte. Each setting produces a unique result. Similarly, GenAI offers multiple techniques, completions, multi-turn chat, interactive chat, RAG (Retrieval Augmented Generation), and function calling—that enable you to build diverse AI-powered features. Rory demonstrates each technique hands-on using the GitHub Codespaces environment. You'll learn how to implement simple LLM completions for one-turn interactions, build multi-turn conversations that maintain context and history, create interactive chat applications that respond to user input in real-time, implement RAG to ground your AI responses in specific documents and prevent hallucinations, and use function calling to connect AI to business-critical operations like weather APIs and calculators. Each example includes practical code that you can run and modify yourself. By understanding these fundamental techniques, you'll have the building blocks to create sophisticated AI applications. This session builds directly toward the next session, where we'll put these techniques into practice by building three complete applications. Whether you're building chatbots, knowledge bases, or intelligent assistants, these techniques are essential. Subscribe and follow along as we continue this exciting journey! 0:00 - Introduction: Different Techniques, Different Results 0:50 - Setting Up the Code Space 1:04 - Technique 1: LLM Completions 1:50 - Testing Simple Completions 2:16 - Tec
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Microsoft Developer · Microsoft Developer · 0 of 60

← Previous Next →
1 Prepare for the DP-300 exam & the Azure Database Administrator Associate cert | Data Exposed
Prepare for the DP-300 exam & the Azure Database Administrator Associate cert | Data Exposed
Microsoft Developer
2 What I Wish I Knew ... about landing a job in tech
What I Wish I Knew ... about landing a job in tech
Microsoft Developer
3 Igniting Developer Innovation with Vector Search
Igniting Developer Innovation with Vector Search
Microsoft Developer
4 Combining the power of vector search with Azure OpenAI then revolutionize image search with vectors!
Combining the power of vector search with Azure OpenAI then revolutionize image search with vectors!
Microsoft Developer
5 What I Wish I Knew ... about finding your place in tech
What I Wish I Knew ... about finding your place in tech
Microsoft Developer
6 Fluent UI React Insights: Accessible by default
Fluent UI React Insights: Accessible by default
Microsoft Developer
7 Signing Container Images with Notary Project
Signing Container Images with Notary Project
Microsoft Developer
8 What I Wish I Knew ... about finding your place in tech
What I Wish I Knew ... about finding your place in tech
Microsoft Developer
9 What programming languages does GitHub Copilot support?
What programming languages does GitHub Copilot support?
Microsoft Developer
10 What I Wish I Knew ... about how much your job can change
What I Wish I Knew ... about how much your job can change
Microsoft Developer
11 What I Wish I Knew ... about how much your job can change
What I Wish I Knew ... about how much your job can change
Microsoft Developer
12 How do I become more confident about AI?
How do I become more confident about AI?
Microsoft Developer
13 How do I become more confident about AI?
How do I become more confident about AI?
Microsoft Developer
14 Performance Demos of SQL’s Intelligent Query Processing Feedback capabilities | Data Exposed
Performance Demos of SQL’s Intelligent Query Processing Feedback capabilities | Data Exposed
Microsoft Developer
15 What I Wish I Knew ... about coming to Microsoft
What I Wish I Knew ... about coming to Microsoft
Microsoft Developer
16 What I Wish I Knew ... about coming to Microsoft
What I Wish I Knew ... about coming to Microsoft
Microsoft Developer
17 Revolutionizing Image Search with Vectors
Revolutionizing Image Search with Vectors
Microsoft Developer
18 Igniting developer innovation with Vector search and Azure OpenAI
Igniting developer innovation with Vector search and Azure OpenAI
Microsoft Developer
19 Getting Started with Azure AI Studio's Prompt Flow - Part 2
Getting Started with Azure AI Studio's Prompt Flow - Part 2
Microsoft Developer
20 What I Wish I Knew ... about finding my career path
What I Wish I Knew ... about finding my career path
Microsoft Developer
21 What I Wish I Knew ... about finding my career path
What I Wish I Knew ... about finding my career path
Microsoft Developer
22 Windows Terminal's journey to Open Source
Windows Terminal's journey to Open Source
Microsoft Developer
23 Can I trust the code that GitHub Copilot generates?
Can I trust the code that GitHub Copilot generates?
Microsoft Developer
24 What I Wish I Knew ... about interviewing
What I Wish I Knew ... about interviewing
Microsoft Developer
25 What I Wish I Knew ... about interviewing
What I Wish I Knew ... about interviewing
Microsoft Developer
26 What is the Microsoft TechSpark Program?
What is the Microsoft TechSpark Program?
Microsoft Developer
27 SQL Server 2022: Accelerate query performance while reducing query compile time - w/ no code changes
SQL Server 2022: Accelerate query performance while reducing query compile time - w/ no code changes
Microsoft Developer
28 What I Wish I Knew ... about discovering computer science
What I Wish I Knew ... about discovering computer science
Microsoft Developer
29 What I Wish I Knew ... about discovering computer science
What I Wish I Knew ... about discovering computer science
Microsoft Developer
30 Call center transcription and analysis using Azure AI
Call center transcription and analysis using Azure AI
Microsoft Developer
31 How to use Text Analytics for health in Azure AI Language
How to use Text Analytics for health in Azure AI Language
Microsoft Developer
32 Azure OpenAI-powered summarization in Azure AI Language
Azure OpenAI-powered summarization in Azure AI Language
Microsoft Developer
33 Accelerate data labeling using Azure OpenAI and Azure AI Language
Accelerate data labeling using Azure OpenAI and Azure AI Language
Microsoft Developer
34 Building a Private ChatGPT with Azure OpenAI
Building a Private ChatGPT with Azure OpenAI
Microsoft Developer
35 What I Wish I Knew ... about how to interview
What I Wish I Knew ... about how to interview
Microsoft Developer
36 What I Wish I Knew ... about how to interview
What I Wish I Knew ... about how to interview
Microsoft Developer
37 Getting Started with Azure AI Studio's Prompt Flow - Part 3
Getting Started with Azure AI Studio's Prompt Flow - Part 3
Microsoft Developer
38 Intelligent Apps with Azure Kubernetes Service (AKS)
Intelligent Apps with Azure Kubernetes Service (AKS)
Microsoft Developer
39 Getting Started with Azure Blob Storage | Data Exposed: MVP Edition
Getting Started with Azure Blob Storage | Data Exposed: MVP Edition
Microsoft Developer
40 Chat + Your Data + Plugins
Chat + Your Data + Plugins
Microsoft Developer
41 What I Wish I Knew ... about different career paths
What I Wish I Knew ... about different career paths
Microsoft Developer
42 What I Wish I Knew ... about different career paths
What I Wish I Knew ... about different career paths
Microsoft Developer
43 Advanced Dev Tunnels Features | OD122
Advanced Dev Tunnels Features | OD122
Microsoft Developer
44 Learn Live - Manage performance and availability in Azure Cosmos DB for PostgreSQL
Learn Live - Manage performance and availability in Azure Cosmos DB for PostgreSQL
Microsoft Developer
45 Plan your SQL Migration to Azure with confidence | Data Exposed
Plan your SQL Migration to Azure with confidence | Data Exposed
Microsoft Developer
46 What I Wish I Knew ... about social skills in a tech career
What I Wish I Knew ... about social skills in a tech career
Microsoft Developer
47 What I Wish I Knew ... about social skills in a tech career
What I Wish I Knew ... about social skills in a tech career
Microsoft Developer
48 All About Vectors, Search, and Function Calling in Azure OpenAI - Labor Day Special
All About Vectors, Search, and Function Calling in Azure OpenAI - Labor Day Special
Microsoft Developer
49 Introduction to project ORAS
Introduction to project ORAS
Microsoft Developer
50 What I Wish I Knew ... about finding the right major
What I Wish I Knew ... about finding the right major
Microsoft Developer
51 What I Wish I Knew ... about finding the right major
What I Wish I Knew ... about finding the right major
Microsoft Developer
52 What I Wish I Knew ... about how to approach programming
What I Wish I Knew ... about how to approach programming
Microsoft Developer
53 What I Wish I Knew ... about how to approach programming
What I Wish I Knew ... about how to approach programming
Microsoft Developer
54 Learn Live - Scale from a single node to multiple nodes with Azure Cosmos DB for PostgreSQL
Learn Live - Scale from a single node to multiple nodes with Azure Cosmos DB for PostgreSQL
Microsoft Developer
55 What I Wish I Knew ... about diversity in tech #1
What I Wish I Knew ... about diversity in tech #1
Microsoft Developer
56 What I Wish I Knew ... about diversity in tech #1
What I Wish I Knew ... about diversity in tech #1
Microsoft Developer
57 Get started with SQL Server AGs across Windows, Linux and Container Replicas | Data Exposed
Get started with SQL Server AGs across Windows, Linux and Container Replicas | Data Exposed
Microsoft Developer
58 Writing LLM Apps with Azure AI and PromptFlow
Writing LLM Apps with Azure AI and PromptFlow
Microsoft Developer
59 What I Wish I Knew ... about how cool working in tech could be
What I Wish I Knew ... about how cool working in tech could be
Microsoft Developer
60 Open Source foundation models in Azure Machine Learning & optimization techniques behind the scenes
Open Source foundation models in Azure Machine Learning & optimization techniques behind the scenes
Microsoft Developer

This video teaches GenAI techniques for Java developers, including LLM completion, multi-turn chat, and RAG pattern, and demonstrates how to use these techniques to build interactive chat systems and business critical functions. The video also covers responsible AI and provides resources for further learning.

Key Takeaways
  1. Set up environment for GenAI development
  2. Implement LLM completion app
  3. Debug and test multi-turn chat and interactive chat
  4. Use RAG pattern for retrieval augmented generation
  5. Create functions for business critical tasks
💡 GenAI can be used to build interactive chat systems and business critical functions, and responsible AI is essential to protect these systems from abuse.

Related Reads

Chapters (5)

Introduction: Different Techniques, Different Results
0:50 Setting Up the Code Space
1:04 Technique 1: LLM Completions
1:50 Testing Simple Completions
2:16 Tec
Up next
This FREE Tool Turns ANY PDF into Perfect Markdown (MinerU Live Test)
Prompt Engineer
Watch →