RepoNVIDIANVIDIApublished Apr 4, 2025seen 2d

NVIDIA/context-aware-rag

Python

Open original ↗

Captured source

source ↗
published Apr 4, 2025seen 2dcaptured 2dhttp 200method plain

NVIDIA/context-aware-rag

Description: Context-Aware RAG library for Knowledge Graph ingestion and retrieval functions.

Language: Python

License: Apache-2.0

Stars: 86

Forks: 23

Open issues: 4

Created: 2025-04-04T19:43:48Z

Pushed: 2026-06-23T20:44:51Z

Default branch: main

Fork: no

Archived: no

README:

NVIDIA Context Aware RAG

![image](docs/source/_static/data_architecture.png)

Context Aware RAG is a flexible library designed to seamlessly integrate into existing data processing workflows to build customized data ingestion and retrieval (RAG) pipelines.

Key Features

With Context Aware RAG, you can quickly build RAG pipelines to support your existing workflows.

Links

Getting Started

Prerequisites

Before you begin using Context Aware RAG, ensure that you have the following software installed.

Installation

Clone the repository

git clone git@github.com:NVIDIA/context-aware-rag.git
cd context-aware-rag/

Create a virtual environment using uv

uv venv --seed .venv
source .venv/bin/activate

Installing from source

uv pip install -e .

Installing optional plugins

##### Arango

uv pip install -e .[arango]

##### NAT

uv pip install -e .[nat]

Optional: Building and Installing the wheel file

uv build
uv pip install dist/vss_ctx_rag-1.0.2-py3-none-any.whl

Service Example

Setting up environment variables

Create a .env file in the root directory and set the following variables:

NVIDIA_API_KEY=
NVIDIA_VISIBLE_DEVICES=

OPENAI_API_KEY=

VSS_CTX_PORT_RET=
VSS_CTX_PORT_IN=

GRAPH_DB_USERNAME=
GRAPH_DB_PASSWORD=
ARANGO_DB_USERNAME=root
ARANGO_DB_PASSWORD=
MINIO_USERNAME=
MINIO_PASSWORD=

Build docker

make -C docker build

Start using docker compose

make -C docker start_compose

This will start the following services:

  • ctx-rag-data-ingestion
  • Service available at http://:
  • ctx-rag-data-retrieval
  • Service available at http://:
  • neo4j
  • UI available at http://:7474
  • milvus
  • otel-collector
  • Phoenix
  • UI available at http://:16686
  • prometheus
  • UI available at http://:9090
  • elasticsearch
  • UI available at http://:9200
  • kibana
  • UI available at http://:5601

To change the storage volumes, export DOCKER_VOLUME_DIRECTORY to the desired directory.

Stop using docker compose

make -C docker stop_compose

Data Ingestion Example

import requests
import json
from pyaml_env import parse_config

base_url = "http://:"

headers = {"Content-Type": "application/json"}

### Initialize the service with a unique uuid
init_data = {"uuid": "1"}
### Optional: Initialize the service with a config file or context config
"""
init_data = {"config_path": "/app/config/config.yaml", "uuid": "1"}
init_data = {"context_config": parse_config("/app/config/config.yaml"), "uuid": "1"}
"""
response = requests.post(
f"{base_url}/init", headers=headers, data=json.dumps(init_data)
)

# POST request to /add_doc to add documents to the service
add_doc_data_list = [
{
"document": "User1: Hi how are you?",
"doc_index": 0,
"doc_metadata": {
"streamId": "stream1",
"chunkIdx": 0,
"file": "chat_conversation.txt",
"is_first": True,
"is_last": False,
"uuid": "1"
},
"uuid": "1"
},
{
"document": "User2: I am good. How are you?",
"doc_index": 1,
"doc_metadata": {
"streamId": "stream1",
"chunkIdx": 1,
"file": "chat_conversation.txt",
"uuid": "1"
},
"uuid": "1"
},
{
"document": "User1: I am great too. Thanks for asking",
"doc_index": 2,
"doc_metadata": {
"streamId": "stream1",
"chunkIdx": 2,
"file": "chat_conversation.txt",
"uuid": "1"
},
"uuid": "1"
},
{
"document": "User2: So what did you do over the weekend?",
"doc_index": 3,
"doc_metadata": {
"streamId": "stream1",
"chunkIdx": 3,
"file": "chat_conversation.txt",
"uuid": "1"
},
"uuid": "1"
},
{
"document": "User1: I went hiking to Mission Peak",
"doc_index": 4,
"doc_metadata": {
"streamId": "stream1",
"chunkIdx": 4,
"file": "chat_conversation.txt",
"uuid": "1"
},
"uuid": "1"
},
{
"document": "User3: Guys there is a fire. Let us get out of here",
"doc_index": 5,
"doc_metadata": {
"streamId": "stream1",
"chunkIdx": 5,
"file": "chat_conversation.txt",
"is_first": False,
"is_last": True,
"uuid": "1"
},
"uuid": "1"
},
]

# Send POST requests for each...

Excerpt shown — open the source for the full document.

Notability

notability 6.0/10

New NVIDIA RAG library with 86 stars

NVIDIA has a repo signal matching data demand, evals and quality.