Create a RAG Chain using LangChain 0.1 (New version)

2024 ж. 13 Мам.
19 989 Рет қаралды

In this video we explore a crash course of the new Langchain version (0.1.0) in python. This will allow you to create RAG chains in Langchain to chat with your documents.
We will be showcasing LangChain, a revolutionary Python library that empowers developers to create context-aware and reasoning-driven applications using powerful language models.
In the video, we will create several chains using the new version of LangChain to chat with a website. The final chain that we build here is a history-aware chain that takes the history of the conversation into account to answer your questions.
----- LINKS
📒 Google Colab: colab.research.google.com/dri...
👉 Official LangChain Documentation: python.langchain.com/docs/get...
💬 Join the Discord Help Server - link.alejandro-ao.com/HrFKZn
❤️ Buy me a coffee... or a beer (thanks): link.alejandro-ao.com/l83gNq
✉️ Join the mail list: link.alejandro-ao.com/AIIguB
-------------------
🔗 What is LangChain?
LangChain is a framework designed to elevate your applications to new heights. It enables the creation of context-aware applications by connecting language models to various sources of context, allowing them to reason and provide intelligent responses.
🚨 Quickstart Highlights:
👉 1. Get Set Up with LangChain: Learn how to seamlessly set up the LangChain ecosystem to kickstart your development journey.
👉 2. Basic Components Mastery: Explore the fundamental components of LangChain, including prompt templates, models, and output parsers. Harness the power of these components to enhance your applications.
👉 3. LangChain Expression Language: Delve into the protocol that serves as the backbone of LangChain. Discover how the LangChain Expression Language (LCEL) facilitates component chaining, enabling seamless integration and communication between different elements.
👉 4. Build Your First Chains: Follow our step-by-step guide to construct a set of simple yet powerful chains using LangChain. Witness firsthand the capabilities that this innovative library brings to your projects.
🛠️ Why LangChain?
LangChain opens up a world of possibilities, allowing you to create intelligent applications that understand context and make informed decisions. Whether you're a seasoned developer or a coding enthusiast, LangChain is your gateway to building the next generation of language-powered applications.
👨‍💻 Who is This For?
This Quickstart tutorial is perfect for developers looking to harness the potential of language models in their applications. No matter your experience level, this guide provides a straightforward introduction to LangChain's capabilities.
🚀 Level Up Your Development Game with LangChain!
Don't miss out on this opportunity to revolutionize your application development process. Join us in this Quickstart tutorial and unlock the true potential of language models. Get ready to code smarter, reason better, and create applications that stand out!
⏰ Timestamps
0:00 Intro
1:19 Installing Langchain
4:06 Get API Keys and Initialize LLM
6:40 Create Your First Chain
10:22 Add Output Parser to Your Chain
13:21 What is a RAG Chain
14:55 Load Text From a Website
19:35 Create a Vector Store
22:44 Create a Document Chain
29:04 Create a RAG Chain
33:24 Retriever Chain with History
43:06 RAG Chain with History
50:35 Conclusion
🚀 #LangChain #PythonLibrary #LanguageModels #DeveloperTutorial

