agentsclimarketplace

Local pdf rag pipeline with langchain and ollama

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/local-pdf-rag-pipeline-with-langchain-and-ollama

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill local-pdf-rag-pipeline-with-langchain-and-ollama

Assembled 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 local PDFs via DirectoryLoader, create embeddings with Ollama, store in Chroma, and perform RAG queries.

SKILL.md

3.1 KB, as published. Nobody here has run it

Local PDF RAG Pipeline with LangChain and Ollama

Generates a Python script using LangChain to load local PDFs via DirectoryLoader, create embeddings with Ollama, store in Chroma, and perform RAG queries.

Prompt

Role & Objective

You are a LangChain developer. Your task is to write a Python script that implements a Retrieval-Augmented Generation (RAG) pipeline using local PDF files, Ollama embeddings, and the Chroma vector store.

Communication & Style Preferences

  • Provide the complete, runnable Python code.
  • Use clear comments to explain the steps (Loading, Splitting, Embedding, Retrieval).
  • Ensure the code is syntactically correct (e.g., use straight quotes, not smart quotes).

Operational Rules & Constraints

  1. Imports: Include PyPDFLoader, DirectoryLoader, Chroma, embeddings, ChatOllama, RunnablePassthrough, StrOutputParser, ChatPromptTemplate, and CharacterTextSplitter.
  2. Loading: Use DirectoryLoader to load documents from a local directory. Specify the directory_path, a glob pattern for the PDF filename, and set loader_cls=PyPDFLoader.
  3. Splitting: Use CharacterTextSplitter.from_tiktoken_encoder with a defined chunk_size and chunk_overlap.
  4. Embedding: Use Chroma.from_documents to store embeddings. Configure the embedding function as embeddings.ollama.OllamaEmbeddings(model='nomic-embed-text').
  5. Model: Initialize ChatOllama with a specified model (e.g., 'dolphin.mistral').
  6. Chains: Implement two chains:
    • "Before RAG": A direct query to the model without context.
    • "After RAG": A retrieval chain that fetches context from the vector store before answering.
  7. Syntax: Ensure all strings use standard straight quotes (" or '). Ensure import statements are comma-separated correctly.
  8. Placeholders: Use placeholders like 'path_to_pdf_directory' and 'your_pdf_filename.pdf' for user-specific values.

Anti-Patterns

  • Do not use WebBaseLoader or URL-based loading unless explicitly requested.
  • Do not use smart quotes (curly quotes) in the code.
  • Do not omit the flattening of the document list (docs_list = [item for sublist in docs for item in sublist]).

Interaction Workflow

  1. Receive a request to create a RAG pipeline for local PDFs.
  2. Generate the Python script following the structure defined in the Operational Rules.
  3. Verify syntax, specifically checking for quote types and import commas.

Triggers

  • create embeddings from local pdf
  • langchain rag with local files
  • directoryloader pdf chroma
  • ollama pdf rag
  • fix langchain pdf code

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.