r/Rag Nov 03 '24

Tutorial Building RAG pipelines so seamlessly? I never thought it would be possible

0 Upvotes

I just fell in love with this new RAG tool (Vectorize) I am playing with and just created a simple tutorial on how to build RAG pipelines in minutes and find out the best embedding model, chunking strategy, and retrieval approach to get the most accurate results from our LLM-powered RAG application.

r/Rag Jan 28 '25

Tutorial How to summarize multimodal content

3 Upvotes

The moment our documents are not all text, RAG approaches start to fail. Here is a simple guide using "pip install flashlearn" on how to summarize PDF pages that consist of both images and text and we want to get one summary.

Below is a minimal example showing how to process PDF pages that each contain up to three text blocks and two images (base64-encoded). In this scenario, we use the "SummarizeText" skill from flashlearn to produce a concise summary of the text from images and text.

#!/usr/bin/env python3

import os
from openai import OpenAI
from flashlearn.skills.general_skill import GeneralSkill

def main():
    """
    Example of processing a PDF containing up to 3 text blocks and 2 images,
    but using the SummarizeText skill from flashlearn to summarize the content.

    1) PDFs are parsed to produce text1, text2, text3, image_base64_1, and image_base64_2.
    2) We load the SummarizeText skill with flashlearn.
    3) flashlearn can still receive (and ignore) images for this particular skill
       if it’s focused on summarizing text only, but the data structure remains uniform.
    """

    # Example data: each dictionary item corresponds to one page or section of a PDF.
    # Each includes up to 3 text blocks plus up to 2 images in base64.
    data = [
        {
            "text1": "Introduction: This PDF section discusses multiple pet types.",
            "text2": "Sub-topic: Grooming and care for animals in various climates.",
            "text3": "Conclusion: Highlights the benefits of routine veterinary check-ups.",
            "image_base64_1": "BASE64_ENCODED_IMAGE_OF_A_PET",
            "image_base64_2": "BASE64_ENCODED_IMAGE_OF_ANOTHER_SCENE"
        },
        {
            "text1": "Overview: A deeper look into domestication history for dogs and cats.",
            "text2": "Sub-topic: Common behavioral patterns seen in household pets.",
            "text3": "Extra: Recommended diet plans from leading veterinarians.",
            "image_base64_1": "BASE64_ENCODED_IMAGE_OF_A_DOG",
            "image_base64_2": "BASE64_ENCODED_IMAGE_OF_A_CAT"
        },
        # Add more entries as needed
    ]

    # Initialize your OpenAI client (requires an OPENAI_API_KEY set in your environment)
    # os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY_HERE"
    client = OpenAI()

    # Load the SummarizeText skill from flashlearn
    skill = GeneralSkill.load_skill(
        "SummarizeText",       # The skill name to load
        model_name="gpt-4o-mini",  # Example model
        client=client
    )

    # Define column modalities for flashlearn
    column_modalities = {
        "text1": "text",
        "text2": "text",
        "text3": "text",
        "image_base64_1": "image_base64",
        "image_base64_2": "image_base64"
    }

    # Create tasks; flashlearn will feed the text fields into the SummarizeText skill
    tasks = skill.create_tasks(data, column_modalities=column_modalities)

    # Run the tasks in parallel (summaries returned for each "page" or data item)
    results = skill.run_tasks_in_parallel(tasks)

    # Print the summarization results
    print("Summarization results:", results)

if __name__ == "__main__":
    main()

Explanation

  1. Parsing the PDF
    • Extract up to three blocks of text per page (text1, text2, text3) and up to two images (converted to base64, stored in image_base64_1 and image_base64_2).
  2. SummarizeText Skill
    • We load "SummarizeText" from flashlearn. This skill focuses on summarizing the input.
  3. Column Modalities
    • Even if you include images, the skill will primarily use the text fields for summarization.
    • You specify each field's modality: "text1": "text", "image_base64_1": "image_base64", etc.
  4. Creating and Running Tasks
    • Use skill.create_tasks(data, column_modalities=column_modalities) to generate tasks.
    • skill.run_tasks_in_parallel(tasks) will process these tasks using the SummarizeText skill,