Пікірлер
  • 💬 Join the Discord Help Server: link.alejandro-ao.com/981ypA ❤ Buy me a coffee (thanks): link.alejandro-ao.com/YR8Fkw ✉ Join the mail list: link.alejandro-ao.com/o6TJUl

    @alejandro_ao@alejandro_ao3 ай бұрын
  • Awesome. I'm excited that you are back !!! Thanks Desperately waiting for the next chapter 😀

    @guruprasannasuresh3893@guruprasannasuresh38933 ай бұрын
    • thank you! it's coming next week :)

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Thanks for the update of Langchain. Quite a lot changes in the syntax. Looking forward with open source llm and embeddings with agents using the new Langchain👍

    @henkhbit5748@henkhbit57483 ай бұрын
    • sure thing, it's on the way!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • I am impressed with your video. it was Simple, practical, and easy to follow, I've been watching tutorials on how to use Langchain but this is the best I've seen so far. I'm waiting for the app version. Keep doing the good work Alejandro.

    @reubensolomon9047@reubensolomon90473 ай бұрын
  • super, i was doig the same thing yesterday and then yt showed me your video:).... exellent work , WATING FOR THE NEXT CHAPTER

    @cheattube@cheattube3 ай бұрын
    • we're in sync 😎

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Thanks so much bro for all your great videos! I got to know your channel only 2 weeks ago, and since then, I have been watching and practising your tutorials from early 2023. Please don't stop thw great work! Can't wait to watch the app version of thia RAG tutorial with agent 😃

    @samcavalera9489@samcavalera94893 ай бұрын
    • thank you man, it means a lot! keep it up! we are living in exciting times

      @alejandro_ao@alejandro_ao3 ай бұрын
    • @@alejandro_ao 🙏🙏🙏

      @samcavalera9489@samcavalera94893 ай бұрын
  • Alejandro, thank you. Excellent work.

    @ratral@ratral3 ай бұрын
    • i´m glad you liked it!! there's much more to come

      @alejandro_ao@alejandro_ao3 ай бұрын
  • And you are back! This made my day.

    @BrandonFoltz@BrandonFoltz3 ай бұрын
    • hello Brandon! thanks! :) so nice to see you around here again!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Thanks AO - looking forward to your next video!

    @bwilliams060@bwilliams0603 ай бұрын
    • thank *you*!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Awesome. You have always somehting great to offer us.

    @SanjeevKumar-dr6qj@SanjeevKumar-dr6qj3 ай бұрын
    • it's my pleasure! there's more to come

      @alejandro_ao@alejandro_ao3 ай бұрын
  • thanks for making these awesome videos, it helps alot to understand the concepts and you are very clear n concise. keep it up!🎉

    @mygicarskrsk4465@mygicarskrsk44653 ай бұрын
    • i'm glad to hear that this is useful to you! will do!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Thanks man, waiting for next part

    @harshyadav1190@harshyadav11903 ай бұрын
    • Coming soon!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • So interesting! Nice to see you again

    @Matepediaoficial@Matepediaoficial3 ай бұрын
    • thanks! nice to see you too :)

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Thank you for this. With the recent changes it's been so hard to find updated tutorials.

    @Sarkkoth@Sarkkoth3 ай бұрын
    • No worries!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Thank you brother. Truely saved my time.

    @swiftmindai@swiftmindai3 ай бұрын
    • Glad to hear it!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Thank you for this video. It was so informative and well-made.

    @siavoshoon@siavoshoon3 ай бұрын
    • thanks! i'm glad it was useful!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Super useful man, thanks

    @smtabatabaie@smtabatabaieАй бұрын
    • thanks man, glad it helped!!

      @alejandro_ao@alejandro_aoАй бұрын
  • Totally Awesome, thank you.

    @jimg8296@jimg82963 ай бұрын
    • glad you liked it!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Best explanation I've seen!

    @alessandroabaza4118@alessandroabaza41183 ай бұрын
    • thanks!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Thanks for the video tutorial.

    @michaelwallace4757@michaelwallace47572 ай бұрын
    • No worries!

      @alejandro_ao@alejandro_ao2 ай бұрын
  • Dude, I love your content. Your work addresses real world problems which is what I have been looking for. Thank you! Also you are very good at explaining these advanced terms to dumb it down for us beginners ❤. Can you make some videos about image processing with langchain?

    @arashkoushkebaghi1432@arashkoushkebaghi1432Ай бұрын
    • thank you for your support!! i will be making some videos about image processing indeed. it's something that i wanted to do for a while

      @alejandro_ao@alejandro_aoАй бұрын
  • bro thanks alot, this is soooo useful

    @lordareello8221@lordareello82213 ай бұрын
    • that's great to hear! you're welcome :)

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Great Video! I actually coded along with the whole thing! I've been trying to get to grips with the new update and the LCEL syntax. Some topics I would love to see videos for are: 1. Runnables, RunnableParallel, RunnablePassthrough(), Runnable protocol... So many runnable things! : ) 2. Interface, is that like a wrapper for things you chain together? like Prompt | LLM | etc... 3. I'm still confused about the difference between a Chain and an Agent and how/when they work together, like can you use chains with agents or vice versa... 4. Finally, I'd love to see a video for a Conversational Agent that does function calling/tools, where the chat history is sent to a vector db and can then be retrieved as context, so that the agent can learn things over time. Thats my wish list! Thanks again.

    @jacobgoldenart@jacobgoldenart3 ай бұрын
    • hey Jacob, i'm glad you found this useful! thanks a lot for the list! i'll try to make videos about this. you can join the discord if you want to follow the news of the channel closely: link.alejandro-ao.com/discord

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Thanks for the video, man!! It's great! Your content is very good and you also provide a great explanation!! Keep going!! Also, could you create a tutorial with a RAG agent with this new version of langchain? 😊

    @danielmacedo1910@danielmacedo19103 ай бұрын
    • thank you man! will do, it's coming soon!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • "I come from across the ocean, where we lack video tutorials, so I'm really fortunate to have found such high-quality videos. More importantly, I hope everything goes well for the creator😉"

    @oooooohmygoood-xu1nm@oooooohmygoood-xu1nm3 ай бұрын
    • hey there thank you

      @alejandro_ao@alejandro_ao3 ай бұрын
  • thank god you still make videos

    @kaidone1@kaidone13 ай бұрын
    • thanks! i’m doing this full time now! let me know what you want to see next :)

      @alejandro_ao@alejandro_ao3 ай бұрын
    • @@alejandro_ao i failed to save a vectorstore locally and use them with a different conversation chain. Main goal was to save money, because it was the same big file I processed, just different questions. I think you made a video with cloud solution once, but I would prefer a local one

      @kaidone1@kaidone13 ай бұрын
    • @@kaidone1 there's a chapter about this next week's video :)

      @alejandro_ao@alejandro_ao3 ай бұрын
  • very informative video

    @laxmiagarwal3285@laxmiagarwal328523 сағат бұрын
    • thanks!

      @alejandro_ao@alejandro_ao20 сағат бұрын
  • Loving the content! Thanks! Also, Can you create this with a streamlit interface?

    @neilmcd123@neilmcd123Ай бұрын
    • here you go! Tutorial | Chat with any Website using Python and Langchain (LATEST VERSION) kzhead.info/sun/ldmpqJRwkZmJeZ8/bejne.html

      @alejandro_ao@alejandro_aoАй бұрын
  • Thank you for this great Tutorial! As far as I know, FAISS uses the inner product (dot product) and L2 (Euclidean) distance as standard metrics for similarity search. However, I'm curious if it's possible to use cosine similarity with FAISS instead. Would utilizing cosine similarity be more beneficial, especially considering its advantages with higher-dimensional vectors?

    @moonly3781@moonly37813 ай бұрын
  • Hey Please upoad the Agent and other stuffs video too , its very helpful!! Also a request to cover Langsmith and Langserve !! Itll give a upperhand

    @meetvasa6955@meetvasa6955Ай бұрын
  • Great Tutorial! How can we modify this so that we get context from all the hyperlinks inside a website! Is it possible??

    @shivamrawat108@shivamrawat108Ай бұрын
  • Awesome videos….just wondered why you used colab instead of the python runtime environment explained in some video before? Presumably to execute the code samples on the fly? Can you explain when to use either of these? Not sure I totally grasped the Faiss step? Anyhow would love some video’s in future on training your own models and some on the use of hugging face? Keep up the good work

    @rmjjanssen2645@rmjjanssen26453 ай бұрын
    • hello there! actually, in the next video i'm showing how to do this with a local python runtime! you're right, the idea behind using a google colab is precisely to execute the code snippets on the fly. also to be able to share the code with you in a single link :) for a real app, you would use your python runtime. the video about that is coming tomorrow!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Good video 👍

    @juanmanuelcarrillo7731@juanmanuelcarrillo7731Ай бұрын
    • thanks!

      @alejandro_ao@alejandro_aoАй бұрын
  • Can we use load qa chain function for RAG ?

    @amineinfo5810@amineinfo5810Ай бұрын
  • Amazing videos! Would you please do one tutorial about how to bring the data from an API and make a vector store?

    @MyXRLearning@MyXRLearning3 ай бұрын
    • thanks! what kind of data would you like to fetch from the API?

      @alejandro_ao@alejandro_ao3 ай бұрын
    • @@alejandro_ao Thanks for your reply. I'm looking to fetch data in the form of JSON structures and then go from that to make the vector storage in order to make a RAG about the fetched data. :)

      @MyXRLearning@MyXRLearning3 ай бұрын
  • How to deploy the conversational retrieval chain using langserve so that I can play around with langserve playground feature. I tried to create the chain specifying input type as- class Input(BaseModel): input: str chat_history: List[BaseMessage] . But I am getting unknown messag type error when it is trying to run the retriever_prompt.

    @NavjotMakkar@NavjotMakkar2 ай бұрын
  • Really really nice video. What about the create an agent phase?

    @LORENZOARCANGELI-rp4hl@LORENZOARCANGELI-rp4hl3 ай бұрын
    • Thank! Coming soon!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • Could you explain the difference between conversation retrieval chain and retrieval qa chain?? And which is better with a memory component?

    @priyanshuaggarwal9037@priyanshuaggarwal90373 ай бұрын
    • hey there. sure. the regular retrieval chain that i built here does not consider the previous messages of the conversation. it's like you were starting a new conversation with every new message. on the other hand, the conversational chain that we built here, takes into account the past messages of the conversation every time. that's why in the example i sent the chat history alongside the message "tell me more about it!". if we send that message to the regular retrieval chain, it will have no idea what we are talking about.

      @alejandro_ao@alejandro_ao3 ай бұрын
  • That you so much for this video, please can you create a video of using slack channel or google chat data with LangChain?

    @chibuzoemelike6403@chibuzoemelike64033 ай бұрын
    • no worries! you mean like asking questions about a slack conversation history? or more like a chatbot inside slack?

      @alejandro_ao@alejandro_ao3 ай бұрын
    • @@alejandro_ao yeah queries about slack history, this bot can just be outside slack, maybe a web page

      @chibuzoemelike6403@chibuzoemelike64033 ай бұрын
    • @@alejandro_ao Yes asking questions about a channel conversation history. The chatbot can be outside slack or integrated to slack.

      @chibuzoemelike6403@chibuzoemelike64033 ай бұрын
  • CSV Was removed how to perform CSV Al in lahgchain now please video

    @KARAN_RANA36@KARAN_RANA362 ай бұрын
    • yeah, that video really needs an update. i'm working on it!

      @alejandro_ao@alejandro_ao2 ай бұрын
  • Seems that agents are built on top of langchain chains. So do you need this if you are using agents?

    @udaynj@udaynj24 күн бұрын
    • hey there, agents are similar to chains, but they are not actually built on top of them. they use LCEL as well and can perform multi-step procedures, but they are much more flexible. a chain will always have the steps pre-defined (as you see here). an agent will use a LLM to decide the next step to take. i hope this helps!

      @alejandro_ao@alejandro_ao24 күн бұрын
    • @@alejandro_ao Thanks Alejandro. That helps. One more question if you don't mind - can you use agents to chain LLM and non-LLM models, since in the real world, not everything will need an LLM model. So say I have a xgboost time series model, but want to interconnect that with an LLM, is that possible? If so, would love to see an example of that

      @udaynj@udaynj23 күн бұрын
    • @@udaynj Absolutely! What you would have to do here is, first, decide if you are going to create a chain or an agent. If this is a chain, then you can create a function that applies your time series model and use it inside your chain. In this video, I created a custom function and added it inside a chain (not a ML model, but it would work pretty much the same): kzhead.info/sun/bMecnJWXjqdoZ4k/bejne.html If you are going for an agent, you will have to create tool that applies that time series model. This would be pretty similar to the function for a chain, but it would be decorated with the decorator @tool by langchain and passed in to your agent. Here is a video where I show how to create a team of agents and create their tools (you would have to create your own function that outputs the prediction of your time series model): kzhead.info/sun/nqaRiaqZkWJ7gWg/bejne.html cheers!

      @alejandro_ao@alejandro_ao23 күн бұрын
    • @@alejandro_ao Thanks for the replies and the video links, Alejandro. Appreciate the detailed responses. You are an amazing teacher. Cheers from the US

      @udaynj@udaynj22 күн бұрын
  • классное видео! есть с чего начать

    @Vedmalex@Vedmalex3 ай бұрын
    • Спасибо!

      @alejandro_ao@alejandro_ao3 ай бұрын
  • which model are you using? is it GPT-3.5

    @laxmiagarwal3285@laxmiagarwal328523 сағат бұрын
    • in this video, mostly gpt3-turbo, yes. but you can change that as a parameter when you initialize your LLM

      @alejandro_ao@alejandro_ao20 сағат бұрын
  • What is the limit of the documents we can train with this method ?

    @CherifRahal@CherifRahal3 ай бұрын
    • there is virtually no limit! however, for super long knowledge bases, you might need some additional tuning rather than a simple RAG algorithm. this is true especially if you have several thousand pages worth of knowledge and the concepts are scattered across them. i'll make some tutorials on that

      @alejandro_ao@alejandro_ao3 ай бұрын
    • @@alejandro_ao Thanks, I have like word documnets, sharepoint and pdf, I just want to search for something without m ehaving to go through each file, just interact with a simple chat interface. And also I work usually with Vscode, do you think it is good or should I switch to Jupiter ?

      @CherifRahal@CherifRahal3 ай бұрын
  • Do you prefer that I use Google Colab in the videos or that I create an app with a graphical user interface?

    @alejandro_ao@alejandro_ao3 ай бұрын
    • An app with GUI will be most appreciated mate. Thanks

      @tonyblack2141@tonyblack21413 ай бұрын
    • An app will be great

      @chibuzoemelike6403@chibuzoemelike64033 ай бұрын
    • UI will be much better.

      @sanjayojha1@sanjayojha13 ай бұрын
    • GUI is the most preferrable and the way you organize and converting into the final product stands out of all. Thanks

      @guruprasannasuresh3893@guruprasannasuresh38933 ай бұрын
    • Great video! Would love to see a video with a GUI.

      @Mercurion42@Mercurion423 ай бұрын
  • Personally I find Langchain difficult to use and the documentation is pretty bad. I think Microsoft autogen approach to framework is much better.

    @tancheeken@tancheeken3 ай бұрын
    • The layer of abstraction is really annoying. Have you tried alternatives like llamaIndex and haystack?

      @sanjayojha1@sanjayojha13 ай бұрын
    • LlamaIndex is awesome, i'm preparing some hands-on tutorials on it

      @alejandro_ao@alejandro_ao3 ай бұрын
    • Also create a video explaining the difference between them please

      @sachinp8847@sachinp88473 ай бұрын
KZhead