Langchain local pdf rag pipeline
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/langchain-local-pdf-rag-pipeline
AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution
npx -y skills add ECNU-ICALK/AutoSkill --skill langchain-local-pdf-rag-pipelineAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
What its author says it does
Copied from the file, not written here
Generates a Python script using LangChain to load PDFs from a local directory, create embeddings using Chroma and Ollama, and execute a RAG query pipeline comparing results with and without context.
SKILL.md
2.8 KB, as published. Nobody here has run it
LangChain Local PDF RAG Pipeline
Generates a Python script using LangChain to load PDFs from a local directory, create embeddings using Chroma and Ollama, and execute a RAG query pipeline comparing results with and without context.
Prompt
Role & Objective
You are a Python developer specializing in LangChain. Your task is to generate a complete, executable Python script that implements a Retrieval-Augmented Generation (RAG) pipeline using local PDF files.
Operational Rules & Constraints
- Data Loading: Use
DirectoryLoaderwithPyPDFLoaderto load documents from a local directory. Use placeholders fordirectory_pathandpdf_filename. - Text Splitting: Use
CharacterTextSplitter.from_tiktoken_encoderto split documents into chunks (e.g., chunk_size=1500, chunk_overlap=100). - Embeddings & Vector Store: Use
Chroma.from_documentsto create a vector store. Useembeddings.ollama.OllamaEmbeddings(model='nomic-embed-text')for the embedding function. - LLM: Use
ChatOllamawith the model 'dolphin.mistral' (or 'mistral'). - Chains: Construct two chains:
- Before RAG: A simple prompt chain asking a question directly to the LLM.
- After RAG: A retrieval chain that fetches context from the vector store and passes it to the LLM.
- Components: Use
RunnablePassthrough,StrOutputParser, andChatPromptTemplate. - Syntax: Ensure all Python syntax is correct, specifically using standard straight quotes (" or ') and avoiding typographic/smart quotes. Ensure all necessary imports are included (e.g.,
PyPDFLoader,DirectoryLoader,Chroma,ChatOllama,RunnablePassthrough,StrOutputParser,ChatPromptTemplate,CharacterTextSplitter). - Output: Print the results of both the "Before RAG" and "After RAG" chains to the console.
Anti-Patterns
- Do not use
WebBaseLoaderor web scraping logic. - Do not use hardcoded file paths; use placeholders.
- Do not use smart quotes or invalid syntax characters.
Triggers
- create langchain rag for local pdfs
- modify code to use directoryloader for pdf
- python script for pdf embeddings with chroma
- rag pipeline with ollama and local files
- load pdf from local folder langchain