Skip to main content

13.7M trainable parameter neural pre-reasoning engine for grounding LLMs before they answer.

Project description

Pre-Reasoning

Pre-Reasoning is a Mia Labs structural analysis engine that grounds an LLM before it answers. It uses a 13.7M trainable parameter MoE neural model to surface dependencies, derived assumptions, root blockers, unlock order, parallel work, cycles, and conflicts from problem text.

The engine ships with bundled weights and declares its torch dependency; install and run, no model download needed.

What It Does

Given natural-language problem text, the engine extracts structure across five learned families:

Family What it detects Output
F1 - Dependencies Forward/reverse dependencies, temporal ordering, chains ROOT BLOCKERS, UNLOCK SEQUENCE, PARALLEL WORK, CYCLES
F2 - Conflicts Competing positions, incompatible entities CONFLICTS with pair precision
F3 - Requirements Numeric thresholds, operator constraints (>=, <=) REQUIREMENTS with verdict
F4 - Conditionals If-then edges, gated dependencies CONDITIONAL EDGES with entity binding
F5 - Transitive Closure Implicit assumptions from dependency chains DERIVED ASSUMPTIONS (built-in E4 expert)

Install

pip install pre-reasoning

For local development from this repo:

pip install -e .

Python Usage

from pre_reasoning import analyze, pulse

result = analyze("Frontend depends on API. API depends on Auth.")
print(result["trace"])

check = pulse(
    "Frontend depends on API. API depends on Auth.",
    "Fix Auth first, then verify the API before frontend work."
)
print(check["status"])

CLI Usage

pre-reasoning "A depends on B. B depends on C."
pre-reasoning --json "CTO conflicts with senior dev."
pre-reasoning --info

To use a different weights file, set PRE_REASONING_CHECKPOINT=/path/to/weights.safetensors or pass --checkpoint.

Eval Results: 35/35 PASS

The 13.7M trainable parameter MoE model passes all 35 metrics across five families. 2,250 eval examples, seed 7777.

Family Metrics Score
F1 - Dependencies 9 9/9
F2 - Conflicts 4 4/4
F3 - Requirements 5 5/5
F4 - Conditionals 4 4/4
F5 - Transitive Closure 4 4/4
Cross-Family Integrity 9 9/9
Total 35 35/35

Full metric tables with explanations and threshold rationale: EVALS.md

Terminal-Bench 2: 34/40 (85%)

LLM grounding benchmark on 40 real coding tasks (Harbor 0.15.0). GPT-5.5 agent with autonomous pre-reasoning (min 12 blocks, pulse every 60s).

Value
Score 34/40 (85%)
Model GPT-5.5
Total runtime 492 min
Total API cost $102.50
Failures torch-tensor-parallelism, gcode-to-text, make-doom-for-mips (timeout), gpt2-codegolf (timeout), polyglot-rust-c, filter-js-from-html

Full task-by-task results with token counts and costs: benchmarks/terminal_bench_2.xlsx

Architecture

User text
  -> neural perception (13.7M MoE)
  -> neural findings converted to structural blocks
  -> built-in E4 expert infers transitive closure assumptions
  -> derived assumptions appended as dependency blocks
  -> graph reasoning
  -> structural trace

File Map

Path Purpose
pre_reasoning/ Installable Python package and CLI entry point
pre_reasoning/inference.py 13.7M trainable parameter MoE neural perception layer
pre_reasoning/harness.py Graph-reasoning core
pre_reasoning/engine.py Default v3 engine: neural perception + built-in closure + graph reasoning
pre_reasoning/engine_core.py Core engine: neural perception + graph reasoning
pre_reasoning/checkpoints/pre-reasoning-12m-v3.safetensors Bundled model weights (85MB file, 13.7M trainable parameters)
examples/ Runnable usage examples
tests/ Pytest suite
skill/SKILL.md Agent skill descriptor for model adoption
hermes-agent/SOUL.md Append block for Hermes SOUL.md (identity add-on)
hermes-agent/hermes_agent_hooks.py Local-only Hermes plugin + agent-hooks installer and config snippet
hooks/ Claude Code before/after hooks for enforced pre-reasoning
INSTALL.md Manual install and hook setup guide
EVALS.md Full eval tables with metric explanations and threshold rationale
WHY_TRACES_WORK.md Literature connection, 13 cited papers

Weights Policy

The raw training checkpoint is not part of the release. The package bundles pre_reasoning/checkpoints/pre-reasoning-12m-v3.safetensors. This is an inference artifact with 13.7M trainable parameters. The file contains 22.1M tensor values because it also stores fixed causal attention masks. It ships no optimizer state, LR schedules, step counters, RNG state, training config, or raw checkpoint provenance.

License

MIT License. See LICENSE.

Authors

Luis Lozano and Dr. Shannon (Mia Labs' AI researcher)

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

pre_reasoning-3.1.0.tar.gz (51.2 MB view details)

Uploaded Source

Built Distribution

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

pre_reasoning-3.1.0-py3-none-any.whl (51.2 MB view details)

Uploaded Python 3

File details

Details for the file pre_reasoning-3.1.0.tar.gz.

File metadata

  • Download URL: pre_reasoning-3.1.0.tar.gz
  • Upload date:
  • Size: 51.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for pre_reasoning-3.1.0.tar.gz
Algorithm Hash digest
SHA256 c9abcbffcfcc1b73d55cb82537b69be78859d927dfb6f5fb0afb53535d00a36b
MD5 8d9918f872103f14f8a680eec88affa4
BLAKE2b-256 b0a0e32bb2c4d8af5e36dad620acf5d21348a61c9d6a21e5967183f405c90df8

See more details on using hashes here.

File details

Details for the file pre_reasoning-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: pre_reasoning-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 51.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for pre_reasoning-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c41358d799f11300909310ef0ff76e64c2a4280a92ffef683b3d7280b69549b4
MD5 333ca85f61e8e2acda6d683c6d543d08
BLAKE2b-256 fad9163b65bca16df512a93555177c831554218155237644ab85894fc5ca6806

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