वेक्टर डेटाबेस के साथ RAG स्टोरेज और रिट्रीवल

LangChain के साथ LLM एप्लिकेशन विकसित करना

Jonathan Bennion

AI Engineer & LangChain Contributor

RAG डेवलपमेंट स्टेप्स

सामान्य RAG वर्कफ़्लो: एक डॉक्युमेंट लोडर, डॉक्युमेंट स्प्लिटर, और स्टोरेज व रिट्रीवल प्रक्रिया।

  • इस वीडियो का फोकस: storage और retrieval
LangChain के साथ LLM एप्लिकेशन विकसित करना

वेक्टर डेटाबेस क्या है और इसकी जरूरत क्यों है?

एक सामान्य RAG वर्कफ़्लो.

LangChain के साथ LLM एप्लिकेशन विकसित करना

कौन सा वेक्टर डेटाबेस चुनें?

 

विभिन्न वेक्टर डेटाबेस का परिदृश्य, ओपन सोर्स बनाम क्लोज़्ड सोर्स और डेडिकेटेड बनाम सपोर्ट-ओनली के आधार पर विभाजित।

 

ध्यान दें:

  • ओपन सोर्स बनाम क्लोज़्ड सोर्स (लाइसेंस)
  • क्लाउड बनाम ऑन-प्रिमाइसेस
  • लाइटवेट बनाम पावरफुल
1 Image Credit: Yingjun Wu
LangChain के साथ LLM एप्लिकेशन विकसित करना

डॉक्युमेंट्स से मिलिए...

docs
[
    Document(
        page_content="In all marketing copy, TechStack should always be written with the T and S
        capitalized. Incorrect: techstack, Techstack, etc.",
        metadata={"guideline": "brand-capitalization"}
    ),
    Document(
        page_content="Our users should be referred to as techies in both internal and external
        communications.",
        metadata={"guideline": "referring-to-users"}
    )
]
LangChain के साथ LLM एप्लिकेशन विकसित करना

Chroma वेक्टर डेटाबेस सेट करना

from langchain_openai import OpenAIEmbeddings
from langchain_chroma import Chroma

embedding_function = OpenAIEmbeddings(api_key=openai_api_key, model='text-embedding-3-small')


vectorstore = Chroma.from_documents( docs, embedding=embedding_function, persist_directory="path/to/directory" )
retriever = vectorstore.as_retriever( search_type="similarity", search_kwargs={"k": 2} )
LangChain के साथ LLM एप्लिकेशन विकसित करना

एक प्रॉम्प्ट टेम्पलेट बनाना

from langchain_core.prompts import ChatPromptTemplate

message = """
Review and fix the following TechStack marketing copy with the following guidelines in consideration:

Guidelines:
{guidelines}

Copy:
{copy}

Fixed Copy:
"""

prompt_template = ChatPromptTemplate.from_messages([("human", message)])
LangChain के साथ LLM एप्लिकेशन विकसित करना

सबको जोड़कर एक चेन बनाना!

from langchain_core.runnables import RunnablePassthrough

rag_chain = ({"guidelines": retriever, "copy": RunnablePassthrough()}
             | prompt_template
             | llm)

response = rag_chain.invoke("Here at techstack, our users are the best in the world!")
print(response.content)
Here at TechStack, our techies are the best in the world!
LangChain के साथ LLM एप्लिकेशन विकसित करना

अभ्यास करते हैं!

LangChain के साथ LLM एप्लिकेशन विकसित करना

Preparing Video For Download...