Dataset Viewer

The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.

epri-ai-openrag

An open-source, downloadable SQLite database of EPRI public publications, shared as chunked texts along with dense embeddings (created using BGE-M3). This artifact enables external organizations to ingest EPRI public documents into their internal RAG (Retrieval-Augmented Generation) pipelines.

Distributed via Hugging Face and as an EPRI.com Software Product.


πŸ“¦ Hugging Face Artifacts

File / Artifact Description
openrag.db Release artifact: SQLite database containing chunks and embeddings.
sqlite_qdrant_cloud.py Ingests openrag.db into a remote Qdrant collection.
qdrant_retrieval.py Demonstrates semantic search over a Qdrant collection.
alternate_embedding.py Generates new embeddings (e.g., VoyageAI) and writes to a new DB.
sqlite_zvec.py Ingests openrag.db into a local ZVEC collection.
zvec_retrieval.py Demonstrates semantic search over a local Zvec collection.
requirements.txt Python dependencies.
.env.example Template for environment variables needed for the scripts.

πŸš€ Getting Started

Prerequisites

  • Python 3.12+
  • A SQLite database file (openrag.db) from a release artifact.
  • Environment variables for external services (see scripts below).

Install dependencies

pip install -r requirements.txt

Create a .env file based on .env.example and fill in the required values for your environment (e.g., Qdrant endpoint, embedding model API keys).

πŸ—„οΈ SQLite DB Schema

The release artifact includes a SQLite database (openrag.db) containing per-chunk embeddings and enriched metadata. The primary table is EmbeddingContent.

Schema Overview

Column Type Description
chunk_id INTEGER (PK) Internal numeric primary key.
product_id TEXT | NULL EPRI product identifier.
content_type TEXT | NULL Chunk type (e.g., "abstract", "section").
heading_h1, heading_h2, heading_h3 TEXT | NULL Hierarchical headings extracted from the source.
heading_level INT Depth/level of the heading.
page_start INT Starting page number of the chunk.
page_end INT Ending page number of the chunk.
chunk_text TEXT Bounded snippet text
title TEXT | NULL Publication title.
date_published TEXT | NULL Publication date (string format).
url TEXT | NULL Canonical URL for the publication.
program_name TEXT | NULL EPRI Program that published the report
abstract TEXT | NULL Abstract as shown in epri.com
keywords TEXT | NULL Comma separated keywords available in epri.com
embedding BLOB | NULL Raw float32 bytes of the dense embedding vector.

Working with the embedding Column

Embeddings are stored as raw float32 bytes to minimize disk footprint. To decode them in Python:

import numpy as np
vector = np.frombuffer(row["embedding"], dtype=np.float32)

SQLModel Representation

from sqlmodel import Column, Field, LargeBinary, SQLModel

class EmbeddingContent(SQLModel, table=True):
    """A single document chunk with its embedding and enriched metadata."""
    chunk_id: int = Field(primary_key=True)
    product_id: str | None = None
    content_type: str | None = None
    heading_h1: str | None = None
    heading_h2: str | None = None
    heading_h3: str | None = None
    heading_level: int 
    page_start : int
    page_end : int
    chunk_text: str 
    title: str | None = None
    date_published: str | None = None
    url: str | None = None
    program_name: str | None = None
    abstract: str | None = None
    keywords: str | None = None
    embedding: bytes | None = Field(sa_column=Column(LargeBinary), default=None)

Developer Notes:

  • The pipeline streams rows in small batches to handle large DB files efficiently.
  • Inspecting the DB directly will show embedding as a BLOB. Do not use text-based tools on it.
  • For CSV exports, handle binary columns carefully (e.g., base64-encode).

πŸ”„ Using Alternate Embedding Models

The default openrag.db uses BGE-M3 embeddings. You can generate new embeddings with a different model and store them in a new SQLite DB using the same schema.

  1. Generate embeddings for chunk_text using your chosen model.
  2. Store the new embeddings as raw float32 bytes in the embedding column.
  3. Use the example ingestion scripts to stream the new DB into your vector store.
  4. Ensure your query embeddings use the same model for optimal retrieval.

Example: alternate_embedding.py demonstrates how to create a new DB (voyage_openrag.db) using the voyage-4-large model. Requires VOYAGEAI_API_KEY in your .env file. Remember to update the DENSE_VECTOR_DIM variable in your .env file to match the new model's embedding dimension.

If you want to try the optional Voyage AI alternative example, install voyageai>=0.3.7 separately (for example: pip install 'voyageai>=0.3.7') and use Deliverable/voyage-embedding.qmd. This is an alternative embedding workflow example; the default pipeline in this repository uses BGE-M3.

Run the migration

Prerequisites

  • .env must contain:
    QDRANT_BASE_URL=https://<your-qdrant-endpoint>
    

Usage

pip install qdrant-client
python sqlite_qdrant_cloud.py

What it does

  • Loads env vars and connects to SQLite and remote Qdrant.
  • Recreates the epri_openrag collection (destructive: deletes existing collection).
  • Streams rows in batches (BATCH_SIZE = 1000).
  • Skips NULL embeddings, decodes float32 bytes, and upserts to Qdrant.
  • Prints final point count.

2. Retrieve from Qdrant (qdrant_retrieval.py)

Demonstrates semantic search over a Qdrant collection using an embedding model.

Prerequisites

  • .env must contain:
    QDRANT_BASE_URL=https://<host>:<port>
    EMBEDDING_MODEL_URL=<your-embedding-endpoint>
    EMBEDDING_MODEL_NAME=BGE-M3
    EMBEDDING_API_KEY=<your-key-if-required>  # Omit for local/private models. Add any other variables required by your provider.
    

Usage

python qdrant_retrieval.py

What it does

  • Instantiates Qdrant and embedding clients.
  • Embeds a sample query string.
  • Searches the epri_openrag collection for the top 15 similar chunks.
  • Prints retrieved metadata payloads.

3. Generate Alternate Embeddings (alternate_embedding.py)

Reads from openrag.db, generates new embeddings via VoyageAI, and writes to voyage_openrag.db.

Prerequisites

  • .env must contain:
    VOYAGEAI_API_KEY=<your-voyageai-key>
    

Usage

pip install voyageai
python alternate_embedding.py

What it does

  • Deletes voyage_openrag.db if it exists (clean run).
  • Streams chunks from openrag.db in batches.
  • Calls VoyageAI API only for non-empty chunk_text.
  • Stores new embeddings as float32 bytes.
  • Displays a progress bar and final row count.

4. Ingest into Local ZVEC (sqlite_zvec.py)

Streams embeddings and metadata from openrag.db into a persistent local ZVEC collection. ZVEC is a lightweight, file-based vector database suitable for local development and offline use.

Prerequisites

  • Install ZVEC:
    pip install zvec
    
  • .env must contain:
    COLLECTION_NAME=epri_openrag
    DENSE_VECTOR_DIM=1024  # Match your embedding model's dimension
    

Usage

python sqlite_zvec.py

What it does

  • Clears the local ZVEC directory at start (destructive: removes existing zvec_db/).
  • Creates a new ZVEC collection with FP16 vectors and metadata field schema.
  • Streams rows from openrag.db in batches (BATCH_SIZE = 1000).
  • Decodes float32 embedding bytes, normalizes vectors, and upserts to ZVEC.
  • Skips rows with NULL embeddings.
  • Sanitizes metadata fields to string types (ZVEC requirement).
  • Runs optimize() on the collection after ingestion.
  • Displays a progress bar and final collection stats.
Downloads last month
3