Metadata-Version: 2.4
Name: asgt-engine
Version: 1.0.1
Summary: ASGT — CPU-Native Algebraic AI Engine. Zero Float, Pure GF(p) Arithmetic.
Author: Alhdrawi
License: MIT
Project-URL: Homepage, https://github.com/asgt-research/asgt-engine
Keywords: ai,cpu,elliptic-curve,number-theory,rag,integer-arithmetic
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pybind11>=2.10
Dynamic: license-file
Dynamic: requires-python

# ASGT Engine — Algebraic Spectral Generative Theory

**CPU-Native AI Engine | Zero Floating Point | Pure Integer Arithmetic on GF(p)**

ASGT replaces GPU-bound linear algebra with elliptic curve arithmetic over finite fields. The entire engine runs on the CPU's integer ALU — no VRAM, no float, no external dependencies.

## Key Features

- **Zero Float/Double**: All computation uses `uint64_t` modular arithmetic on GF(p)
- **Elliptic Curve Embeddings**: Words → points on E: y² = x³ + ax + b (mod p)
- **Hecke Attention**: Integer-only attention mechanism replacing matrix multiply
- **p-adic Retrieval**: Nearest-neighbor search using p-adic valuation distance
- **Hensel Training**: Exponentially convergent parameter lifting (p-adic Newton)
- **Binary Checkpointing**: Save/load trained models as compact `.asgt` files

## Installation

```bash
pip install asgt-engine
```

## Quick Start

```python
import asgt_engine

# Initialize engine with elliptic curve E(GF(65537))
engine = asgt_engine.ASGTEngine(a=7, b=13, p=65537)

# Train on texts (expands vocab + builds knowledge base)
texts = [
    "The heart pumps blood through the circulatory system",
    "DNA carries the genetic instructions for life",
    "Photosynthesis converts sunlight into chemical energy",
]
engine.train_batch(texts)

# Retrieve relevant knowledge
results = engine.retrieve("What pumps blood?", top_k=3)
for r in results:
    print(f"[sim={r.similarity}] {r.text}")

# Generate answer
answer = engine.generate("What carries genetic information?")
print(answer)  # "DNA carries the genetic instructions for life"

# Save and load model
engine.save_model("my_model.asgt")

engine2 = asgt_engine.ASGTEngine()
engine2.load_model("my_model.asgt")
```

## Architecture

```
Input Text → Tokenizer → EC Point Embedding → Hecke Attention → p-adic Retrieval → Output
     │            │              │                    │                │
  Strings    Normalize     [n]G on E(GF(p))    Σ[wᵢⱼ]Pⱼ        v_p(x-y)
     │        + Split       try-and-increment   integer weights   integer dist
     ▼            ▼              ▼                    ▼                ▼
  Python       C++ ALU        C++ ALU             C++ ALU          C++ ALU
```

## Performance (Google Colab CPU)

| Metric | Value |
|---|---|
| Encoding speed | 44,000+ sentences/sec |
| Retrieval speed | 21,000+ queries/sec |
| Retrieval accuracy | 100% (6/6 benchmark) |
| Model size | 16 bytes per fact |
| Data types used | `uint64_t` only |

## License

MIT
