Connecting LLMs to tools
Key Takeaways
Connecting Large Language Models to external tools and APIs to leverage real-time information and take actions
Full Transcript
if you've been following the AI space you probably know that large language models are helping developers build all sorts of neat and novel applications that's because LMS are excellent at processing and producing nuanced fluid language but llms have some limitations for one out of the box they're not connected to the external world when responding to user queries they don't have access to knowledge outside of their training data this means they can't return real-time information about things like weather or traffic or the news and they also can't take actions like booking flights sending messages or writing information to a database in other words if we want llms to be really useful they need to be able to interact with the outside world when we ask an llm what the weather is at Austin tomorrow we wanted to pull this information from a weather API and if we wanted to do something more complicated like using LM as a helpful assistant that can help us book a trip at some point we're going to have to call some apis to put flights and make hotel reservations so how exactly do we teach llms to use external tools like apis let's take a look let's say we want to build a chatbot that has access to a weather API so that we can ask about the weather and it can give us updates in real time for example what's the weather in Austin how would we architect an app like this well the first step is to write a prompt to get the llm to specify when a call to the weather API is needed and second we need to write the application code to actually go out and execute that API call finally we need to feed the API output back into the llm so that it can produce a response for the user let's break down each of these three steps as usual with LMS the first thing that we want to do is to design a prompt and as a reminder a prompt is the text that we feed into an llm to get it to take on a particular Behavior in this case we want to write a prompt that allows the model to indicate what an API call is necessary here's one way we can structure that prompt we might start with an instruction that tells the llm what our objective is like your objective is to complete the user's tasks then we describe the tools the llm can use to complete the user request in this case the weather API for example you have access to the following tool followed by an example of what using the tool command looks like what we're doing here is simply telling the llm what tools it has access to in plain old English since llms are capable of processing nuanced natural language this is actually often enough to get the llm to take on the behavior that we want however sometimes it's also helpful to add some illustrative examples to our prompt showing the llm that we want Its Behavior to be one example input could be what is the weather in New York tomorrow and the example response we'd want is the command weather and the City New York we passed this prompt into an llm with a new user request like what's the weather in Austin tomorrow the llm should output something like this which is what we want what we've done here is design a prompt that can get an llm to Output tool commands when they're required to complete the user's request however just to be clear the LM isn't actually calling any of these apis it's just producing text that indicates that we the programmer should go out and actually make that API call and that's something we have to design at our application code so let's see what that might look like first we need to detect when the model outputs a tool command in our case we prompting the model to Output the tool command in these curly brackets so we just need to do a string search to identify when a command has been issued then we have to actually go out and execute this command to do that we'll take this string weather Austin and we'll extract the parameters we need to make the API call how we do this depends on the API and how complex it is here we just have to identify the target City Austin we write code to call the API and then we get back some response which is typically in the Json format okay let's recap we got the nlm to Output when an API command is needed to complete the user's query then our application executed the API command let's suppose the response into this Json object which contains the weather in Austin now we could just return the space on blob back to the user technically it answers the question but most people don't want to read Json so instead let's use the llm to take this info and produce a more conversational response we can accomplish this by writing a brand new prompt that shows the llm how to issue commands and how to rephrase the API output into something more conversational we'll rewrite our original prompt do just that here's the prompt we started with remember it included an example of the user asking for the weather in New York let's extend that example by showing the model how to reframe the API output first we add a new field to The Prompt where we append the Json response note that we're not gonna ever actually show the end user this Json but it will be part of the model prompt finally we add an example of how the model should rephrase the Json into something that sounds conversational like setup Now using this prompt when we ask what's the weather in Austin the bot responds starts with a command then we go out and we execute the API commanded code and append the response to the prompt then we call the Alum a second time and this time it takes an API response and voila our end user gets their question answered with real-time accurate weather this is one basic way to design an llm application that can interact with just one tool but how would you extend this to multiple Tools in addition to listing out all the tool commands that we want our analog to have access to we might need a more sophisticated prompt maybe one that even includes logic about when to use each tool one reason prompting technique known as react is a way of writing columns that combines Keen of thought prompting with taking actions as a reminder in a cloud prompting is a technique where we nudge the llm to explain steps of reasoning to arrive and answered the react technique can be especially useful if a single user query requires multiple steps and maybe even multiple tools to complete designing prompts to teach llms how to use tools is an active and developing area of research if you're curious to learn more about different prompting methods we've put some links in the description below that's the basics of connecting large language models to external tools let us know in the comments what tools you're using with llms thank you
Original Description
Large Language Models (LLMs) are helpful in many use cases for devs. However, their lack of access to knowledge outside of their training data limits their usefulness. If you’ve ever wanted an LLM to return real-time information or take an action, this video is for you. Prompt LLMs how to leverage external sources of information!
Chapters:
0:00 - Intro
1:01 - Overview 1:31 - Prompt the LLM to call an API
3:08 - Write application code to call the API
3:43 - Feed API response to the LLM
Resources:
ReAct Prompting → https://goo.gle/43Jc3FW
Subscribe to Google for Developers → https://goo.gle/developers
#MachineLearning #MLmodels #LLMs #GenerativeAI
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Google for Developers · Google for Developers · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Developer Journey - Sunnyvale DSC Summit ‘19
Google for Developers
How Google is working with students - Sunnyvale DSC Summit ‘19
Google for Developers
Starting your career in the Cloud - Sunnyvale DSC Summit ‘19
Google for Developers
The Solution Challenge - Sunnyvale DSC Summit ‘19
Google for Developers
Firebase - Sunnyvale DSC Summit ‘19
Google for Developers
Cloud Hero - Sunnyvale DSC Summit ‘19
Google for Developers
Panel discussion - Sunnyvale DSC Summit ‘19
Google for Developers
The art of negotiation - Sunnyvale DSC Summit ‘19
Google for Developers
Courage to care, solve and share - Sunnyvale DSC Summit ‘19
Google for Developers
Version 9 of Angular, Glass Enterprise Edition 2, path to DX deprecation, & more!
Google for Developers
[DEPRECATING] Introducing a new series (Assistant for Developers Pro Tips)
Google for Developers
Detecting memory bugs with HWASan, Bazel 2.1, Next ‘20 session guide, & more!
Google for Developers
Why Podcast.app chose a .app domain name
Google for Developers
Machine Learning Bootcamp Jakarta 2019
Google for Developers
Android Studio 3.6, Android 11 Developer Preview, Kubeflow 1.0, & more!
Google for Developers
[DEPRECATING] Importance of community (Assistant on Air)
Google for Developers
Why the Flutter team switched from .io to a .dev domain name
Google for Developers
3 website-building tips from .dev creators
Google for Developers
Why NimbleDroid chose a .app domain name
Google for Developers
Android Platform Codelab, Bazel 2.2, Maps Android Utility Library v1.0, & more!
Google for Developers
Google for Games Developer Summit: A free, digital experience for game developers
Google for Developers
Inspecting Home Graph (Assistant for Developers Pro Tips)
Google for Developers
Google for Games Developer Summit Keynote
Google for Developers
Stadia Games & Entertainment presents: Keys to a great game pitch (Google Games Dev Summit)
Google for Developers
Empowering game developers with Stadia R&D (Google Games Dev Summit)
Google for Developers
Supercharging discoverability with Stadia (Google Games Dev Summit)
Google for Developers
Stadia Games & Entertainment presents: Creating for content creators (Google Games Dev Summit)
Google for Developers
Bringing Destiny to Stadia: A postmortem (Google Games Dev Summit)
Google for Developers
Live Captioning in Google Slides
Google for Developers
[DEPRECATING] User engagement for the Google Assistant
Google for Developers
TensorFlow Dev Summit ‘20, Google for Games Dev Summit, Cloud AI Platform Pipelines, & much more!
Google for Developers
Top 5 from the TensorFlow Dev Summit 2020
Google for Developers
Developer Student Clubs 2019 Turkey Leads Summit
Google for Developers
Building simpler payment experiences | Google Pay Plugin for Magento 2
Google for Developers
Become A Developer Student Club Lead
Google for Developers
Firebase Kotlin Extensions, ARM apps on the Android Emulator, Angular v9.1, & more!
Google for Developers
Test suite for Smart Home (Assistant for Developers Pro Tips)
Google for Developers
Google Play updates, Bazel 3.0, Business Console for Google Pay, & more!
Google for Developers
How to use error logs (Assistant for Developers Pro Tips)
Google for Developers
Contact Center AI, Android Studio 4.1 Canary 5, TensorFlow QAT API, & more!
Google for Developers
WebView DevTools, Kotlin meets gRPC, Flutter CodePen support, & more! (Episode 200)
Google for Developers
Offline handling for Smart Home (Assistant for Developers Pro Tips)
Google for Developers
Android 11 Dev Preview 3, Google Fonts for Flutter, Shielded VM, & more!
Google for Developers
Machine Learning Foundations: Ep #1 - What is ML?
Google for Developers
Flutter web support updates, BigQuery materialized views, Cloud Spanner emulator, & more!
Google for Developers
Computer vision by building a neural network with TensorFlow | Machine Learning Foundations
Google for Developers
Machine Learning Foundations: Ep #3 - Convolutions and pooling
Google for Developers
Android 11 Beta plans, Flutter 1.17, Dart 2.8, & much more!
Google for Developers
Machine Learning Foundations: Ep #4 - Coding with Convolutional Neural Networks
Google for Developers
Google Developers ML Summit
Google for Developers
Real-world image classification using convolutional neural networks | Machine Learning Foundations
Google for Developers
Adobe XD support for Flutter, Architecture Framework, temporary closures with Places API, & more!
Google for Developers
Machine Learning Foundations: Ep #6 - Convolutional cats and dogs
Google for Developers
Machine Learning Foundations: Ep #7 - Image augmentation and overfitting
Google for Developers
Announcing Firebase Live, Flutter Day, Java 11 on Google Cloud Functions, & more!
Google for Developers
Machine Learning Foundations: Ep #8 - Tokenization for Natural Language Processing
Google for Developers
Android 11 Beta, Google Play Asset Delivery, Firebase Crashlytics SDK, & much more!
Google for Developers
Natural Language Processing: Using sequencing APIs in TensorFlow | Machine Learning Foundations
Google for Developers
Build a sarcasm classifier using NLP and TensorFlow | Machine Learning Foundations
Google for Developers
AR Realism with the ARCore Depth API
Google for Developers
More on: LLM Foundations
View skill →Related Reads
Chapters (4)
Intro
1:01
Overview 1:31 - Prompt the LLM to call an API
3:08
Write application code to call the API
3:43
Feed API response to the LLM
🎓
Tutor Explanation
DeepCamp AI