← Back to Blog

Building a Simple RAG Chatbot to Chat with Any PDF in Minutes

By Amin Rabinia · Founder, Glissando AI

Retrieval Augmented Generation (RAG) has become one of the most powerful AI techniques to make language models smarter and more grounded. But while most tutorials dive into complex architectures, you can actually build a simple RAG system with just a few lines of Python.

In this quick guide, we'll show you how to create your own "Chat with PDF" app using OpenAI, FAISS, and Gradio. No heavy frameworks, no complicated setups — just clean, simple code that anyone can follow.

When simple RAG is enough: For many document Q&A use cases—internal knowledge bases, product documentation, policy chatbots—the simple RAG pattern (embed → store → retrieve → generate) is all you need. Start here before adding complexity.

What is RAG?

At its core, RAG enhances a language model's capabilities by retrieving relevant information from external data sources and feeding that into the model for better answers. Instead of relying solely on the model's memory, you give it facts directly from your documents.

For this demo, our external data source will be a PDF file. We'll allow the user to upload a PDF, ask questions, and the AI will answer based on the document contents.


How It Works

The workflow is straightforward:

  • Upload a PDF: The user provides a PDF file that will be used as the knowledge base.
  • Extract Text: Each page of the PDF is extracted and treated as a separate chunk.
  • Embed Text: Using OpenAI's embedding API, we convert each chunk into a vector.
  • Store in FAISS: The vectors are stored in FAISS, a fast similarity search library.
  • Ask Questions: When a user asks a question, we embed it, find the most relevant document chunks, and pass them into GPT to generate an answer.
  • Build the Interface: We use Gradio to create a simple web UI so users can upload PDFs and ask questions easily.

Why This is a Great Beginner RAG Project

Many RAG tutorials involve chains, pipelines, and multiple services. This project keeps things very simple:

  • Each PDF page = a chunk
  • FAISS as a simple vector store
  • OpenAI embeddings to convert text to vectors
  • Gradio as a no-fuss frontend

This makes it ideal for people who are new to AI, coders who want to understand RAG, and content creators who want to build document chatbots without complex tools.

See this simple code to run the chatbot section of the RAG system below. Complete code here (needs your OpenAI API key).

with gr.Blocks() as demo:
    with gr.Row():
        pdf_input = gr.File(label="Upload PDF")
        upload_btn = gr.Button("Process PDF")
        status = gr.Textbox(label="Status")

    upload_btn.click(process_pdf, inputs=[pdf_input], outputs=[status])

    question = gr.Textbox(label="Ask a question about the PDF")
    answer = gr.Textbox(label="Answer")

    question.submit(answer_question, inputs=[question], outputs=[answer])

demo.launch()

Bonus Ideas to Expand

Once you have the basic version working, it's easy to make this more advanced:

  • Allow multiple PDFs
  • Show sources in answers
  • Use better chunking methods for large pages
  • Switch to open-source embedding models
  • Build more advanced frontends

We used this RAG system to process an invoice as an example.


Final Thoughts

RAG is a very practical AI pattern and is becoming standard in many enterprise AI apps. But you don't need to dive into enterprise solutions to start experimenting. With just Python, OpenAI, and a few easy libraries, you can build a useful chatbot that chats with any PDF in minutes.

Watch the full tutorial below.

Want to apply this to your business? Explore AI Automation Consulting →

Get the next one in your inbox

One practical AI idea per week, from real client projects. No fluff, unsubscribe anytime.

Have Questions About AI for Your Business?

30 minutes with a senior AI consultant. Walk away with clarity on what's feasible, what to build, and what to do next.

Got Questions?

Send Us a Message

We'll reply within one business day.

+1 916 936 1544
Sacramento, CA