MYRA: SR-TRBM with LLM-Guided Refinement and Analysis

Hybrid energy-based RBM with LLM-guided structural refinement


🔧 Usage

Extract the dataset before running experiments:

```bash

7z x stan.7z

```

Alternatively, you can use WinRAR or other compatible tools. The model's entire size is approximately 190 MB.


🔬 Experiment Protocol: Single-Seed Band Uniqueness Criterion

The MYRA experiment protocol does not rely on multi-seed averaging or aggregate statistics across runs. Instead, each seed is evaluated independently through a band uniqueness criterion applied over a local lag sweep. The purpose is to obtain a truth value for the seed level in the execution results. The concept is a new idea in the literature.

For reference outputs, see the following:

  • artifacts/run.log—example of a successful run with a valid ground truth
  • artifacts/run_false_example.log—example of a run where the criterion is not satisfied

After training and sampling, the system sweeps lag steps in the range:

[lag_step − 5, lag_step + 7]

Lag[8] Step Sweep ↓

LagSteps=5  | Mix=0.482933 | PixelH=0.3984 | SpatialH=0.4038 | BandConsistent=False
LagSteps=6  | Mix=0.448003 | PixelH=0.3977 | SpatialH=0.4039 | BandConsistent=False
LagSteps=7  | Mix=0.421478 | PixelH=0.3963 | SpatialH=0.4053 | BandConsistent=False
LagSteps=8  | Mix=0.402880 | PixelH=0.4010 | SpatialH=0.4053 | BandConsistent=True
LagSteps=9  | Mix=0.393213 | PixelH=0.3945 | SpatialH=0.4042 | BandConsistent=False
LagSteps=10 | Mix=0.377839 | PixelH=0.3963 | SpatialH=0.4038 | BandConsistent=False
LagSteps=11 | Mix=0.369841 | PixelH=0.4002 | SpatialH=0.4045 | BandConsistent=False
LagSteps=12 | Mix=0.359160 | PixelH=0.3989 | SpatialH=0.4055 | BandConsistent=False
LagSteps=13 | Mix=0.353690 | PixelH=0.4011 | SpatialH=0.4057 | BandConsistent=False
LagSteps=14 | Mix=0.343051 | PixelH=0.3960 | SpatialH=0.4033 | BandConsistent=False

Entropy Band Analysis

Entropy Band             : Closed interval [0.398905, 0.404758]
Choice(Mix | Band)       : C(0.404569 | [0.398905, 0.404758]) = 0.404569
Band Consistency         : True

✅ Seed Experiment Result

SEED EXPERIMENT: SUCCESS → This run successfully satisfies the band consistency criterion. Notably, the valid solution emerges precisely at lag step = 8, indicating a well-aligned entropy balance within the defined band.

The outcome is relatively favorable given the stochastic nature of the process.

At each step, the MCMC Mix Index is compared against the closed entropy interval:

[min(PixelH, SpatialH), max(PixelH, SpatialH)]

A seed experiment is considered successful if and only if all three conditions hold simultaneously:

  1. Global Mix Index ∈ Entropy Band
  2. BandConsistent = True at the characteristic lag step
  3. Exactly one lag step across the full sweep satisfies `BandConsistent = True`.

This implies a unique choice function over the admissible band:

Choice(Mix | Band) : C(x | [y, z]) = x


🎯 Key Criterion: Uniqueness

Condition (iii) is the structurally decisive one.

If multiple lag steps produce band-consistent results, the mixing signal is diffuse—the system has not converged to a sharp, well-localized attractor.

A system that converges everywhere has converged nowhere in particular.

Uniqueness of the band-consistent lag is therefore not a byproduct of the evaluation; it is the criterion itself.


🔥 Interpretation

This design reflects a thermodynamic intuition:

  • A well-mixed chain should exhibit band consistency precisely at the characteristic autocorrelation scale of its energy landscape:
  • Not broadly
  • Not sporadically

The goal is sharp localization, not widespread agreement.


⏱️ Runtime

  • SR-TRBM training takes approximately 30 minutes per seed (PCD-1).
  • LLM-based refinement takes about 3 hours for ~120 samples (10% of 1200).
  • Total runtime: about 3.5–4 hours.

🧠 Core Idea

What did the model actually learn?

MYRA (Model Representation Anatomy) is a hybrid framework for analyzing and refining learned representations in energy-based models, particularly RBMs.

Most models are optimized for output quality. MYRA focuses instead on the internal structure of what is learned. Rather than only evaluating generated samples, MYRA investigates how learned patterns are organized, combined, and expressed during generation.


⚙️ Model Overview

MYRA combines:

  • a Restricted Boltzmann Machine (RBM) for generation
  • an LLM-based interpretive layer for structural analysis
  • an energy-based acceptance mechanism for refinement

The system operates as a loop:

  1. RBM generates samples
  2. LLM analyzes structure and proposes refinements
  3. Changes are accepted or rejected based on energy
  4. The process repeats

This forms a guided generative refinement process.


🔍 LLM Integration

