⚛️ AMF — Atomic Model Fragmentation
First Arabic-originated Molecular Inference Engine for LLMs أول مكتبة عربية توفر محرك استدلال جزيئي للنماذج اللغوية الكبيرة
pip install amf-core
What is AMF?
AMF (Atomic Model Fragmentation) is a Python library that enables running large language models (LLMs) on severely resource-constrained hardware — including machines with less than 1 GB of VRAM and as little as 300 MB of RAM.
Instead of loading an entire model into memory, AMF:
- Fragments the model into independent semantic cells
- Analyzes each user prompt to determine which cells are needed
- Loads only the required cells on demand via memory-mapping
- Infers using only the active subset of weights
Validated on Kaggle: Qwen2.5-7B (9 GB model) running with < 500 MB RAM ✅
Installation
pip install amf-core
Optional extras:
pip install amf-core[safetensors] # Safetensors / HuggingFace support
pip install amf-core[dev] # Development tools
Requirements: Python ≥ 3.10, numpy, gguf, rich, scikit-learn
Quick Start
1 — Direct Molecular Inference (fastest)
import amf
eng = amf.engine("path/to/model.gguf")
eng.load()
print(eng.predict("Hello")) # → "resilient"
print(eng.generate("Hello", n=5)) # → "Hello resilient strong bold clear"
eng.close()
2 — Context manager (auto-close)
import amf
with amf.engine("model.gguf") as eng:
print(eng.predict("The future of AI is"))
3 — Full Fragmentation Pipeline
import amf
model = amf.load_universal("path/to/model.gguf")
cells = amf.fragment(model, strategy="functional", output_dir="./cells")
print(f"Generated {cells.total_cells} cells ({cells.total_bytes / 1e6:.0f} MB)")
for cell in cells.cells:
print(f" {cell.cell_id:30s} DNA: {cell.dna_tag} ({cell.size_mb:.1f} MB)")
4 — CLI
amf fragment --model qwen2.5:0.5b # Fragment a model
amf chat # Interactive chat
amf info # System info
Architecture
AMF operates in 6 distinct phases:
User Prompt
│
▼
┌──────────────────────────────────────────────────────────┐
│ 1. Universal Parsing │ ModelLoader reads GGUF / │
│ │ Safetensors → UniversalModel │
├──────────────────────────┼───────────────────────────────┤
│ 2. Weight Analysis │ WeightAnalyzer classifies │
│ │ tensors by zone & function │
├──────────────────────────┼───────────────────────────────┤
│ 3. DNA Tagging │ SortingAlgorithm assigns │
│ │ tags: A-L-003-Q │
│ │ (Attention-Linguistic-L3-Q) │
├──────────────────────────┼───────────────────────────────┤
│ 4. Intent Analysis │ IntentAnalyzer determines │
│ │ which layer zones are needed │
├──────────────────────────┼───────────────────────────────┤
│ 5. Molecular Engine │ Loads only required cells │
│ │ via selective mmap │
├──────────────────────────┼───────────────────────────────┤
│ 6. AMFEngine Inference │ Forward pass on active │
│ │ weight subset (NumPy) │
└──────────────────────────┴───────────────────────────────┘
Layer Zones
| Zone | Layers | Specialisation |
|---|---|---|
| Linguistic | 0 – 7 | Grammar, syntax, tokens |
| Semantic | 8 – 15 | Meaning, context |
| Reasoning | 16–23 | Logic, math, code |
DNA Tag Format
A - L - 003 - Q
│ │ │ └─ Component (Q/K/V/O/Gate/Up/Down/Norm)
│ │ └──────── Layer index (zero-padded)
│ └─────────────── Zone (L=Linguistic / S=Semantic / R=Reasoning)
└───────────────────── Type (A=Attention / F=FFN / C=Core)
AMFEngine API
from engine.amf_engine import AMFEngine
eng = AMFEngine("model.gguf", inference_layer=20)
eng.load()
eng.predict("Hello") # → str
eng.generate("Hello", n=5) # → str
eng.set_layer(16) # switch inference layer
eng.list_layers() # → [0, 1, ..., 23]
eng.info() # → dict
eng.close()
Supported quantisation formats
| Format | Status |
|---|---|
| F32 | ✅ Full |
| F16 | ✅ Full |
| Q8_0 | ✅ Full |
| Q4_K_M | ✅ Approximate |
| Q4_0 | ✅ Approximate |
Benchmark
| Model | Full RAM | AMF RAM | Reduction |
|---|---|---|---|
| Qwen2.5-0.5B | ~400 MB | ~80 MB | 5× |
| Qwen2.5-7B (Q4) | ~4.5 GB | ~500 MB | 9× |
| Qwen2.5-32B (Q4) | ~20 GB | ~500 MB | 40× |
CPU-only. No GPU required.
Supported Models
| Model Family | Format | Status |
|---|---|---|
| Qwen 2.5 (all sizes) | GGUF | ✅ Tested |
| Qwen 3 / 3.5 | GGUF | ✅ Compatible |
| LLaMA 3 | GGUF | ✅ Compatible |
| Mistral | GGUF | ✅ Compatible |
| HuggingFace models | Safetensors | 🔄 Beta |
Contributing
git clone https://github.com/jadcrypto/amf-core.git
cd amf-core
pip install -e .[dev]
pytest tests/
License
MIT — see LICENSE.
Citation
@software{amf_core,
title = {AMF: Atomic Model Fragmentation},
author = {Jad},
year = {2026},
url = {https://github.com/jadcrypto/amf-core}
}
Metadata
Release files for amf-core 0.2.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 | |
|---|---|---|---|---|
| amf_core-0.2.0.tar.gz | 47.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| amf_core-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 99.8 kB
Release files / amf_core-0.2.0.tar.gz
| Download URL | amf_core-0.2.0.tar.gz |
|---|---|
| Size | 47.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10a38bb9d4cc2959d0ea395d5514e1b8008d2025c967848982c9e2c9ee350f55
|
|
BLAKE2b-256 checksum How to use checksums |
c1ab2d988e25ddbc4db1fb41459f2e4072dde57d37902a37cda218880b6c2345
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / amf_core-0.2.0-py3-none-any.whl
| Download URL | amf_core-0.2.0-py3-none-any.whl |
|---|---|
| Size | 52.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e45e3866bca461795bf84704ae2654ecf13da053ab5df6e681319ae537f1ed1
|
|
BLAKE2b-256 checksum How to use checksums |
fb27ac0aa642a49fd7ed727e158ffd5db1672274fe41387aaac2364d682f2431
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for amf-core 0.2.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.