Difference between langchain and rag

hi i’m a student that study language model. I’m curious what the difference is between langchain and rag. I understand that rag is a part of langchain, but if using external data, both langchain and rag can do so. So what is the difference between the two(using rag with langchain or not use rag but only langchain)? Thanks in advance for answering

RAG: retrieval-augmented generation. That is a technique to passively examine the the latest user input and the context of conversation, and then use embeddings or other search technique to fill the AI model context with specialized knowledge relevant to the topic. Usually used for making an AI that can answer about closed-domain problems, such as company knowledgebase.

Langchain is instead an agent. It gives the AI multiple iterations it can perform with multiple semi-autonomous steps until a job is completed. That can be improving an answer until it is optimum, or can be actions fulfilled by multiple calls, like browsing pages or documents (although this is best done by native tuning like “functions”, not by prompting alone). Far more expensive and possible to run out of control against your account balance.


Agents is a part of Langchain.

As RAG has already been explained. Langchain is library in Python that acts as an interface between different language models, vector stores and all kinds of libraries. It makes it easier to build RAG models and other LLM solutions.

Note that it is LLM model agnostic and is not reliant on one single LLM provider, like OpenAI.