kturung/colpali-llama-vision-rag

114

stars

6

commits

Python

primary language

Nov 25, 2024

updated

README

๐Ÿ–ผ๏ธ Image RAG (Colpali + LLaMA Vision)

A powerful Retrieval-Augmented Generation (RAG) system combining Colpali's ColQwen image embeddings with LLaMA Vision via Ollama.

๐ŸŒŸ Key Features

  • ๐Ÿงฌ ColQwen model for generating powerful image embeddings via Colpali
  • ๐Ÿค– LLaMA Vision integration through Ollama for image understanding
  • ๐Ÿ“ฅ Intelligent image indexing with duplicate detection
  • ๐Ÿ’ฌ Natural language image queries
  • ๐Ÿ“„ PDF document support
  • ๐Ÿ” Semantic similarity search
  • ๐Ÿ“Š Efficient SQLite storage

๐Ÿ› ๏ธ Technical Stack

  • Embedding Model: ColQwen via Colpali
  • Vision Model: LLaMA Vision via Ollama
  • Frontend: Streamlit
  • Database: SQLite
  • Image Processing: Pillow, pdf2image
  • ML Framework: PyTorch

โšก Quick Start

  1. Install Poppler (required for PDF support):

    Mac:

    brew install poppler
    

    Windows:

    1. Download the latest poppler package from: https://github.com/oschwartz10612/poppler-windows/releases/
    2. Extract the downloaded zip to a location (e.g., C:\Program Files\poppler)
    3. Add bin directory to PATH:
      • Open System Properties > Advanced > Environment Variables
      • Under System Variables, find and select "Path"
      • Click "Edit" > "New"
      • Add the bin path (e.g., C:\Program Files\poppler\bin)
    4. Verify installation:
      pdftoppm -h
      
  2. Clone and setup environment:

    git clone https://github.com/kturung/colpali-llama-vision-rag.git
    python -m venv venv
    source venv/bin/activate  # For Mac/Linux
    # or
    .\venv\Scripts\activate  # For Windows
    pip install -r requirements.txt
    
  3. Install Ollama from https://ollama.com

  4. Launch application:

    streamlit run app.py
    

Note: Restart your terminal/IDE after modifying PATH variables

๐Ÿ’ก Usage

๐Ÿ“ค Adding Images

  1. Navigate to "โž• Add to Index"
  2. Upload images/PDFs
  3. System automatically:
    • Generates ColQwen embeddings
    • Checks for duplicates
    • Stores in SQLite

๐Ÿ”Ž Querying

  1. Go to "๐Ÿ” Query Index"
  2. Enter natural language query
  3. View similar images
  4. Get LLaMA Vision analysis

๐Ÿ’พ Database Schema

CREATE TABLE embeddings (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    image_base64 TEXT,
    image_hash TEXT UNIQUE,
    embedding BLOB
)

Contributors

kturung

4 commits

eltictacdicta

2 commits

kturung/colpali-llama-vision-rag

114

stars

6

commits

Python

primary language

Nov 25, 2024

updated

README

๐Ÿ–ผ๏ธ Image RAG (Colpali + LLaMA Vision)

A powerful Retrieval-Augmented Generation (RAG) system combining Colpali's ColQwen image embeddings with LLaMA Vision via Ollama.

๐ŸŒŸ Key Features

  • ๐Ÿงฌ ColQwen model for generating powerful image embeddings via Colpali
  • ๐Ÿค– LLaMA Vision integration through Ollama for image understanding
  • ๐Ÿ“ฅ Intelligent image indexing with duplicate detection
  • ๐Ÿ’ฌ Natural language image queries
  • ๐Ÿ“„ PDF document support
  • ๐Ÿ” Semantic similarity search
  • ๐Ÿ“Š Efficient SQLite storage

๐Ÿ› ๏ธ Technical Stack

  • Embedding Model: ColQwen via Colpali
  • Vision Model: LLaMA Vision via Ollama
  • Frontend: Streamlit
  • Database: SQLite
  • Image Processing: Pillow, pdf2image
  • ML Framework: PyTorch

โšก Quick Start

  1. Install Poppler (required for PDF support):

    Mac:

    brew install poppler
    

    Windows:

    1. Download the latest poppler package from: https://github.com/oschwartz10612/poppler-windows/releases/
    2. Extract the downloaded zip to a location (e.g., C:\Program Files\poppler)
    3. Add bin directory to PATH:
      • Open System Properties > Advanced > Environment Variables
      • Under System Variables, find and select "Path"
      • Click "Edit" > "New"
      • Add the bin path (e.g., C:\Program Files\poppler\bin)
    4. Verify installation:
      pdftoppm -h
      
  2. Clone and setup environment:

    git clone https://github.com/kturung/colpali-llama-vision-rag.git
    python -m venv venv
    source venv/bin/activate  # For Mac/Linux
    # or
    .\venv\Scripts\activate  # For Windows
    pip install -r requirements.txt
    
  3. Install Ollama from https://ollama.com

  4. Launch application:

    streamlit run app.py
    

Note: Restart your terminal/IDE after modifying PATH variables

๐Ÿ’ก Usage

๐Ÿ“ค Adding Images

  1. Navigate to "โž• Add to Index"
  2. Upload images/PDFs
  3. System automatically:
    • Generates ColQwen embeddings
    • Checks for duplicates
    • Stores in SQLite

๐Ÿ”Ž Querying

  1. Go to "๐Ÿ” Query Index"
  2. Enter natural language query
  3. View similar images
  4. Get LLaMA Vision analysis

๐Ÿ’พ Database Schema

CREATE TABLE embeddings (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    image_base64 TEXT,
    image_hash TEXT UNIQUE,
    embedding BLOB
)

Contributors

kturung

4 commits

eltictacdicta

2 commits

Languages

Python

100.0%