Skip to main content

GPT-Driven Neural Network Generator

GitHub release
short alias lmurg

📖 Overview

This Python-based NNGPT project leverages large language models (LLMs) to automate the creation of neural network architectures, streamlining the design process for machine learning practitioners. It leverages various neural networks from the LEMUR Dataset to fine-tune LLMs and provide insights into potential architectures during the creation of new neural network models.

For Linux/Mac:

python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip

For Windows:

python3 -m venv .venv
.venv\Scripts\activate
python3 -m pip install --upgrade pip

It is assumed that CUDA 13.0 is installed; otherwise, consider replacing 'cu130' with the appropriate version. Most LLM usage scenarios require GPUs with at least 24 GB of memory.

Environment for NNGPT Developers

Pip package manager

Create a virtual environment, activate it, and run the following command to install all the project dependencies:

python -m pip install --upgrade pip
rm -rf db
pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu130
MAX_JOBS=4 NVCC_THREADS=1 pip install -r req-no-isolation.txt --no-build-isolation --no-cache -v --extra-index-url https://download.pytorch.org/whl/cu130

Removing the --no-cache parameter allows previously built packages to be retrieved from the cache, but it can lead to problems if the PyTorch version has changed.

If there are installation problems, install the dependencies from the 'requirements.txt' file one by one.

Update of NN Dataset

To get the latest code and statistics, install the most recent version of the LEMUR Dataset from GitHub:

rm -rf db
pip uninstall -y nn-dataset
pip install --no-cache-dir git+https://github.com/ABrain-One/nn-dataset --extra-index-url https://download.pytorch.org/whl/cu130

Installing the stable version:

rm -rf db
pip uninstall -y nn-dataset 
pip install nn-dataset --extra-index-url https://download.pytorch.org/whl/cu130

Adding functionality to export data to Excel files and generate plots for analyzing neural network performance:

pip install nn-stat --extra-index-url https://download.pytorch.org/whl/cu130

and export/generate:

python -m ab.stat.export

Installation of NNGPT with pip

   pip install nn-gpt --extra-index-url https://download.pytorch.org/whl/cu130
   pip install nn-gpt[flash] --no-build-isolation --extra-index-url https://download.pytorch.org/whl/cu130

Use

  • ab.gpt.act.alter.* – Generates modified neural network models.
    Use the -e argument to set the number of epochs for the initial CV model generation.

  • ab.gpt.act.eval.Eval – Evaluates the models generated in the previous step.

  • ab.gpt.act.tune.Tune* – Performs fine-tuning and evaluation of an LLM. For evaluation purposes, the LLM generates neural network models, which are then trained to assess improvements in the LLM’s performance on this task. The -s flag allows skipping model generation for the specified number of epochs.

  • ab.gpt.act.AccPredictor – Fine-tunes and evaluates a Qwen3-8B accuracy predictor from LEMUR training runs. Given early-epoch accuracies and neural network code, it predicts final best_accuracy and best_epoch.

    Running the script runs four steps in order:

    1. Preprocessing — loads training runs from the nn_dataset API, filters runs with ≥50 epochs, and writes ab/gpt/data/llm_finetuning_data.jsonl
    2. Data preparation for training — converts preprocessed runs into ChatML train/val/test splits (ab/gpt/data/train_llm_dataset.jsonl, val_llm_dataset.jsonl, test_llm_dataset.jsonl)
    3. Model training — QLoRA fine-tunes Qwen3-8B with validation and early stopping; saves the checkpoint to ab/gpt/model2/
    4. Model testing — runs inference on the test split and writes ab/gpt/data/test_predictions.csv and test_metrics.log
    python -m ab.gpt.act.AccPredictor
    

    Individual steps can also be imported:

    from ab.gpt.act.AccPredictor import data_preprocessing, prepare_llm_datasets, train_model, test_model, predict_best_accuracy
    from ab.gpt.act.AccPredictor import DEFAULT_TRAIN_PATH, DEFAULT_VAL_PATH, DEFAULT_OUTPUT_DIR, DEFAULT_TEST_PATH
    
    data_preprocessing()
    prepare_llm_datasets()
    train_model(DEFAULT_TRAIN_PATH, DEFAULT_VAL_PATH)
    test_model(model_path=DEFAULT_OUTPUT_DIR, data_path=DEFAULT_TEST_PATH)
    
    # Inference with the published Hugging Face checkpoint
    best_acc, best_epoch = predict_best_accuracy(task, dataset, metric, nn_code, epoch_1_acc, epoch_2_acc)
    

    Requires a GPU with ≥24 GB VRAM, unsloth, and the LEMUR/nn-dataset package installed.

LangGraph Multi-Agent Workflow

NNGPT supports an optional LangGraph-based multi-agent orchestration mode. The agent system integrates directly inside tune() — no separate entry point, no duplicated logic.

Design Principle

All pipeline logic remains in ab/gpt/util/Tune.py as the single source of truth. Agent nodes are thin wrappers only — they read from state and call the existing functions. No logic is reimplemented inside any agent file.

Agent Flow

The professor-specified flow is: Finetuner → Generator → Evaluator → Predictor

  • manager — controls routing, checks epoch stop condition, decides next node
  • generator — calls nn_gen() / trans_gen(); skips if epoch < skip_epoch; skips evaluator if no code generated
  • evaluator — calls _evaluate_epoch(); stores accuracy and all predictor inputs in state
  • finetuner — calls _finetune_epoch(); increments epoch counter, returns to manager
  • predictor — optional; activates after epoch 1 and epoch 2 accuracies are both available

