Member-only story

RAG (Retrieval-augmented generation) on Wikipedia Page

Pankaj Kumar
2 min readOct 20, 2024

Reading Country wiki to Get Independence Day & Capital using RAG

Photo by Kostiantyn Li on Unsplash

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

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Already have an account? Sign in

Pankaj Kumar
Pankaj Kumar

Written by Pankaj Kumar

MS Data Science SMU TX, MSc Financial Engg WQU. Interest in Algos, Discovering Trends in data. Worked 4 Hedge Funds n Inv banks https://vitvinyas.onrender.com/

No responses yet

Write a response