MYRA uses an LLM as an external interpretive layer.

The LLM is not used for generation. It analyzes model behavior, evaluates structure, and suggests refinements during the iterative loop.


⚙️ Quick Start (Default Backend)

The current setup uses the OpenAI API for fast and minimal setup.

You can run the system immediately without modifying the backend.


🔁 Backend Flexibility

The LLM layer is modular.

The default implementation (openaiF) can be replaced or extended to support other providers such as:

  • Anthropic (Claude)
  • Google (Gemini)
  • Meta (Llama / local models)
  • Mistral, DeepSeek, Qwen

Switching backends typically requires only small changes in:

  • client.py
  • __init__.py
  • import references in srtrbm_project_core.py

🔗 Repository

Full implementation and backend details:

👉 https://github.com/cagasolu/srtrbm-llm-hybrid


The LLM acts as an interpretive layer, not a source of ground truth.


🧪 Key Observation

In practice, we observe:

  • stable sampling without collapse
  • consistent pattern recombination across different seeds
  • outputs that are structurally coherent but not present in the dataset

This suggests a gap between learned structure and generated outputs.


⚙️ Installation

Recommended environment

  • Ubuntu 22.04 LTS
  • CUDA 12.x
  • PyTorch 2.x
pip install -r requirements.txt

System Overview of MYRA

MYRA
└── SR-TRBM (Energy-Based Generator)
    └── Refinement (Structural + Embedding)
        └── LLM
            └── Interpretation & Analysis
                └── Final Output   ← this model

Architecture

MYRA combines three main components:

  • SR-TRBM → energy-based generative model
  • MYRA complex refinement → structural correction via embedding matching
  • LLM layer → interpretation and convergence analysis

📂 Repository Structure

.
├── 🧠 Core Engine
│   └── srtrbm_project_core.py       # Energy-based generation (SR-TRBM) & Gibbs sampling dynamics
│
├── 🤖 LLM Integration (openaiF/)
│   ├── client.py                    # Robust LLM client (Retry/Fallback mechanisms)
│   ├── gateway.py                   # Semantic interpretation & reasoning layer
│   └── hook.py                      # Epistemic control & decision-making framework
│
├── 🧩 Refinement System
│   ├── supplement/
│   │   └── cluster.py               # Embedding-based matching & latent clustering
│   └── correction/
│       └── NO.py                    # Energy-aware & spatial correction modules
│
├── ⚙️ Configuration
│   └── yaml/                        # LLM policies, guidance rules, and hyperparameters
│
├── 📊 Analysis & Metrics
│   └── analysis/                    # Energy tracking, LPIPS metrics, and convergence logs
│
├── 📈 Visualization
│   └── graphs/                      # Training curves & energy landscape visualizations
│
├── 📦 Assets
│   ├── zeta_mnist_hybrid.pt         # Pre-trained model weights (PyTorch)
│   └── stan.dgts                    # Core dataset files
│
└── 🧪 Outputs
    └── artifacts/                   # Generated samples, inference logs, and results

How It Works

  1. RBM generates initial samples
  2. LLM proposes structural edits (pixel-level)
  3. Edits are evaluated using energy difference (ΔE)
  4. Accepted edits refine the sample

This can be interpreted as:

Learned MCMC proposal distribution guided by a language model


Results

  • Reconstruction Accuracy: ~0.98
  • LPIPS: ~0.15
  • Stable energy dynamics
  • Low collapse risk

Uses

Direct Use

  • Generating structured digit samples
  • Studying hybrid energy-based + LLM systems

Research Use

  • Learned proposal distributions
  • Energy-guided refinement
  • Hybrid generative modeling

Limitations

  • Reduced sample diversity under strong refinement
  • Sensitive to acceptance scaling
  • Depends on LLM consistency

Training Details

Training Data

  • Fashion-MNIST (784-dimensional)

Training Procedure

  • RBM trained via contrastive divergence
  • Refinement applied post-generation

Evaluation

Metrics

  • Reconstruction MSE
  • LPIPS (perceptual similarity)
  • Energy gap
  • Sample diversity

Technical Insight

The system bridges:

  • Energy-based modeling (RBM)
  • Semantic correction (LLM)

Resulting in a:

Memory-augmented, energy-aware refinement system


Files

  • artifacts/ → generated samples and logs
  • srtrbm_project_core.py → main implementation

Citation

cff-version: 1.2.0
title: "MYRA: SR-TRBM with LLM-Guided Refinement"
version: "v1.0.1"
date-released: 2026-03-25

authors:
  - given-names: "Görkem Can"
    family-names: "Süleymanoğlu"

identifiers:
  - type: doi
    value: "10.5281/zenodo.19211121"

links:
  - type: repository
    url: "https://github.com/cagasolu/srtrbm-llm-hybrid"
  - type: model
    url: "https://huggingface.co/cagasoluh/MYRA"

keywords:
  - energy-based-models
  - rbm
  - llm
  - hybrid-ai
  - generative-model

Contact

Maintained by: Görkem Can Süleymanoğlu

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train cagasoluh/MYRA