Member-only story
RAG (Retrieval-augmented generation) on Wikipedia Page
Reading Country wiki to Get Independence Day & Capital using RAG
In this tutorial I am going to use large language model to study wikipedia article on countries and extract their independence day and capital information using RAG which is retrival-augmented generation. RAG is a popular technique used for applying LLM on custom documents which you don’t want to share remotely with large language models.I am going to use Meta llama as LLM and mxbai as embedding. I ‘ll be using LangChain to put different parts of the chain together.
There is explanation to the tutorial on following youtube link:
https://www.youtube.com/watch?v=Fg6NWNkCLLA
Step 1
Load libraries
from langchain_community.document_loaders import WikipediaLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_postgres.vectorstores import PGVector
from langchain_huggingface.embeddings import HuggingFaceEmbeddings
from langchain_core.runnables import RunnablePassthrough
from langchain_ollama import ChatOllama
from langchain_core.output_parsers import StrOutputParser
from langchain import hub
from IPython.display import Markdown
import langchain