Any future improvement to nn_gen(), trans_gen(), _evaluate_epoch(), or _finetune_epoch() automatically applies to both classic and agent modes.

Crash Recovery

Agent mode uses LangGraph MemorySaver checkpointing. If the pipeline crashes mid-epoch (e.g. GPU OOM), re-running with the same nn_name_prefix resumes from the last completed node — no restart from epoch 0.

Usage

The agent mode is enabled by default.

To use the accuracy predictor agent:

python -m ab.gpt.act.tune.Tune --use_predictor

Agent Files

File Purpose
ab/gpt/act/agents/run_agent.py Builds and runs the LangGraph StateGraph
ab/gpt/act/agents/manager.py Routing logic and epoch stop condition
ab/gpt/act/agents/predictor.py Optional accuracy prediction node
ab/gpt/act/agents/state.py Shared AgentState TypedDict — field names match LEMUR DB columns
ab/gpt/util/Tune.py Single source of truth: nn_gen, trans_gen, _evaluate_epoch, _finetune_epoch, generate_step, evaluate_step, finetune_step
ab/gpt/act/AccPredictor.py Accuracy predictor: data prep, fine-tuning, and evaluation

Fine-tuned LLMs

🐳 Docker

All versions of this project are compatible with AI Linux and can be seamlessly executed within the AI Linux Docker container.

Installing the latest version of the project from GitHub

docker run --rm -u $(id -u):ab -v $(pwd):/a/mm abrainone/ai-linux:llm bash -c "[ -d nn-gpt ] && git -C nn-gpt pull || git -c advice.detachedHead=false clone --depth 1 https://github.com/ABrain-One/nn-gpt"

Running script

docker run --rm -u $(id -u):ab --shm-size=16G -v $(pwd)/nn-gpt:/a/mm abrainone/ai-linux:llm bash -c "python -m ab.gpt.act.tune.8B"

If recently added dependencies are missing in the AI Linux, you can create a container from the Docker image abrainone/ai-linux:llm, install the missing packages (preferably using pip install <package name>), and then create a new image from the container using docker commit <container name> <new image name>. You can use this new image locally or push it to the registry for deployment on the computer cluster.

Citation

The original version of this project was created at the Computer Vision Laboratory of the University of Würzburg by the authors mentioned below, under the supervision and technical guidance of Dr. Dmitry Ignatov, whose foundational work established the basis for the project. If you find this project to be useful for your research, please consider citing our articles for NNGPT, architecture design and hyperparameter tuning:

@InProceedings{ABrain.NNGPT,
	title = {{NNGPT}: Rethinking {AutoML} with Large Language Models},
	author = {Kochnev, Roman and Khalid, Waleed and Uzun, Tolgay Atinc and Zhang, Xi and Dhameliya, Yashkumar Sanjaybhai and Qin, Furui and Vysyaraju, Chandini and Duvvuri, Raghuvir and Goyal, Avi and Ignatov, Dmitry and Timofte, Radu},
	booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW)},		
	pages = {5664--5674},	
	year={2026}
}

@InProceedings{ABrain.Architect,
	title={From Memorization to Creativity: {LLM} as a Designer of Novel Neural Architectures},
	author={Khalid, Waleed and Ignatov, Dmitry and Timofte, Radu},
	booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW)},	
	pages = {3252--3261},	
	year={2026}
}

@InProceedings{ABrain.HPGPT,
	title={Optuna vs Code Llama: Are {LLMs} a New Paradigm for Hyperparameter Tuning?},
	author={Kochnev, Roman and Goodarzi, Arash Torabi and Bentyn, Zofia Antonina and Ignatov, Dmitry and Timofte, Radu},
	booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision Workshops (ICCVW)},
	url={https://openaccess.thecvf.com/content/ICCV2025W/AIM/papers/Kochnev_Optuna_vs_Code_Llama_Are_LLMs_a_New_Paradigm_for_ICCVW_2025_paper.pdf},
	pages = {5664--5674},
	year={2025},
	doi={10.1109/ICCVW69036.2025.00598}
}

Licenses

This project is distributed under the following licensing terms:

  • models with pretrained weights under the legacy DeepSeek LLM V2 license
  • all neural network models and their weights not covered by the above licenses, as well as all other files and assets in this project, are subject to the MIT license

The idea and leadership of Dr. Ignatov

Metadata

Release files for lmurg 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lmurg 1.0.8
File Size Uploaded Provenance Actions
lmurg-1.0.8.tar.gz 7.6 kB Without provenance Details for lmurg-1.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lmurg 1.0.8
File Interpreter ABI Platform Actions
lmurg-1.0.8-py3-none-any.whl Python 3 none any Details for lmurg-1.0.8-py3-none-any.whl

Total release size: 15.2 kB

Release files / lmurg-1.0.8.tar.gz

Download URL lmurg-1.0.8.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0759097643b9624c04646ba0f0add441efcc17c269f3bb5253077c6b03233dbe
BLAKE2b-256 checksum
How to use checksums
fc71f47e892df488fd30adbadd31ded0c9aefd8edc1d079bbad2c0388b32f5f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / lmurg-1.0.8-py3-none-any.whl

Download URL lmurg-1.0.8-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b813c73056243566be1e5600f3a0ad9e9325da242421ef2f54de065d2a665ec
BLAKE2b-256 checksum
How to use checksums
1047e3ed60ba120e40e22e30d80f7ec6db3f45a27d018a2c3ae684992735b166
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for lmurg 1.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page