LangChain- Develop LLM powered applications with LangChain
- Descrição
- Currículo
- FAQ
- Revisões
COURSE WAS RE-RECORDED and supports- LangChain Version 0.3.0
Welcome to first LangChain Udemy course – Unleashing the Power of LLM!
This comprehensive course is designed to teach you how to QUICKLY harness the power the LangChain library for LLM applications.
This course will equip you with the skills and knowledge necessary to develop cutting-edge LLM solutions for a diverse range of topics.
Please note that this is not a course for beginners. This course assumes that you have a background in software engineering and are proficient in Python. I will be using Pycharm IDE but you can use any editor you’d like since we only use basic feature of the IDE like debugging and running scripts .
In this course, you will embark on a journey from scratch to building a real-world LLM powered application using LangChain.
We are going to do so by build 3 main applications:
-
Ice Breaker– LangChain agent that given a name, searches in google to find Linkedin and twitter profiles, scrape the internet for information about a name you provide and generate a couple of personalized ice breakers to kick off a conversation with the person.
-
Documentation Helper– Create chatbot over a python package documentation. (and over any other data you would like)
-
A slim version of ChatGPT Code-Interpreter
-
Prompt Engineering Theory Section
The topics covered in this course include:
-
LangChain
-
LLM + GenAI History
-
LLMs: Few shots prompting, Chain of Thought, ReAct prompting
-
Chat Models
-
Open Source Models
-
Prompts, PromptTemplates, langchainub
-
Output Parsers, Pydantic Output Parsers
-
Chains: create_retrieval_chain, create_stuff_documents_chain
-
Agents, Custom Agents, Python Agents, CSV Agents, Agent Routers
-
OpenAI Functions, Tool Calling
-
Tools, Toolkits
-
Memory
-
Vectorstores (Pinecone, FAISS)
-
RAG (Retrieval Augmentation Generation)
-
DocumentLoaders, TextSplitters
-
Streamlit (for UI)
-
LCEL
-
LangSmith
-
Intro to LangGraph
-
FireCrawl
-
GIST of Cursor IDE
-
Cursor Composter
-
Curser Chat
-
MCP – Model Context Protocol
Throughout the course, you will work on hands-on exercises and real-world projects to reinforce your understanding of the concepts and techniques covered. By the end of the course, you will be proficient in using LangChain to create powerful, efficient, and versatile LLM applications for a wide array of usages.
This is not just a course, it’s also a community. Along with lifetime access to the course, you’ll get:
-
Dedicated 1 on 1 troubleshooting support with me
-
Github links with additional AI resources, FAQ, troubleshooting guides
-
Access to an exclusive Discord community to connect with other learners (5000+ members)
-
No extra cost for continuous updates and improvements to the course
DISCLAIMERS
-
Please note that this is not a course for beginners. This course assumes that you have a background in software engineering and are proficient in Python.
I will be using Pycharm IDE but you can use any editor you’d like since we only use basic feature of the IDE like debugging and running scripts. -
The first project of the course (Ice-Breaker) requires usage of 3rd party APIs-
ProxyURL, SerpAPI, Twitter API which are generally paid services.
All of those 3rd parties have a free tier we will use to create stub responses development and testing.
-
1Course IntroductionVídeo Aula
-
2Course ObjectivesVídeo Aula
Course Objectives: Develop LLM Powered Applications with LangChain
Agents
Retrieval Augmentation Generation (RAG)
We also Cover:LangChain Ecosystem: LangSmith, LangGraph
Prompt Engineering
Production
Target Audience:
Software Engineers
Data Scientists
Technical Product Managers
Anyone who is comftirable with Code
No AI/ML experience is needed
Prerequisites: This is NOT a beginner's course
Python knowledge
Git usage
Virtual Environments, environment variables
No AI/ML Knowledge is needed, we cover all here
-
3Course Structure + How to get the best of Udemy [PLEASE DO NOT SKIP]Vídeo Aula
-
4Course's Discord ServerVídeo Aula
-
5Course ResourcesTexto
-
6What is LangChain? LangChain Under 6 MinutesVídeo Aula
-
7Project Setup (Pycharm) recommend)Vídeo Aula
Goal of video:
In this video, we will set up our project by cloning a branch, configuring PyCharm, installing dependencies, and building an Icebreaker file. We'll also introduce the LanChain framework.
Topics covered:Cloning a Git branch:
We'll clone a branch from the main repository to our local machine using Git command-line interface. This step is important to work on a specific version of the code.Configuring PyCharm:
We'll configure PyCharm by setting up the Python interpreter and creating a virtual environment. This is important to ensure our project is aligned with the correct interpreter and that we have a clean environment to work in.Installing dependencies: We'll use pip to install the necessary dependencies for our project, including the Lanchang framework. This step is essential to ensure we have all the necessary packages to build our application.
Introduction to the LanChain framework:
We'll provide a quick introduction to the LanChain framework, explaining its abstractions like chains and why it's become so popular among developers.Create ice_breaker.py file:
We'll create an Icebreaker file, which will hold all of our LanChain code. We'll start with a default function and run it using the Python terminal to make sure everything works as expected.Configuring runners:
We'll add a new runner to PyCharm and configure it to run our Icebreaker file.Installing a code formatter:
We'll install the code formatter Black, which will help us maintain consistent formatting in our Python code. This is a best practice in software development and will help ensure that our code is clean, readable, and maintainable.
To summarize: In this video, we'll show you how to set up your project by cloning a Git branch, configuring PyCharm, and installing dependencies. We'll also provide a quick introduction to the LanChain framework, build an Icebreaker file, and configure runners to run it. Finally, we'll install a code formatter to ensure our code is consistent and readable. By the end of this video, you'll be ready to start writing your first LanChain code.
-
8Project Setup (vscode) - optionalVídeo Aula
-
9Environment Variables and .env FileVídeo Aula
-
10Your First LangChain application - Chaining a simple promptVídeo Aula
Goal:
In this video, we will learn about the basics of the LangChain framework and how to write a simple prompt program that executes a large language model. We will also introduce some cool topics of the LangChain framework, such as chat models, PromptTemplates, and chains.Topics Covered:
Introduction to prompts:
We will define what a prompt is and how it is used to receive input and output from a large language model.PromptTemplates:
We will cover the concept of PromptTemplates and how they allow us to create customizable prompts that can receive different inputs.Chat models:
We will introduce the new concept of chat models and how they are wrappers around large language models to interact with them through text.Chains:
We will explain the purpose of chains, which is to combine multiple components to create a single coherent application.Creating a prompt and PromptTemplate:
We will create a prompt template object and introduce the concept of input variables and keys.Using a ChatModel:
We will create an instance of a chat model and plug it into the prompt template.Creating and Running the chain:
We will run the chain with the prompt template and input variables and show how the LangChain framework automatically handles the process for us.
-
11Using Open Source Models With LangChain (Ollama, Llama3, Mistral)Vídeo Aula
Open Source Models in GenAI Applications
Ollama
Mistral by Mistral AI
Llama3 by Meta
-
12LangChain Version In Course (V0.3.3) - (No breaking changes in 0.3.3)Vídeo Aula
The course compatible with V0.3.0
-
13Which LLM to Use? (OpenAI, Gemini, Anthropic, Mistral, Llama)Vídeo Aula
-
14Quick Check InVídeo Aula
-
15Ice Breaker- What are we building here?Vídeo Aula
-
16Integrating Linkedin Data Processing - Part 1Vídeo Aula
In this video, we will be focusing on building an application that connects with LinkedIn and utilizes LLMs to analyze data that we scrape from Linked.
Here are the topics that we will cover:Scraping LinkedIn API Data:
We will write a code that fetches and scrapes information from a LinkedIn URL using the function called "scrape_linkedIn_profile".Using ProxyURL:
We will learn how to use ProxyURL to scrape LinkedIn API data. We will see how it's advantageous to use this tool.Cleaning Response Payload:
We will learn how to clean unnecessary data from the payload. We will discuss the importance of being frugal with tokens to avoid exceeding the token limit and how it affects the API call made to LLMs.Leveraging summarization Power of LLMs:
We will give the LinkedIn data that we got as an input to an LLM chain so it can output a coherent summary.
-
17Linkedin Data Processing - Part 2 - Agents TheoryVídeo Aula
LangChain Agent Theory
In this video, we’ll dive into the concept of LangChain agents and how they can be used for reasoning and performing tasks and interact with external services.
Topics:
Introduction to LangChain agents
The concept of subtasks and how agents split them to complete bigger tasks
Chain Of Thought Prompting
ReAct Prompt Prompting
How agents can be used to perform tasks and interact with external services
Understanding the structure of agents and their tools, Toolkits
A practical example of building an agent
-
18Linkedin Data Processing- Part 3: Tools, Agent Executor, create_react_agentVídeo Aula
LangChain agents
LangChain agents are entities that can perform actions autonomously by interacting with the environment.
For this, an LLM (large language model) is used to determine which actions to take and in what order. There are several agents available in LangChain, including the zero-shot-react-description, react-docstore, self-ask-with-search, and conversational-react-description.Tools
Tools are ways that an agent can use to interact with the outside world. Examples of tools include search engines, APIs, and other datastores.
Tools are useful because LLMs only have knowledge of what they were trained on, but tools can fetch up-to-date data and take actions that can be observed and factored into an agent's decision on what to do next.LangChain ReAct
The LangChain AgentType is derived from prompt engineering techniques and determines how the agent will calculate its strategies to achieve a task. Memory helps the agent remember previous interactions, and an AgentExecutor is the logic for running an Agent in a while-loop until some stopping criteria is met.The default LangChain Agent is based on the ReAct framework proposed by Yao et al.
This approach is characterized by the following algorithm:user gives an agent a task
thought (the agent "thinks" about what to do),
action/action input (the agent decides what action to take and what the input to that tool should be),
observation (the output of the tool),
and repeating steps 2-4 until the agent "thinks" it is done.
Overall, LangChain agents, tools, and AgentType are important concepts in creating autonomous agents that can perform tasks and interact with the outside world.
-
19Linkedin Data Processing- Part 4: Custom Search Agent ImplementationVídeo Aula
Initializing the Agent
Defining the Tools
We create a list of tools that the agent can use- It will need to search for the LinkedIn profile URL. Each tool has a unique name, function, and description. We also set a description for each tool, which is used by the agent reasoning algorithm to decide which tool to use.
Initializing the Agent with Tools
We initialize the agent with the list of tools and an LLM model. We also set the agent type to zero-shot react. The agent type is critical as it determines the reasoning process for performing a task. We can use different agent types for different tasks to get different results.
Verbose Logging
We set the verbose flag to true, which tells the agent to log every step it takes.
This is useful for understanding the agent's reasoning process and how it performs a task.Creating a Custom Tool
We create a custom tool that uses the LinkedIn API to search for the LinkedIn profile URL.
We use the decorator method to define the tool so that the LangChain agent can use it.Testing the Agent
We test the agent by passing it a name and running the code. The agent returns the LinkedIn profile URL for the given name. We also scrape the LinkedIn data from the URL using a proxy URL.
-
20Linkedin Data Processing- Part 5: Custom Search Agent TestingVídeo Aula
Testing the Agent
We test the agent by passing it a name and running the code. The agent returns the LinkedIn profile URL for the given name. We also scrape the LinkedIn data from the URL using a proxy URL.
-
21[Optional] Twitter Data Processing- Part 1- ScrapingVídeo Aula
Introduction
In this video, we will learn how to enrich data using Twitter API. We will incorporate Twitter into our application, making it more robust. After watching the two videos, our application will have the ability to extract Twitter usernames and scrape data from Twitter using an agent.
Twitter Processing:
We will provide the same code as we use in this lecture, which we will call Twitter's API. We will also use a package called tweepy, which will help us access Twitter API.Scraping User Tweets:
We will create a new function called "scrape_user_tweets" that will receive the username of the user and a number of tweets. It will get the tweets from this user and filter out retweets and replies.Testing the Function
We will test the function by getting the tweets of Elon Musk. As Elon Musk is super popular on Twitter, we will have to filter out a couple of those messages. We will change the number of tweets to 100 to fix the problem. -
22[Optional] Twitter Data Processing- Part 2- AgentsVídeo Aula
Introduction:
In this video, we will create the LangChain agent that takes a name searches online and extracts the username from Twitter.
We'll use Python to create the Twitter Lookup Agent and adjust it to use Twitter instead of LinkedIn like we did in previous videos.In this video, we'll cover the following topics:
Creating the Twitter Lookup Agent
Testing the application and overcoming token limitations
Generating topics of interest and icebreakers for conversation starters
-
23Output Parsers- Getting Ready to work with a FrontendVídeo Aula
-
24FullsStack App- Building our LLM powered by LangChain FullStack ApplicationVídeo Aula
Introduction
In this video, we're going to build the server-side for our project, as well as the front-end.
By the end of it, we will have fully integrated it into a Lansing-based generative application.Technical Details
We also want to return from the ice_breaker function, the profile pic URL, so we're going to change the type of notation in the return value to a tuple.
We will be using Flask to create a Flask application. We need the Flask to render the template to render the HTML code that we're going to be writing.
Building the Flask Web ServerWe will create a new file and name it app.py. This file will hold our Flask web server. We will use the main endpoint '/process' which will be using a post request with the name of the person we want to get info about.
When we call the endpoint, we will invoke the process function.Creating the Front-End
We need to write the front-end.
We will create a new directory and name it static. Inside it, we will create a new directory named CSS. We will create a new file named style.css and we'll place our CSS content inside it.Next, we will create a new directory named templates. In the templates directory, we will create an index.html file. Flask will be looking for the HTML5 to render in the templates directory.
-
25Tracing application with LangSmithVídeo Aula
-
26[New] Real World Ice breaker AgentsVídeo Aula
-
27What are we building? ReAct AgentExecutor from scratchVídeo Aula
-
28Environment Setup + ReAct Algorithm overviewVídeo Aula
-
29Defining Tools for our ReAct agentVídeo Aula
-
30ReAct prompt, LLM Reasoning Engine, Output Parsing and Tool ExecutionVídeo Aula
-
31AgentAction, AgentFinish, ReAct LoopVídeo Aula
-
32CallbackHandlers, ReAct Prompt and finalizing the ReAct Agent loopVídeo Aula
-
33Recap with LangSmithVídeo Aula
-
34Medium Analyzer- Boilerplate Project SetupVídeo Aula
-
35Medium Analyzer- Class Review: TextLoader,TextSplitter,OpenAIEmbeddings,PineconeVídeo Aula
Introduction
In this video, we will review the classes and objects that we will use for this session. We will explain each class related to the theoretical particle reviewed earlier, including Document Loaders, Text Splitters, OpenAI Embeddings, Pinecone, and VectorDBQA Chain.Document Loaders
Document Loaders are classes that implement how to load and process data to make it digestible by the language model. We will be using the class of TextLoader, which helps us send data to LLMS.
This abstraction allows us to attach other things to the text, such as processing WhatsApp messages, downloading PDF files, or working with a Notion notebook.TextSplitter
TextSplitter us with long pieces of text.
Large text files often contain more tokens than the modeling forces allow, causing the request to fail.
TextSplitter solves this problem by splitting the text into smaller chunks, which can be sent to the language model. TextSplitter has a lot of logic, including splitting strategies and calculating appropriate chunk size. The chunk size may change according to what we want to accomplish, depending on the different weighting systems. We can specify the chunk size and overlap between the chunks to ensure that the text isn't sped up in a way that disturbs the context or meaning.OpenAIEmbeddings
OpenAIEmbeddings is a black box that takes inputs as text and outputs vectors in an embedded Vector space.
We can use OpenAI Embeddings' API to embed a text, and we will get back a vector. There are many embedding providers available, but OpenAI Embeddings is one of the best. The Embedding abstraction It creates a uniform interface for us to access different embeddings from different providers. It is straightforward to switch between different providers by just changing a parameter.Pinecone
Pinecone is an excellent Vector database that has recently gone viral. It provides a persistent storage solution for the vectors we receive from embedding like OpenAI Embeddings.
Pinecone allows us to search in the vector space for the closest vectors of the current one. We can add new vectors to the vector space and retrieve relevant documents from the vector database.
-
36Medium Analyzer- Ingestion ImplementationVídeo Aula
In this video we will write a python script script that demonstrates how to use various libraries and tools to create an LLM powered assistant that can answer questions based on the content of a given text document.
This is the ingestion part.
Here are the main steps that the code follows:
Import necessary libraries including LangChain modules:
TextLoader, CharacterTextSplitter, OpenAIEmbeddings, PineconeVectorStore, and OpenAI.Initialize Pinecone by providing an API key and environment.
Load a text document from a file using TextLoader.
Split the document into smaller chunks using CharacterTextSplitter.
Use OpenAIEmbeddings to create embeddings for each text chunk.
Index the embeddings in Pinecone using the PineconeVectorStore.from_documents method.
Overall, this code demonstrates how to leverage several powerful libraries and tools to build a simple but effective search engine that can provide answers to natural language queries.
-
37Medium Analyzer- Retrieval Implementation Implementation with chainsVídeo Aula
-
38Medium Analyzer- Retrieval Implementation Implementation with LCELVídeo Aula
-
39Chat With Your PDF- FAISS Local VectorstoreVídeo Aula
Introduction:
In this video, we'll be exploring how to use local vectorstores to load and retrieve PDF documents using
LangChain and FAISSSetting up the Environment
Creating a new directory and virtual environment
Installing required packages including PyPDF and FAISS
Loading and Processing the PDF Document
Using PyPDF to load the PDF file
Chunking the document with LangChain's CharacterSplitter
Using OpenAI embeddings to convert the document into vectors
Storing vectors in a vector store
FAISS
Python package to help with similarity search in our local environment
-
40What are we building? (RAG)Vídeo Aula
-
41Environment SetupVídeo Aula
Cloning the Repository
First, we'll clone the repository by running the command
"git clone https://github.com/emarco177/documentation-helper.git -b 1-start-here"
in the terminal. This will clone the repository and start us off on the beginning branch.Creating the Download Directory
Next, we'll create a new directory called "langchain-docs" to download the Python documentation of LangChain to. We'll use the wget utility to download the documentation of LangChain.
This will take some time as it will download a lot of files, so feel free to take a break.
Creating the Pinecone Index
Once we have all the files downloaded, we'll move on to creating a Pinecone index.
We'll log in to our user and create an index that will store the embeddings of the documentation of LangChain. We'll search for embeddings of OpenAI to determine the dimension of the vectors that are returned, which is 1536.
-
42OPTIONAL Manually Scraping the LangChain DocumentationVídeo Aula
-
43Pinecone Vectorstore IngestionVídeo Aula
Initializing and Adding Documents to the Pinecone Index
After the index is initialized, we'll start adding documents to it.
Splitting the Documents into Chunks
We'll then split the documents into chunks using the text feature split documents. We'll print a debugging message to count how many documents we have now after splitting them.
Insert to Pincone vectorstore:
Then we will use the Pincone wrapper of LangChain to insert all the embeddings of the chunks we created.
-
44Retrieval + Augmentation + Generation = RAGVídeo Aula
In this video, we will be implementing a RetrievalQA chain in a backend powered by LangChain and Pinecone. We will be discussing how to retrieve context from a vectorstore and use it to augment a prompt to get a better answer from an LLM.
Setting up Pinecone and the Python client
We will start by importing Pinecone and the Python client to create an index for our vector store.
Retrieving context from a vector store
We will write code to retrieve context from a vector store using LinkChain and Pinecone.
We will discuss how the vector store uses similarity search to retrieve relevant vectors.
Augmenting a prompt with context
We will modify our prompt to include the retrieved context from the vector store.
We will discuss how this helps improve the accuracy of our LM.
Using create_retrieval_chain + create_stuff_documents_chain
We will discuss how to use a retriever object to retrieve relevant vectors from the vectorstore.
Running a demo
We will run a demo to see the RetrievalQA LangChain chain in action.
We will discuss the output and how to access the source documents.
To summerize, implementing a retrieval Q&A chain in a backend using LinkChain and Pinecone is a powerful way to improve the accuracy of an LLM. With this approach, we can retrieve context from a vector store and use it to augment a prompt, resulting in more accurate and relevant answers.
-
45Building an AI LangChain Chat Assistant- "Frontend" with Streamlit (UI)Vídeo Aula
Introduction:
In this video, we will go over the steps to create a new file called main.py and use Streamlit to build an elegant and simple user interface.
Creating a Streamlit Runner
We will create a Streamlit Runner to run the Streamlit CLI with our main.py file. We will select Python as our language, name the runner "Streamlit Runner", and include the path to the Streamlit CLI.Creating a User Prompt
We will then create a text input for the user to input their prompt. The prompt will be stored in a variable called "prompt".Generating a Response
We will then generate a response to the user's prompt by running the run_llm function. The response will be stored in a variable called "generated_response".Updating the Session State
We will then update the session state to include the user's prompt and the response from the AI. This will allow us to maintain chat history and provide context to the AI.
Displaying Chat History
If the chat history is not empty, we will display the chat history to the user. This will allow the user to see the questions they've asked and the AI's responses.
-
46Building an AI LangChain Chat Assistant- MemoryVídeo Aula
Intro- Integrating Conversation Memory into a Language Model with LangChain
In this video, we will explore how to integrate conversation memory into a language model using LangChain.
Setting Up the Repository
First, commit the current code and create a new branch to implement memory support.
Updating Session States
We will add a new key called "chat_history" to the Streamlit session_states variable.
This key will store a list containing the entire conversation history between the user and the language model.Updating the Function to Support Memory
We will modify the function to accept a chat_history parameter. Pass this parameter to the run_llm function, which will refactor to process the chat history as well.
Implementing Conversational Retrieval Chain
We will replace the RetrievalQA chain with a ConversationalRetrieval chain which support memory.
Initialize it using the from_llm function from LangChain instead of the from_type function used before in RetrievalQA.
We will also pass the chat history object to the conversational retrieval chain.Understanding the Augmented Prompt
We'll dive into LangChain source code.
We will examine the augmented prompt sent to the language model by the ConversationalRetrieval chain. The prompt is modified to include the chat history, allowing the language model to understand the context of the conversation.
Now we know how to integrate conversation memory into a language model using LangChain.
This process can be applied to any language model that requires context-aware conversation support. -
47[Optional] RAG Pipeline Optimization featuring FireCrawlVídeo Aula
-
48Leveraging Cursor IDE for UI ImprovementsVídeo Aula
-
49What is Cursor?Vídeo Aula
Cursor is an AI-powered integrated development environment (IDE) designed to enhance coding productivity.
Some key features of Cursor:AI-assisted coding: It uses large language models to help with code completion, generation, and editing.
Code explanation: Cursor can provide explanations for selected code snippets.
Natural language commands: You can describe what you want to do in plain English, and Cursor will attempt to generate the corresponding code.
Intelligent code search: It allows you to search your codebase using natural language queries.
Built on VS Code: Cursor is based on Visual Studio Code, so it inherits many of VS Code's features and can use VS Code extensions.
Git integration: It includes built-in Git support for version control.
Multi-language support: Cursor works with various programming languages and frameworks.
Customizable AI settings: Users can adjust AI-related settings to suit their preferences.
Cursor aims to streamline the coding process by leveraging AI to assist developers with various tasks, from code generation to debugging and refactoring.
-
50Adding Sidebar and LangChain's color theme with Cursor ComposerVídeo Aula
Cursor Composer is a feature within the Cursor IDE that enhances the AI-assisted coding experience. Cursor Composer offers:
AI-powered code generation: It allows you to describe functionality in natural language and generates corresponding code.
Context-aware: Composer understands the context of your project and existing code, providing more relevant suggestions.
Interactive editing: You can iteratively refine the generated code through further prompts or manual edits.
Multi-file support: Composer can work across multiple files in your project, understanding and modifying related code as needed.
Language agnostic: It supports various programming languages and frameworks.
Customizable output: You can specify coding style preferences or project-specific requirements.
Cursor Composer aims to speed up development by handling boilerplate code, suggesting implementations, and assisting with complex logic, all while allowing developers to maintain control over the final output
-
51[NEW] Documentation Helper In ProductionVídeo Aula
-
62The GIST of LLMsVídeo Aula
What is Language Modeling?
Language modeling is the task of predicting the next word in a sentence.
It is similar to autocomplete or word suggestions we see in our day-to-day life.
The language model predicts the probability of the next word based on the previous words in the sentence.
Formal Definition of Language Modeling
Language modeling involves computing the probability distribution of the next word in a sequence of words.
The probability of the next word (x t+1) is calculated based on the sequence of words before it (X1, X2, ..., XT) and needs to be a part of the vocabulary (V).
Large Language Models: A Brief Overview
A large language model (LLM) is a language model trained on a huge amount of data.
LLMs are capable of predicting the probability of the next word with high accuracy.
They have gained immense popularity in recent times due to their ability to perform a variety of language-related tasks.
How Large Language Models Work
LLMs work by taking an input of words and predicting the probability of the next word.
They make their predictions based on the input provided and the probabilities learned during the training phase.
LLMs can sometimes generate output that is far-fetched from reality and simply not true due to the limitations of probability-based predictions.
-
63What is a Prompt? Composition of a formal promptVídeo Aula
What is a Prompt in AI Language Models?
A prompt is the input given to an AI model to produce an output.
It guides the model to understand the context and generate a meaningful response.
Components of a Prompt:
Instruction
The heart of the prompt that tells the AI model what task it needs to perform.
It sets the stage for the model's response, whether it's text summary, translation, or classification.
Context
Additional information that helps the AI model understand the task and generate more accurate responses.
For some tasks, context may not be necessary, but for others, it can significantly improve the model's performance.
Input Data
The information that the AI model will process to complete the task set in the prompt.
It could be a piece of text, image, or anything relevant to the task.
Output Indicator
Signals the AI model that we expect a response.
Sometimes implicit in the instruction, but sometimes explicitly stated.
-
64Zero Shot PromptingVídeo Aula
Here are the key points we'll cover:
Large language models and their immense knowledge base
What is zero shot prompting?
An example of a zero shot prompt
Why zero shot prompts are popular among AI beginners
The limitations of zero shot prompting
With zero shot prompting, AI models can generate outputs for tasks they haven't been explicitly trained on, using their pre-existing knowledge to perform the task based on the information provided in the prompt. However, this kind of prompt comes with its own set of limitations, such as accuracy and scope.
-
65Few Shot PromptingVídeo Aula
In this video, we will explore the concept of Few Shot Prompting, a technique used in prompt engineering that allows AI models to generate or classify new data by presenting them with a small number of examples or shots of a particular task or concept along with a prompt or instruction. Here are the main points we will cover:
What is Few Shot Prompting?
Few Shot Prompting is a prompt engineering technique that involves presenting the AI model with a small number of examples or shots of a task or concept to generate or classify new data that is similar to the examples provided. It is particularly useful in scenarios where there is limited data available for a given task or domain where data may be scarce.
How Does Few Shot Prompting Work?
Few Shot Prompting works by providing the AI model with a few examples of a particular task or concept and a prompt or instruction on how to generate or classify new data similar to the examples provided. It can quickly adapt models to new tasks and domains by fine-tuning existing models without requiring a large amount of new data.
Case Study: Zero Shot, One Shot, and Few Shot Prompting in Action
We will demonstrate the effectiveness of zero shot, one shot, and few shot prompting techniques in generating text-to-text descriptions for Blue Willow, an open source AI tool that generates images from text prompts. By comparing the outputs generated by each technique, we will see which one performed better according to our task of generating a good description to paint a picture.
-
66Chain of Thought PromptingVídeo Aula
Introduction to Chain of Thought
Explanation of Chain of Thought's purpose in improving LLM reasoning abilities
How Chain of Thought allows models to decompose complex problems into manageable steps
Standard Prompting Limitations
Examples of insufficient answers with standard zero-shot prompting
Explanation of zero-shot prompting
Chain of Thought Prompting
Explanation of Chain of Thought as a new prompting technique
Examples of Chain of Thought's success in solving complex reasoning problems
Comparison to human problem-solving methods
Zero-Shot and Few-Shot Chain of Thought Prompting
Explanation of zero-shot Chain of Thought prompting
Explanation of few-shot Chain of Thought prompting
Benefits and limitations of each method
-
67ReActVídeo Aula
In this video, we will explore the ReAct Prompting technique, a powerful approach to prompt engineering that combines reasoning and acting to accomplish complex tasks. Here are the main points we will cover:
What is ReAct Prompting?
ReAct Prompting is a technique that allows language models to reason and act upon a task to generate an output.
It is based on the chain of thoughts that the model can generate to accomplish a task.
How Does ReAct Prompting Work?
ReAct Prompting involves breaking down a task into multiple steps, reasoning the steps, acting upon them, and then completing the entire task.
The model can derive an action by accessing external sources or APIs, allowing it to accomplish more complex tasks.
Case Study: ReAct Prompting in Action
We will look at a research paper that demonstrates the power of ReAct Prompting in action.
The paper shows how a language model was able to derive the correct answer to a complex question by reasoning and acting upon it.
-
68Prompt Engineering Quick TipsVídeo Aula
How to Produce Prompts for Better LLM Responses
Incorporating Context for Coherent and Accurate Responses
Context provides relevance for generating better responses
Leaving context to the AI model could lead to off-topic or irrelevant responses
Defining a Clear Task for Unambiguous Results
Clear and precise task definitions provide better results
Ambiguous tasks can lead to confusion and lower performance
Example: Improving user experience of an e-commerce website
Iterating for Optimized Prompts
Iterations involve refining prompts and evaluating output
Refining prompts over iterations leads to optimized prompts
Taking the time to write effective prompts saves time in the long run
By following these low-hanging fruit tips for prompt engineering, you can improve the performance of your AI models and get better responses. Incorporating context, defining clear tasks, and iterating to refine prompts will lead to more accurate and relevant responses, saving you time and improving the overall performance of your AI models.
-
69Have a technical issue? WATCH THIS FIRST. I Promise this will help!Vídeo Aula
-
70Tweet API- tweepy.errors.Forbidden: 403 ForbiddenVídeo Aula
Exception has occurred: Forbidden
403 Forbidden
453 - You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve
File "/Users/justin/ownCloud/__LLM/udemy_langchain/ice_breaker/third_parties/twitter.py", line 27, in scrape_user_tweets
tweets = api.user_timeline(screen_name=username, count=num_tweets)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justin/ownCloud/__LLM/udemy_langchain/ice_breaker/ice_breaker.py", line 37, in <module>
print(scrape_user_tweets(username="@elonmusk"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tweepy.errors.Forbidden: 403 Forbidden
453 - You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-lev
-
71Pinecone: AttributeError: init is no longer a top-level attribute of pineconeVídeo Aula
-
72LangChain Version In Course (V0.3.3)Vídeo Aula
-
73LLM Applications in ProductionVídeo Aula
-
74LLM Application Development landscapeVídeo Aula
-
75[New] LLMs in Production: Privacy & Data RetentionVídeo Aula
-
76[New] Generative UI/UX featuring CopilotKit?Vídeo Aula
CopilotKit is an open-source platform for integrating AI copilots (assistants) into applications quickly and easily. In the context of generative UI, CopilotKit offers the following features:
Generative UI Components: CopilotKit allows developers to create dynamic user interfaces with AI-generated components within a chat UI. This is particularly useful when working with AI agents.
Real-time UI Updates: The platform enables real-time updates to the UI based on the AI agent's state and actions.
Custom Rendering: Developers can define custom rendering functions to display agent states or responses in the UI.
Relationship with LangGraph:
Integration Bridge: CopilotKit, specifically its CoAgents feature, acts as a bridge between LangGraph agents and user interfaces. LangGraph is a framework for building stateful, multi-step AI agents.
State Streaming: CopilotKit provides tools to stream the state of LangGraph agents to the frontend in real-time. This allows the UI to reflect the current state and progress of the AI agent.
Dynamic Interaction: It enables dynamic interactions between LangGraph agents and the user interface, allowing for a more interactive and collaborative AI experience.
Custom UI for Agent States: Developers can use CopilotKit to create custom UI components that represent different states or outputs of a LangGraph agent.
Simplified Integration: CopilotKit simplifies the process of connecting LangGraph-based AI agents to web applications, making it easier to create interactive AI experiences.
-
77Finished course? Whats next!Vídeo Aula
LLM OPS- LangSmith
LLM Security
Learning Resources
-
78[New] Official LangChain Academy CoursesVídeo Aula
-
79[New] Open Source LLMs VS Managed LLM Providers (Deepseek)Vídeo Aula
Open source models and managed LLMs both have their place in production applications, with the choice depending on specific project requirements and organizational constraints.
Open Source Models
Open source LLMs offer several advantages for production use:
1Cost-effectiveness: They can be significantly cheaper to operate, sometimes up to 30x less expensive than proprietary models[4].
Customization: Organizations can fine-tune models for specific tasks or domains, potentially outperforming general-purpose proprietary LLMs[4].
Control and privacy: Companies can host models on internal servers, ensuring data privacy and security[5].
Transparency: Users have insight into the model's inner workings, aiding in research and development[8].
However, open source models also present challenges:
Expertise required: Significant in-house knowledge is needed for deployment, maintenance, and optimization[9].
Infrastructure costs: While the model itself is free, companies must invest in hardware and operational resources[9].
Performance gaps: Some open source models may lag behind proprietary ones in areas like output quality and instruction following[4].
Managed LLMs
Managed LLMs, typically proprietary models offered as a service, have their own set of advantages:
Ease of use: They offer simple integration and deployment, reducing the need for extensive in-house expertise[1].
Reliability and support: Vendors provide professional support, updates, and optimizations[9].
Compliance: Some managed services offer pre-configured compliance measures, beneficial for regulated industries[1].
Performance: Proprietary models often lead in tasks requiring advanced reasoning and precise instruction following[4].
However, managed LLMs also have drawbacks:
Higher costs: Licensing fees or usage-based pricing can be substantial, especially at scale[9].
Limited customization: Users have less control over model architecture and training data[8].
Data privacy concerns: Sending sensitive data to third-party services may not be suitable for all organizations[6].
Hybrid Approach
Many organizations are adopting a hybrid approach, leveraging both open source and proprietary models. For example, using open source models for 95% of queries and reserving more expensive proprietary models for the remaining 5% that require higher performance[4].
In conclusion, the choice between open source models and managed LLMs depends on factors such as budget, required performance, data privacy needs, and in-house expertise. Open source models offer cost savings and customization but require more management, while managed LLMs provide ease of use and reliability at a higher cost. A hybrid approach can often provide the best balance for many production applications.
Citations:
[1] https://www.civo.com/blog/open-source-vs-proprietary-llms
[2] https://www.restack.io/p/open-source-llm-challenges-answer-production-cat-ai
[3] https://www.datacamp.com/tutorial/deploying-llm-applications-with-langserve
[4] https://www.anyscale.com/blog/open-source-llms-viable-for-production-or-a-low-quality-toy
[5] https://www.mercity.ai/blog-post/comprehensive-comparison-of-llms-8-2023
[6] https://www.seldon.io/deploying-large-language-models-in-production-llm-deployment-challenges
[7] https://whylabs.ai/learning-center/llm-deployment-and-observability/llm-deployment-monitoring-and-observability-overview
[8] https://ubiops.com/openai-vs-open-source-llm/
[9] https://datasciencedojo.com/blog/open-source-llm/
[10] https://www.scalegen.ai/blog-v1.0/llms-in-production-101-navigating-the-challenges
[11] https://www.qwak.com/post/building-llm-applications-for-production
[12] https://www.reddit.com/r/LocalLLaMA/comments/1h0bh2r/enterprise_challenges_in_deploying_opensource/