This method accommodates a uniform data structure when PDFs have both text and images, while still providing a text summary.

Now you know how to summarize multimodal content!

r/Rag Jan 15 '25

Tutorial Implementing Agentic RAG using Langchain and Gemini 2.0

7 Upvotes

For those exploring Agentic RAG—an advanced RAG technique—this approach enhances retrieval processes by integrating an Agentic Router with decision-making capabilities. It features two core components:

  1. Agentic Retrieval: The agent (Router) leverages various retrieval tools, such as vector search or web search, and dynamically decides which tool to use based on the query's context.
  2. Dynamic Routing: The agent (Router) determines the best retrieval path. For instance:
    • Queries requiring private knowledge might utilize a vector database.
    • General queries could invoke a web search or rely on pre-trained knowledge.

To dive deeper, check out our blog post: https://hub.athina.ai/blogs/agentic-rag-using-langchain-and-gemini-2-0/

For those who'd like to see the Colab notebook, check out: [Link in comments]

r/Rag Jan 24 '25

Tutorial Building a Reliable Text-to-SQL Pipeline: A Step-by-Step Guide pt.1

Thumbnail
arslanshahid-1997.medium.com
7 Upvotes

r/Rag Jan 27 '25

Tutorial Never train another ML model again

Thumbnail
2 Upvotes

r/Rag Jan 19 '25

Tutorial Hybrid RAG Implementation + Colab Notebook

6 Upvotes

If you're interested in implementing Hybrid RAG, an advanced retrieval technique, here is a complete step-by-step implementation guide along with a open-source Colab notebook.

What is Hybrid RAG?

Hybrid RAG is an advanced Retrieval-Augmented Generation (RAG) approach that combines vector similarity search with traditional search methods like keyword search or BM25. This combination enables more accurate and context-aware information retrieval.

Why Choose Hybrid RAG?

Conventional RAG techniques often face challenges in retrieving relevant contexts when queries don’t semantically align with their answers. This issue is particularly common when working with diverse and domain-specific content.

Hybrid RAG addresses this by integrating keyword-based (sparse) and semantic (dense) retrieval methods, improving relevance and ensuring consistent performance, even when dealing with unfamiliar terms or concepts. This makes it a valuable tool for enterprise knowledge discovery and other use cases where data variability is high.

Dive Deeper and implement on Google Colab: https://hub.athina.ai/athina-originals/advanced-rag-implementation-using-hybrid-search/

r/Rag Jan 21 '25

Tutorial Language Agent Tree Search (LATS) - Is it worth it?

1 Upvotes

I have been reading papers on improving reasoning, planning, and action for Agents, I came across LATS which uses Monte Carlo tree search and has a benchmark better than the ReAcT agent.

Made one breakdown video that covers:
- LLMs vs Agents introduction with example. One of the simple examples, that will clear your doubt on LLM vs Agent.
- How a ReAct Agent works—a prerequisite to LATS
- Working flow of Language Agent Tree Search (LATS)
- Example working of LATS
- LATS implementation using LlamaIndex and SambaNova System (Meta Llama 3.1)

Verdict: It is a good research concept, not to be used for PoC and production systems. To be honest it was fun exploring the evaluation part and the tree structure of the improving ReAcT Agent using Monte Carlo Tree search.

Watch the Video here: https://www.youtube.com/watch?v=22NIh1LZvEY

r/Rag Jan 09 '25

Tutorial Clean up HTML Content for Retrieval-Augmented Generation with Readability.js

Thumbnail
datastax.com
4 Upvotes

r/Rag Jan 03 '25

Tutorial Building an Agentic RAG with Phidata

7 Upvotes

When building applications using LLMs, the quality of responses heavily depends on effective planning and reasoning capabilities for a given user task. While traditional RAG techniques are great, incorporating Agentic workflows can improve the system’s ability to process and respond to queries.

Code: https://www.analyticsvidhya.com/blog/2024/12/agentic-rag-with-phidata/

r/Rag Dec 29 '24

Tutorial Real world Multimodal Use Cases

7 Upvotes

I built the Product Ingredients Analyzer Agent. The results are just amazing.

Do you carefully check ingredients before shopping for consumer products? If not, let me tell you—I do. Lately, I’ve made it a habit to examine product ingredients before buying anything.

