PruneForge
A Hierarchical Pruning Architecture for On-Device Language Intelligence
PruneForge is a research prototype (v0.1, 2026) that replaces the standard transformer decode-from-scratch approach with a retrieve → prune → assemble pipeline, designed to run efficiently on CPU-class hardware.
Architecture
Query
│
▼
Knowledge Pool ← compressed semantic store (contrastive pre-training)
│ TopK retrieval
▼
Stage 1: Morphological Decomposition ← BiLSTM, character-level, language-agnostic
│
Stage 2: Topical Relevance Filter ← bilinear scorer, prunes ~70% of candidates
│
Stage 3: Composability Assessment ← pairwise MLP, O(k²)
│
Stage 4: Coherence Validation ← small Transformer encoder
│
Stage 5: Handoff Formatting ← sort by relevance, no parameters
│
▼
Composition Motor ← Transformer decoder + self-correction loop
│
▼
Output text
Symbolic Content Flag (SCF): when the candidate set is predominantly symbolic (code, math, formulas), stages 2–4 switch to operator-aware modes rather than semantic modes.
Installation
pip install pruneforge
With HNSW retrieval support (optional, requires faiss):
pip install "pruneforge[hnsw]"
From source (editable):
git clone https://github.com/astromini/pruneforge
cd pruneforge
pip install -e .
Quick Start
Inference
from pruneforge import PruneForgeModel
model = PruneForgeModel.from_pretrained("output/")
response = model.generate("Yarın hava nasıl olacak?")
print(response)
Training
# Plain-text corpus only (self-supervised)
python train.py --data corpus.txt --lang tr --output output/
# With morphological annotations (Stage 1 supervised)
python train.py --data corpus.txt --morph morph.tsv --lang tr --output output/
# GPU
python train.py --data corpus.txt --lang multilingual --device cuda --output output/
# Quick smoke test (small epochs)
python train.py --data corpus.txt --pool_epochs 1 --stage_epochs 1 --motor_epochs 1
Training runs 7 sequential phases automatically:
| Phase | Component | Notes |
|---|---|---|
| 1 | Knowledge Pool | Contrastive pre-training (NT-Xent) |
| 2 | Stage 1 | Morphological decomposition (supervised or self-supervised) |
| 3 | Stage 2 | Topical relevance filter |
| 4 | Stage 3 | Composability assessment |
| 5 | Stage 4 | Coherence validation |
| 6 | Motor | Supervised CE + REINFORCE |
| 7 | Joint | End-to-end fine-tuning |
Morphological Corpus Format
For Stage 1 supervised training (--morph), provide a TSV file:
yemekler yemek ler
koşuyorum koş uyor,um
running run ing
Columns: token \t root \t affix_1,affix_2,...
If no morphological corpus is available, omit --morph — Stage 1 falls back
to self-supervised character-level reconstruction.
Configuration
All hyperparameters live in pruneforge/config.py.
Pass a PruneForgeConfig to any component:
from pruneforge.config import PruneForgeConfig
cfg = PruneForgeConfig()
cfg.knowledge_pool.num_concepts = 500_000 # reduce for low-RAM devices
cfg.knowledge_pool.embedding_dim = 128
cfg.motor.num_layers = 4
Package Structure
pruneforge/
├── pruneforge/
│ ├── __init__.py
│ ├── config.py ← all hyperparameters
│ ├── inference.py ← PruneForgeModel (end-to-end)
│ ├── knowledge_pool/
│ │ ├── __init__.py
│ │ └── pool.py ← KnowledgePool + QueryEncoder
│ ├── pipeline/
│ │ ├── __init__.py
│ │ ├── pipeline.py ← HierarchicalPruningPipeline
│ │ ├── stage1_morphology.py
│ │ ├── stage2_relevance.py
│ │ ├── stage3_composability.py
│ │ ├── stage4_coherence.py
│ │ └── stage5_handoff.py
│ ├── motor/
│ │ ├── __init__.py
│ │ └── motor.py ← CompositionMotor
│ └── utils/
│ ├── __init__.py
│ └── data.py ← tokenizer + datasets
├── train.py ← single-command training script
├── tests/
│ └── test_e2e.py
├── pyproject.toml
├── setup.py
└── requirements.txt
Running Tests
pip install -e .
python tests/test_e2e.py
Expected output:
PruneForge End-to-End Smoke Test
========================================
[ 5/5 ] Tokenizer ... OK
[ 1/5 ] Knowledge Pool ... OK
[ 2/5 ] Full Pipeline (Stages 1-5) ... OK (10→N→N→N tokens)
[ 3/5 ] Composition Motor ... OK (iterations used: [1, 1])
[ 4/5 ] Training losses ... OK (CE=... RL=...)
✓ All tests passed.
Requirements
- Python ≥ 3.9
- PyTorch ≥ 2.0.0
- NumPy ≥ 1.24.0
- (optional) faiss-cpu ≥ 1.7.4 for HNSW retrieval
License
Apache 2.0 — see LICENSE.
Citation
@software{pruneforge2026,
author = {astromini},
title = {PruneForge: A Hierarchical Pruning Architecture for On-Device Language Intelligence},
year = {2026},
version = {0.1.0},
url = {https://github.com/astromini/pruneforge},
}
Metadata
Release files for pruneforge 0.1.4
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 |
|---|---|---|---|---|
| pruneforge-0.1.4.tar.gz | 34.4 kB | Without provenance | Details for pruneforge-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pruneforge-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for pruneforge-0.1.4-py3-none-any.whl |
Total release size: 72.8 kB
Release files / pruneforge-0.1.4.tar.gz
| Download URL | pruneforge-0.1.4.tar.gz |
|---|---|
| Size | 34.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60f73322ea2b8be4576cc5c02fcd60bc4aa28f23ab8326719bed6e457ea7d9ce
|
|
BLAKE2b-256 checksum How to use checksums |
b5db0f3cb99bd0260dca76d43b0260f96939b703878f08e63681a4ede730ba84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / pruneforge-0.1.4-py3-none-any.whl
| Download URL | pruneforge-0.1.4-py3-none-any.whl |
|---|---|
| Size | 38.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6669596d513ce90bdf7eee74e680cf62ae1de074115229db4b54b87d8a00bf8a
|
|
BLAKE2b-256 checksum How to use checksums |
9cb621147c0ccc24a329d1744dc3d6ce1f9242b96dc9f4eaf9595c00c614cd61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Security for pruneforge 0.1.4
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.