My first Day and why LangChain

In the world of emerging AI, the future is unpredictable, but one thing is certain: there will be a shift towards AI. Those who understand AI will thrive, while others may struggle. As a newcomer, I wondered what to learn and where to start, and I discovered Generative AI
Today’s Learning
Generative AI
GenAI is the type of artificial intelligence that generates some type of content such as image video text music etc by learning from existing data and mimicking human creativity.
There are two perspective of GenAI
Builder’s perspective:
E.g. RLHF, Pretraining, Quantization, Fine Tuning
User’s Perspective
E.g. Prompt Engineering, AI Agents, Vector Databases, RAG, Fine Tuning
Agentic AI
Agentic AI is an artificial intelligence system designed to perform tasks with minimal human supervision. It consists of one or more AI agents (yes, there is a difference between AI agents and Agentic AI) that are created to carry out specific tasks. These agents have their own "brains," usually based on large language models.
Suppose you want to make a agentic ai that can read pdf documents and it has chat feature in it. You can upload document, read it and chat with a bot asking query about the document.
System design of this application
Create a doc reader (pdf) with chatbot feature. User can ask about the pdf from the chatbot.
System design:
Text splitter: Breaks the PDF text into parts, such as splitting each page.
Embedding: Converts each page into vectors using various embedding techniques.
Storage: Saves these embeddings in a database for future use.
User query: Converts the user's query into a vector.
Semantic search: Finds the page embeddings that are closest to the user's query embedding. For example, if the embedding is a 100-dimensional vector, semantic search selects pages with the smallest distance to the user's query vector.
System query: Combines the selected pages and the user's query.
Model processing: Sends this system query to the model's "brain," which should understand natural language and generate text.Challenge 1
How to Develop a Brain
To achieve this, we can use LLMs (Large Language Models). We don't need to build these models ourselves because major AI companies like OpenAI have developed APIs for their LLMs. We can use these APIs and pay based on the number of requests.
Another Challenge
The system consists of many components, and we need to perform several tasks.
Components: AWS Cloud, document loader, embedder, database
Tasks: Save on AWS Cloud, load documents, embed, query the database
Writing code for all of this from scratch can be overwhelming. However, LangChain provides a solution to this problem.
What LangChain Provides:
Here are some of its features:
Concept of Chain: You can link a series of tasks in LangChain, even creating complex chains.
Model Agnostic Development: You don't have to rely on specific models. If you want to use AWS, GCP, OpenAI, or Gemini, you just need to change a line of code.
Complete Ecosystem: Includes memory and state handling, such as remembering previous chats for context.
What You Can Build with LangChain:
AI agents
Conversational chatbots
Knowledge assistants
Summarization/Research helpers
Task automation
Alternatives to LangChain:
Llamaindex
Heystack
Subscribe to my newsletter
Read articles from Satyam Rai directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