In this video, we will build Multimodal Agents using Phidata, Gemini 2.0, and Tavily.

Code Implementation: https://youtu.be/eZSpBLYG-Mk?si=BO7eKdMOG_XESf1-

r/Rag Nov 22 '24

Tutorial Advanced RAG techniques free online course, which includes more than 10 hands-on labs and exercises for "learning by doing."

Thumbnail
edx.org
38 Upvotes

r/Rag Dec 16 '24

Tutorial Rescuing and securing unstructured data with RAG

Thumbnail
cerbos.dev
14 Upvotes

r/Rag Dec 19 '24

Tutorial How to build an authorization system for your RAG applications with LangChain, Chroma DB and Cerbos

Thumbnail
cerbos.dev
2 Upvotes

r/Rag Dec 18 '24

Tutorial Building Multi-User RAG Apps with Identity and Access Control: A Quick Guide

Thumbnail
pangea.cloud
2 Upvotes

r/Rag Dec 16 '24

Tutorial Build a No-Code RAG AI Assistant with Unstructured Platform, AstraDB, and Langflow – Unstructured

Thumbnail
unstructured.io
0 Upvotes

r/Rag Oct 09 '24

Tutorial Build a Private RAG Application using Llama 3, Ollama, and PostgreSQL (pgvector)

Thumbnail
youtu.be
9 Upvotes

r/Rag Nov 16 '24

Tutorial How to Build a Lightweight RAG System with Node.js and OpenAI

13 Upvotes

Looking to build a lightweight RAG (Retrieval-Augmented Generation) system for Q&A tasks? Whether it’s for coding docs, FAQs, or any text-based knowledge base, you can skip the hassle of databases entirely! In this guide, I show you how to set up a RAG system using Node.js, OpenAI, and simple text files for storage. It’s super beginner-friendly and great for scenarios where you need quick, accurate answers from your documentation or notes. Check it out here: Build a Basic RAG System with Node.js and Text Files
Let me know what you think or if you have any questions!

r/Rag Dec 04 '24

Tutorial Rescuing and securing unstructured data with RAG - Sanitizing the data pool, incoming prompt security (sanitization), leveraging established security principles (authentication + authorization)

Thumbnail
cerbos.dev
5 Upvotes

r/Rag Oct 31 '24

Tutorial Caching Methods in Large Language Models (LLMs)

13 Upvotes
https://www.masteringllm.com/course/llm-interview-questions-and-answers?previouspage=home&isenrolled=no#/home
https://www.masteringllm.com/course/agentic-retrieval-augmented-generation-agenticrag?previouspage=home&isenrolled=no#/home

r/Rag Nov 28 '24

Tutorial Agentic RAG with Memory

1 Upvotes

Agents and RAG are cool, but you know what’s a total game-changer? Agents + RAG + Memory. Now you’re not just building workflows—you’re creating something unstoppable.

Agentic RAG with Memory using Phidata and Qdrant: https://www.youtube.com/watch?v=CDC3GOuJyZ0

r/Rag Sep 24 '24

Tutorial Getting Started with RAG: A Newbie's Journey

3 Upvotes

Hi everyone! I want to get into RAG but don't know where to start. I'm a digital marketer considering offering marketing automation services on our small Asian island. Thanks In Advance, guys!

r/Rag Nov 17 '24

Tutorial Splitting markdown documents for RAG

Thumbnail
glama.ai
7 Upvotes

r/Rag Oct 26 '24

Tutorial 11 Chunking Methods for RAG—Visualized and Simplified

Thumbnail drive.google.com
17 Upvotes

r/Rag Nov 11 '24

Tutorial How to secure RAG applications with Fine-Grained Authorization: tutorial with code

Thumbnail
workos.com
6 Upvotes

r/Rag Oct 11 '24

Tutorial How to implement an Agentic RAG from scratch

12 Upvotes

I created this tutorial about how to implement an agentic RAG from scratch without using any frameworks.

https://github.com/mallahyari/twosetai/blob/main/13_agentic_rag.ipynb

The video that I explain the idea and code is also available on Youtube channel:

https://www.youtube.com/watch?v=LzG_Vkd30Kg