Skip to main content

Neural Retrieval-Augmented Generation for GitHub code blocks

Project description

LLM Retrieval Augmented Generation

GitHub release
short alias lrag


The original version of the NN RAG project was created by Waleed Khalid at the Computer Vision Laboratory, University of Würzburg, Germany.

📖 Overview

A minimal Retrieval-Augmented Generation (RAG) pipeline for code and dataset details.
This project aims to provide LLMs with additional context from the internet or local repos, then optionally fine-tune the LLM for specific tasks.

Requirements

  • Python 3.8+ recommended
  • Pip or Conda for installing dependencies
  • (Optional) GPU with CUDA if you plan to do large-scale training

Installing Dependencies

  1. Create and activate a virtual environment (recommended):
    python -m venv venv
    source venv/bin/activate   # Linux/Mac
    venv\Scripts\activate      # Windows
    
  2. Latest Development Version

Install the latest version directly from GitHub:

pip install git+https://github.com/ABrain-One/nn-rag --upgrade

Usage

Command Line Interface

The package provides a command-line interface for extracting neural network blocks:

# Correct way to run (recommended)
python3 -m ab.rag --help

# Extract a specific block
python3 -m ab.rag --block ResNet

# Extract multiple blocks
python3 -m ab.rag --blocks ResNet VGG DenseNet

# Extract from JSON file (default)
python3 -m ab.rag

# Note: Avoid running 'python3 -m ab.rag.extract_blocks' as it may show warnings

Python API

from ab.rag import BlockExtractor, BlockValidator

# Initialize extractor
extractor = BlockExtractor()

# Warm up the index (clones repos and indexes if needed)
extractor.warm_index_once()

# Extract a single block
result = extractor.extract_single_block("ResNet")

# Extract multiple blocks
results = extractor.extract_multiple_blocks(["ResNet", "VGG"])

# Extract from JSON file (uses default nn_block_names.json)
results = extractor.extract_blocks_from_file()

# Extract with limit
results = extractor.extract_blocks_from_file(limit=10)

# Extract with custom JSON file
results = extractor.extract_blocks_from_file("custom_blocks.json")

# Extract with start_from parameter
results = extractor.extract_blocks_from_file(start_from="ResNet", limit=5)

Citation

If you find this pipeline to be useful for your research, please consider citing our article:

@article{ABrain.NN-RAG,
  title={A Retrieval-Augmented Generation Approach to Extracting Algorithmic Logic from Neural Networks},
  author={Khalid, Waleed and Ignatov, Dmitry and Timofte, Radu},
  journal={arXiv preprint arXiv:2512.04329},
  year={2025}
}

The idea and leadership of Dr. Ignatov

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nn_rag-2.1.4.tar.gz (84.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nn_rag-2.1.4-py3-none-any.whl (95.5 kB view details)

Uploaded Python 3

File details

Details for the file nn_rag-2.1.4.tar.gz.

File metadata

  • Download URL: nn_rag-2.1.4.tar.gz
  • Upload date:
  • Size: 84.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for nn_rag-2.1.4.tar.gz
Algorithm Hash digest
SHA256 ae89fba173046d64ff3304094547656b3363e85bb407b60b17c1bb931488e199
MD5 92d515ef763fd91fa94514da92a2babc
BLAKE2b-256 5b6b660c4bf58c011408fddb0f6815933fa2734dbf5069892dc7568d377b8965

See more details on using hashes here.

File details

Details for the file nn_rag-2.1.4-py3-none-any.whl.

File metadata

  • Download URL: nn_rag-2.1.4-py3-none-any.whl
  • Upload date:
  • Size: 95.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for nn_rag-2.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4499bf67d9cacbc9a64196810dec0aacf8ab46a2db45cc3db3eb60bce58f0582
MD5 ae5fe5794275d812a194a16a748fe856
BLAKE2b-256 91a730f204c30faf40016bca1f89a87f11c04fd03fbe254ab492a35e21485aa4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page