
單元目標:
在這個單元,我們將透過 clone a branch、設定 PyCharm、安裝相關套件和模組以及建立 Icebreaker 檔案來設置我們的專案。我們也會介紹 LangChain 框架的基本概念。
Topics covered:
涵蓋主題:
Cloning a Git branch:
我們將使用 Git 指令介面從 main repository 中 clone a branch 到本地端。這個步驟非常重要,因為我們需要在特定版本的程式碼上進行。
設定 PyCharm:
我們將設定 PyCharm,包括設定 Python interpreter 和建立虛擬環境。這對於確保專案與一致且正確的 interpreter,並且有一個乾淨的工作環境來進行開發是至關重要的。.
安裝相關模組套件:
我們將使用 pip 安裝專案所需的依賴套件,包括 LangChain 框架。這個步驟非常關鍵,能確保我們有所有必要的套件來開發應用程式。
介紹 LangChain 框架:
我們將簡要介紹 LangChain 框架,說明其抽象概念如「chain」等,並解釋為何這個框架在開發者之間如此受歡迎。
建立 ice_breaker.py 檔案:
我們將建立一個 Icebreaker 檔案,用來儲存所有 LangChain 的程式碼。我們會從一個預設的函式開始,並透過 Python 終端機運行它,確保一切正常運作。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.
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.
Open Source Models in GenAI Applications
Ollama
Mistral by Mistral AI
Llama3 by Meta
The course is filmed in version V0.1.14
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.
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
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 AgentType
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.
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.
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.
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.
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
Introduction:
An Output Parser is a class that structures language model responses by implementing two methods: get_format_instructions() and parse(). The former method returns a string that contains instructions on how the language model's output should be formatted, while the latter method takes in a string response from the language model and parses it into a specific structure.
Pydantic Output Parser
The Pydantic Output Parser is a type of Output Parser that allows users to specify a schema and request LLMs for outputs that conform to that schema.
We can use Pydantic to declare the python data model, and the Pydantic Output Parser will convert the LLM's response into a structured object that conforms to the schema. This can be useful for handling complex output from LLMs, or if we want our output to be ingested with other systems.
Using Pydantic Output Parser
To use the Pydantic Output Parser, users can define their desired data structure using Pydantic's BaseModel, similar to a Python dataclass but with actual type checking and coercion.
We can then define a query intended to prompt the LLM to populate the data structure.
The Pydantic Output Parser can be instantiated with the Pydantic object representing the desired data structure. A PromptTemplate can be set up with instructions for how the LLM should generate a response, and the Pydantic Output Parser can be used to generate format instructions for the PromptTemplate.
The PromptTemplate can then be used to format the user query and format instructions into a prompt, which can be passed to the LLM to generate a response.
The response can then be parsed using the PydanticOutputParser, which will convert it into a structured object that conforms to the specified schema.
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 Server
We 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.
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.
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.
Introduction:
In this video, we'll be exploring how to use local vectorstores to load and retrieve PDF documents using
LangChain and FAISS
Setting 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
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.
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.
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.
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.
Implementing a RetrievalQA LangChain chain
We will create a RetrievalQA chain using LinkChain and the LM.
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.
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.
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.
ConversationBufferMemory
ConversationBufferMemory is a memory utility in the langchain package that allows for storing messages in a buffer and extracting them as a string or a list of messages. It is useful for storing conversation history in a chatbot or conversational AI system.
It simply keeps a buffer of all the interactions in a conversation. It does not have a limit on the number of interactions it can store
ConversationBufferWindowMemory
ConversationBufferWindowMemory is a type of memory in the LangChain package that keeps a list of the interactions of a conversation over time, but only uses the last K interactions. This can be useful for keeping a sliding window of the most recent interactions, so the buffer does not get too large. On the other hand, ConversationBufferMemory is a different type of memory that simply keeps a buffer of all the interactions in a conversation. It does not have a limit on the number of interactions it can store.
ConversationTokenBufferMemory
ConversationTokenBufferMemory is a buffer for storing conversation memory that keeps a buffer of recent interactions in memory, and uses token length rather than the number of interactions to determine when to flush interactions. It is a class in the langchain.memory.token_buffer module and is used in conversational AI applications to store and retrieve conversation history.
ConversationSummaryMemory
ConversationSummaryMemory is a type of memory utility in the LangChain package that creates a summary of the conversation over time. It condenses information from the conversation over time and can be useful for keeping track of the conversation history. It differs from other memory utilities in LangChain in that it specifically focuses on creating a summary of the conversation, whereas other memory utilities may focus on different aspects of the conversation, such as keeping a buffer of recent interactions or using token length to determine when to flush interactions.
ConversationSummaryBufferMemory
ConversationSummaryBufferMemory is a type of memory utility in the LangChain package that keeps a buffer of recent interactions in memory and compiles them into a summary, using token length rather than the number of interactions to determine when to flush interactions. It differs from other memory utilities in that it combines the functionality of keeping a buffer of recent interactions with the ability to summarize the conversation over time. Other memory utilities in the package include ConversationSummaryMemory, which creates a summary of the conversation over time, and ConversationBufferMemory, which keeps a buffer of recent interactions in memory.
Entity Memory
Entity Memory is a memory module in LangChain that remembers information about specific entities. It uses LLMs to extract information on entities and builds up its knowledge about that entity over time. It is designed to be used in chains and provides easy ways to incorporate its utilities into chains. Compared to other memory utilities in LangChain, Entity Memory is focused on remembering information about specific entities, while other memory utilities are more general and can be used to manage and manipulate previous chat messages. Additionally, Entity Memory is designed to be used in chains, while other memory utilities can be used in a variety of contexts.
VectorStore-Backed Memory
VectorStore-Backed Memory is a memory component in LangChain that stores memories in a VectorDB and queries the top-K most “salient” docs every time it is called. It differs from most of the other Memory classes in that it doesn’t explicitly track the order of interactions. In this case, the “docs” are previous conversation snippets. This can be useful to refer to relevant pieces of information that the AI was told earlier in the conversation.
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.
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.
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.
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.
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
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.
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.
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
課程已重新錄製並支援 LangChain 版本 0.3.0,並經由 Steve Lai 全新中文配音(後續進行包含繁體與簡體中文字幕校正)。
讓用中文母語的人能夠更容易並更快速的學習。
课程已重新录制并支持 LangChain 版本 0.3.0,并经由 Steve Lai 全新中文配音(后续进行包含繁体与简体中文字幕校正)。让以中文为母语的人能够更加轻松、快速地学习。
COURSE WAS RE-RECORDED and supports- LangChain Version 0.3.0, and with brand new Mandarin Chinese voiceover by Steve Lai (followed by traditional and simplified Chinese subtitle proofreading). This allows native Chinese speakers to learn more easily and quickly.
---
歡迎來到第一門 LangChain Udemy 課程 - 釋放 LLM 的力量!
這是一堂全方位課程,目的是要教你如何快速運用 LangChain 函式庫來開發 LLM 應用。
本課程將提供你開發跨領域 LLM 解決方案所需的技能與知識。
欢迎来到第一门 LangChain Udemy 课程 - 释放 LLM 的力量!
这是一门全方位课程,旨在教你如何快速运用 LangChain 函数库来开发 LLM 应用。
本课程将为你提供开发跨领域 LLM 解决方案所需的技能与知识。
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.
---
(2025/01)重要聲明:中文配音目前完成至第五章節(講座 39),共約 4 小時 33 分鐘,包含第一個 LangChain 應用程式,以及 ReAct prompt 深入探討、RAG 等內容。後續章節中文配音將陸續完成,我們也會隨時通知各位最新狀況。
(2025/01)重要声明:中文配音目前完成至第五章节(讲座 39),共计约 4 小时 33 分钟,包含第一个 LangChain 应用程序,以及 ReAct prompt 深入探讨、RAG 等内容。后续章节的中文配音将陆续完成,我们也会随时通知各位最新进展。
(Jan 2024) Important Announcement: The Chinese voiceover is currently completed up to Chapter 5 (Lecture 39), totaling approximately 4 hours and 33 minutes. This includes the first LangChain application, an in-depth exploration of ReAct prompts and RAG. The Chinese voiceover for subsequent chapters will be completed gradually, and we will keep everyone updated on the latest progress
---
請注意,這不是入門課程。本課程假設你已具備軟體工程背景,且精通 Python。我會使用 Pycharm IDE,但你可以選用任何 IDE,因為我們只會用到像是 debug 和 running scripts 這類的基本功能。
在本課程中,你將從零開始,一路建構可真實實際執行的 LLM 所驅動的應用程式。課程內容將圍繞在這三個主要的應用程式:
破冰神器 Ice Breaker- 基於 LangChain agent 所開發的應用程式,只要輸入一個名字,就能在 Google 上搜尋對方的 Linledin 和 twitter 檔案,抓取網路上的相關資訊,並產生客製化的對話開場白。
文件助手 Documentation Helper - 為 python package 文件建構一個 chatbot 聊天機器人。 (當然也可以用於任何你想要的資料)
精簡版 ChatGPT code 解讀器
Prompt Engineering 理論篇章
请注意,这不是一门针对初学者的课程。本课程假设你已具备软件工程背景,并且精通 Python。我会使用 Pycharm IDE,但你可以使用任意编辑器,因为我们只需要用到诸如 debug 和 running scripts 这些基本功能。
在本课程中,你将从零开始,一路构建可真实落地执行的 LLM 驱动应用程序。课程内容将围绕以下三个主要应用程序:
破冰神器 Ice Breaker
基于 LangChain agent 所开发的应用程序,只需输入一个名字,即可在 Google 上搜索对方的 Linkedin 和 twitter 资料,抓取网络上的相关信息,并生成个性化的对话开场白。
文件助手 Documentation Helper
为 python package 文档构建一个聊天机器人。(当然也可以用于任何你想要处理的数据)
精简版 ChatGPT code 解读器
另外,还包含一部分 Prompt Engineering 的理论篇章。
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, LangChain Expression Language
LangSmith
Intro to LangGraph
FireCrawl
GIST of Cursor IDE
Cursor Composter
Curser Chat
---
在課程中,你將透過實作練習和真實專案,鞏固所學概念和技術。學完課程後,你將能熟練運用 LangChain 開發強大、高效能且多元的 LLM 應用。
這不只是一堂課,更是一個社群。除了終身課程存取權,你還將獲得:
與講師一對一的故障排除 troubleshooting 支援
Github links,提供額外的 AI 資源、常見問題和疑難排解指南
課程持續更新與改進,無額外費用
在课程中,你将通过实战练习和真实项目,巩固所学概念和技术。学完课程后,你将能够熟练运用 LangChain 来开发强大、高性能且多元的 LLM 应用。
这不仅是一门课程,更是一个社区。除了课程的终身访问权,你还将获得:
与讲师的一对一故障排除(troubleshooting)支持
Github links,提供额外的 AI 资源、常见问题解答和故障排除指南
课程不断更新与改进,无需支付额外费用
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
No extra cost for continuous updates and improvements to the course
---
免責聲明
再次強調,這不是入門課程。本課程假設你已有軟體工程背景,且精通 Python。我會使用 Pycharm IDE,但你可以選用任何編輯器,因為我們只會用到像是像是 debug 和 running scripts 這類的基本功能。
課程的第一個專案(破冰神器 Ice-Breaker)需要使用第三方 API,包括 ProxyCURL、SerpAPI、Twitter API,這些通常都是付費服務。但所有這些第三方平台都有免費額度,我們將用於開發和測試的儲存。
免责声明
再次强调,这不是一门针对初学者的课程。本课程假设你已有软件工程背景,并且精通 Python。我会使用 Pycharm IDE,但你可以选择任何编辑器,因为我们只需要用到类似 debug 和 running scripts 这样一些基本功能。
课程的第一个项目(破冰神器 Ice-Breaker)需要使用第三方 API,包括 ProxyCURL、SerpAPI、Twitter API,这些通常都是付费服务。但这些第三方平台都有免费额度,我们将在开发和测试中使用它们的免费配额。
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-
ProxyCURL, 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.