ebrm-system
Energy-Based Reasoning Machine — the system. A production reasoning pipeline: intent routing, adaptive test-time compute, energy-based scoring, external verifier bridge, and self-consistency voting.
This repository is the system layer on top of the ebrm model (research / paper reference). ebrm-system is the framework you deploy — ebrm is the model you cite.
Why this exists
Modern reasoning LLMs are strong but unverifiable: they emit plausible chains that are hard to check mechanically. ebrm-system wraps any base reasoner with a pipeline that makes answers auditable, budget-aware, and consistency-checked.
Architecture
query
│
▼
┌──────────────────────────┐
│ 1. Intent Classifier │ rule-based or neural; emits difficulty + budget
└──────────────────────────┘
│
▼
┌──────────────────────────┐
│ 2. Hierarchical Reasoner │ latent-thought inner loop (Coconut-inspired)
└──────────────────────────┘
│
▼
┌──────────────────────────┐
│ 3. Adaptive Langevin │ steps scale with difficulty; K parallel traces
└──────────────────────────┘
│
▼
┌──────────────────────────┐
│ 4. Process Reward Model │ stepwise energy → trace confidence
└──────────────────────────┘
│
▼
┌──────────────────────────┐
│ 5. External Verifier │ SymPy / sandboxed exec / regex — mechanical check
└──────────────────────────┘
│
▼
┌──────────────────────────┐
│ 6. Self-Consistency Vote │ weighted by confidence or 1/energy
└──────────────────────────┘
│
▼
answer + audit trail
Every stage is a swappable component behind a Protocol. The verifier layer never hallucinates — it only confirms what SymPy / Python / regex can mechanically check.
Install
pip install ebrm-system
From source:
git clone https://github.com/piyushptiwari1/ebrm-system
cd ebrm-system
pip install -e ".[dev]"
Quick start
# See what the intent router thinks about a query
ebrm-system classify "Solve: 3x + 7 = 22"
# Verify an answer mechanically
ebrm-system verify "x**2 + 2*x + 1" "(x+1)**2"
Python API:
from ebrm_system.intent import RuleBasedClassifier
from ebrm_system.verifiers import SymPyVerifier, VerifierChain
from ebrm_system.voting import Candidate, SelfConsistencyVoter
clf = RuleBasedClassifier()
pred = clf.classify("Solve: 3x + 7 = 22")
# pred.suggested_langevin_steps, pred.suggested_trace_count, ...
chain = VerifierChain([SymPyVerifier()])
results = chain.verify("5", {"expected": "5"})
assert chain.all_passed(results)
voter = SelfConsistencyVoter(numerical=True, tolerance=0.01, weight_by="inverse_energy")
result = voter.vote([
Candidate(answer=5.0, energy=-2.0),
Candidate(answer=5.0, energy=-1.5),
Candidate(answer=4.0, energy= 3.0),
])
# result.answer == 5.0, weighted by low energy
Components
| Module | Status | Purpose |
|---|---|---|
ebrm_system.intent |
✅ stable | Intent + difficulty + compute budget |
ebrm_system.verifiers |
✅ stable | SymPy / exec / regex / Lean / DRI + intent routing |
ebrm_system.voting |
✅ stable | Self-consistency with weighted bucketing |
ebrm_system.inference |
✅ stable | Langevin candidates, QJL, TurboQuant KV + attention |
ebrm_system.reward |
✅ stable | LatentIndex (QJL-backed nearest-neighbour reward) |
ebrm_system.core |
✅ stable | HierarchicalLatentReasoner — end-to-end orchestrator |
Development
pip install -e ".[dev]"
pytest # run tests
ruff check . # lint
mypy src # type-check
pre-commit install # optional hooks
CI runs lint + type + test on Python 3.10/3.11/3.12/3.13. See .github/workflows/ci.yml.
Design principles
- Mechanical over mystical — verifiers confirm with SymPy / exec / regex; never an LLM grading an LLM.
- Budget-aware — easy queries don't pay for hard-query compute. Intent routing controls Langevin steps, restarts, and trace count.
- Audit-first — every candidate carries its trace, energy, and verifier evidence.
- Swappable — everything is a Protocol. Swap the rule-based classifier for a neural one; swap SymPy for Z3; drop in your own voter.
Citation
If you use this system in academic work, please cite the model paper:
@software{ebrm_system_2026,
author = {Tiwari, Piyush},
title = {ebrm-system: An Energy-Based Reasoning Machine pipeline},
year = {2026},
url = {https://github.com/piyushptiwari1/ebrm-system}
}
License
Apache 2.0. See LICENSE.
Metadata
Release files for ebrm-system 0.31.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ebrm_system-0.31.0.tar.gz | 147.2 kB | Without provenance | Details for ebrm_system-0.31.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ebrm_system-0.31.0-py3-none-any.whl | Python 3 | none | any | Details for ebrm_system-0.31.0-py3-none-any.whl |
Total release size: 289.3 kB
Release files / ebrm_system-0.31.0.tar.gz
| Download URL | ebrm_system-0.31.0.tar.gz |
|---|---|
| Size | 147.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05907adf19f76c728117ff542d49fb0ade2e4d5895fd699d6126ffbcf02584e1
|
|
BLAKE2b-256 checksum How to use checksums |
33c713aba9a71fc77fe3511a7541adb43d43b9df0a6cd03eb71edf7534edb630
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / ebrm_system-0.31.0-py3-none-any.whl
| Download URL | ebrm_system-0.31.0-py3-none-any.whl |
|---|---|
| Size | 142.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc71b18fb90ac81389bca2f49ec7b4d01fd9d8841730ce1ade351e216fd000ef
|
|
BLAKE2b-256 checksum How to use checksums |
743460d482e6facc8f7e3fbc463a8d09de61393b533be58c33d0b3c1b98f4bc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for ebrm-system 0.31.0
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.