optimumai 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. optimumai-0.1.0/.github/workflows/ci.yml +33 -0
  2. optimumai-0.1.0/.github/workflows/publish.yml +42 -0
  3. optimumai-0.1.0/.gitignore +31 -0
  4. optimumai-0.1.0/CHANGELOG.md +30 -0
  5. optimumai-0.1.0/LICENSE +21 -0
  6. optimumai-0.1.0/PKG-INFO +181 -0
  7. optimumai-0.1.0/README.md +141 -0
  8. optimumai-0.1.0/examples/quickstart.py +31 -0
  9. optimumai-0.1.0/pyproject.toml +76 -0
  10. optimumai-0.1.0/src/optimumai/__init__.py +31 -0
  11. optimumai-0.1.0/src/optimumai/algebra/__init__.py +6 -0
  12. optimumai-0.1.0/src/optimumai/algebra/matrix.py +94 -0
  13. optimumai-0.1.0/src/optimumai/algebra/vector.py +158 -0
  14. optimumai-0.1.0/src/optimumai/cli/__init__.py +0 -0
  15. optimumai-0.1.0/src/optimumai/cli/main.py +150 -0
  16. optimumai-0.1.0/src/optimumai/config.py +41 -0
  17. optimumai-0.1.0/src/optimumai/core/__init__.py +7 -0
  18. optimumai-0.1.0/src/optimumai/core/_fmt.py +40 -0
  19. optimumai-0.1.0/src/optimumai/core/base_op.py +58 -0
  20. optimumai-0.1.0/src/optimumai/core/explain.py +46 -0
  21. optimumai-0.1.0/src/optimumai/core/trace.py +97 -0
  22. optimumai-0.1.0/src/optimumai/probability/__init__.py +5 -0
  23. optimumai-0.1.0/src/optimumai/probability/softmax.py +83 -0
  24. optimumai-0.1.0/src/optimumai/transformers/__init__.py +5 -0
  25. optimumai-0.1.0/src/optimumai/transformers/attention.py +117 -0
  26. optimumai-0.1.0/src/optimumai/utils/__init__.py +0 -0
  27. optimumai-0.1.0/src/optimumai/visualization/__init__.py +5 -0
  28. optimumai-0.1.0/src/optimumai/visualization/terminal.py +88 -0
  29. optimumai-0.1.0/tests/test_algebra.py +65 -0
  30. optimumai-0.1.0/tests/test_base_op_and_config.py +40 -0
  31. optimumai-0.1.0/tests/test_cli.py +59 -0
  32. optimumai-0.1.0/tests/test_core.py +33 -0
  33. optimumai-0.1.0/tests/test_probability.py +40 -0
  34. optimumai-0.1.0/tests/test_transformers.py +47 -0
  35. optimumai-0.1.0/uv.lock +3281 -0
@@ -0,0 +1,33 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ # setup-uv already creates and activates a .venv (VIRTUAL_ENV is set),
25
+ # so install straight into it — no explicit `uv venv` needed.
26
+ - name: Install project
27
+ run: uv pip install -e ".[dev]"
28
+
29
+ - name: Lint
30
+ run: uv run ruff check src tests
31
+
32
+ - name: Test
33
+ run: uv run pytest --cov=optimumai --cov-report=term-missing
@@ -0,0 +1,42 @@
1
+ name: Publish to PyPI
2
+
3
+ # Publishes on a GitHub Release. Uses PyPI Trusted Publishing (OIDC) — no API
4
+ # token required. One-time setup on PyPI: add a trusted publisher pointing at
5
+ # this repo + workflow (owner: muhammadyahiya, repo: optimumai,
6
+ # workflow: publish.yml, environment: pypi).
7
+
8
+ on:
9
+ release:
10
+ types: [published]
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v5
19
+ - name: Build sdist and wheel
20
+ run: uv build
21
+ - name: Upload artifacts
22
+ uses: actions/upload-artifact@v4
23
+ with:
24
+ name: dist
25
+ path: dist/
26
+
27
+ publish:
28
+ needs: build
29
+ runs-on: ubuntu-latest
30
+ environment:
31
+ name: pypi
32
+ url: https://pypi.org/project/optimumai/
33
+ permissions:
34
+ id-token: write # required for trusted publishing
35
+ steps:
36
+ - name: Download artifacts
37
+ uses: actions/download-artifact@v4
38
+ with:
39
+ name: dist
40
+ path: dist/
41
+ - name: Publish to PyPI
42
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,31 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ *.egg
9
+
10
+ # Virtual environments
11
+ .venv/
12
+ venv/
13
+ env/
14
+
15
+ # Tooling
16
+ .pytest_cache/
17
+ .ruff_cache/
18
+ .mypy_cache/
19
+ .coverage
20
+ htmlcov/
21
+ coverage.xml
22
+
23
+ # Environment / secrets
24
+ .env
25
+ .env.*
26
+ !.env.example
27
+
28
+ # OS / editor
29
+ .DS_Store
30
+ .idea/
31
+ .vscode/
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ All notable changes to OptimumAI are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/), and the project adheres to
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.1.0] — 2026-07-03
8
+
9
+ The first release ships the spine of the SDK: the tracer engine plus the full
10
+ arc from a dot product to transformer attention, each runnable with
11
+ `explain=True`.
12
+
13
+ ### Added
14
+
15
+ - **core** — `Trace`/`Step` computation-trace model, `ExplainLevel`
16
+ (beginner → intermediate → engineer → researcher), and the `BaseOp` contract.
17
+ - **algebra** — `Vector` (`dot`, `norm`, `cosine_similarity`) and `Matrix`
18
+ (`matmul`, transpose), each producing a step-by-step trace.
19
+ - **probability** — `softmax` with temperature control and the
20
+ numerically-stable max-subtraction trick, explained.
21
+ - **transformers** — single-head scaled dot-product `Attention`,
22
+ `softmax(QKᵀ/√dₖ)·V`, traced across all four stages.
23
+ - **visualization** — Rich terminal renderer with a consistent visual grammar.
24
+ - **cli** — the `optimumai` command: `algebra dot|matmul|cosine`, `softmax`,
25
+ `attention --demo`, and `learn`.
26
+ - Tooling: hatchling build, pytest suite (40 tests, 91% coverage), ruff, a
27
+ GitHub Actions CI matrix (Python 3.10–3.13), and a PyPI trusted-publishing
28
+ workflow.
29
+
30
+ [0.1.0]: https://github.com/muhammadyahiya/optimumai/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Muhammad Yahiya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: optimumai
3
+ Version: 0.1.0
4
+ Summary: Unlock the math behind AI — run any operation with explain=True for a step-by-step trace, terminal visualization, and the intuition of why AI uses it.
5
+ Project-URL: Homepage, https://github.com/muhammadyahiya/optimumai
6
+ Project-URL: Repository, https://github.com/muhammadyahiya/optimumai
7
+ Project-URL: Issues, https://github.com/muhammadyahiya/optimumai/issues
8
+ Author: Muhammad Yahiya
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,attention,deep-learning,education,explainable,machine-learning,mathematics,transformers,tutorial
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Education
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: click>=8.1
26
+ Requires-Dist: numpy>=1.26
27
+ Requires-Dist: pydantic-settings>=2.0
28
+ Requires-Dist: python-dotenv>=1.0
29
+ Requires-Dist: rich>=13.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.5; extra == 'dev'
34
+ Provides-Extra: llm
35
+ Requires-Dist: litellm>=1.0; extra == 'llm'
36
+ Provides-Extra: viz
37
+ Requires-Dist: matplotlib>=3.8; extra == 'viz'
38
+ Requires-Dist: plotext>=5.2; extra == 'viz'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # OptimumAI
42
+
43
+ **Unlock the math behind AI.**
44
+
45
+ Every mathematical operation in modern AI — from a dot product to a full
46
+ attention block — can be run with `explain=True` to produce a **step-by-step
47
+ computation trace**, a **terminal visualization**, and the intuition for **why
48
+ AI actually uses it**.
49
+
50
+ The same code runs fast in production *or* teaches you exactly what it's doing.
51
+ micrograd shows you scalar backprop; EpyNN walks you through MLPs — OptimumAI
52
+ gives you a single, traceable API that runs the whole way from `a · b` up to
53
+ `softmax(QKᵀ/√dₖ)·V`.
54
+
55
+ ```python
56
+ from optimumai import Vector
57
+
58
+ Vector([1, 2, 3]).dot(Vector([4, 5, 6]), explain=True)
59
+ ```
60
+
61
+ ```
62
+ ╭───────────────────────── OptimumAI ──────────────────────────╮
63
+ │ DOT │
64
+ │ a · b = Σᵢ aᵢ·bᵢ │
65
+ ╰───────────────────────────────────────────────────────────────╯
66
+ # Step Computation
67
+ 1 Multiply component 0 1 × 4 = 4
68
+ 2 Multiply component 1 2 × 5 = 10
69
+ 3 Multiply component 2 3 × 6 = 18
70
+ 4 Sum the products 4 + 10 + 18 = 32
71
+ ╭──────── Result · scalar ────────╮
72
+ │ 32 │
73
+ ╰─────────────────────────────────╯
74
+ ╭──────────── Why AI uses this ────────────╮
75
+ │ • Similarity between two embedding vectors │
76
+ │ • The raw attention score q · k │
77
+ │ • The inner loop of every matrix multiply │
78
+ ╰────────────────────────────────────────────╯
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Install
84
+
85
+ ```bash
86
+ pip install optimumai
87
+ ```
88
+
89
+ Optional extras:
90
+
91
+ ```bash
92
+ pip install "optimumai[llm]" # LLM tutor (Q&A over concepts)
93
+ pip install "optimumai[viz]" # extra plotting backends
94
+ ```
95
+
96
+ ## Quickstart — Python
97
+
98
+ ```python
99
+ from optimumai import Vector, Matrix, softmax, Attention
100
+
101
+ # Linear algebra
102
+ Vector([1, 2, 3]).cosine_similarity(Vector([2, 4, 6]), explain=True) # → 1.0
103
+ Matrix([[1, 2], [3, 4]]).matmul(Matrix([[5, 6], [7, 8]]), explain=True)
104
+
105
+ # Probability
106
+ softmax([2.0, 1.0, 0.1], temperature=0.5, explain=True)
107
+
108
+ # Transformers — the headline
109
+ Attention(d_k=4).forward(Q, K, V, explain=True)
110
+ ```
111
+
112
+ Every `explain=True` call returns the numeric result *and* prints the trace, so
113
+ it drops straight into notebooks, scripts, and tests. Prefer the data over the
114
+ print-out? Use the `*_trace` variants:
115
+
116
+ ```python
117
+ trace = Vector([1, 2, 3]).dot_trace(Vector([4, 5, 6]))
118
+ trace.result # 32.0
119
+ trace.steps # [Step(...), Step(...), ...]
120
+ trace.why_ai # ['Similarity between two embedding vectors', ...]
121
+ ```
122
+
123
+ ## Quickstart — CLI
124
+
125
+ ```bash
126
+ optimumai algebra dot "[1,2,3]" "[4,5,6]"
127
+ optimumai algebra matmul "[[1,2],[3,4]]" "[[5,6],[7,8]]"
128
+ optimumai softmax "[2,1,0.1]" --temperature 0.5
129
+ optimumai attention --demo --level engineer
130
+ optimumai learn # list every topic
131
+ optimumai learn attention --level researcher
132
+ ```
133
+
134
+ ## Explain levels
135
+
136
+ The same math, revealed for four audiences (`--level` on the CLI, `level=` in
137
+ Python):
138
+
139
+ | Level | Adds |
140
+ | -------------- | ------------------------------------------------- |
141
+ | `beginner` | The steps and plain-English "why" |
142
+ | `intermediate` | Per-step detail notes (default) |
143
+ | `engineer` | Intermediate values + complexity |
144
+ | `researcher` | Everything |
145
+
146
+ ## What's inside
147
+
148
+ ```
149
+ optimumai/
150
+ ├── core/ # Tracer, Step/Trace model, ExplainLevel, BaseOp
151
+ ├── algebra/ # Vector (dot, norm, cosine), Matrix (matmul)
152
+ ├── probability/ # softmax (with temperature + stability)
153
+ ├── transformers/ # scaled dot-product Attention
154
+ ├── visualization/ # Rich terminal renderer
155
+ └── cli/ # the `optimumai` command
156
+ ```
157
+
158
+ ## Roadmap
159
+
160
+ `v0.1` ships the spine — algebra → probability → attention — plus the tracer,
161
+ CLI, and terminal visualization. Next up:
162
+
163
+ - **Calculus & optimization** — derivatives, gradients, SGD/Adam convergence
164
+ - **Neural networks** — dense layers, activations, full backprop trace
165
+ - **Multi-head attention, positional encoding, a full transformer block**
166
+ - **Embeddings, RAG pipeline traces, diffusion schedules**
167
+ - **LLM tutor** — `Tutor().ask("Why is LayerNorm after attention?")`
168
+ - **Streamlit explorer** for visual, interactive pipelines
169
+
170
+ ## Development
171
+
172
+ ```bash
173
+ git clone https://github.com/muhammadyahiya/optimumai
174
+ cd optimumai
175
+ uv venv && uv pip install -e ".[dev]"
176
+ pytest
177
+ ```
178
+
179
+ ## License
180
+
181
+ MIT © 2026 Muhammad Yahiya
@@ -0,0 +1,141 @@
1
+ # OptimumAI
2
+
3
+ **Unlock the math behind AI.**
4
+
5
+ Every mathematical operation in modern AI — from a dot product to a full
6
+ attention block — can be run with `explain=True` to produce a **step-by-step
7
+ computation trace**, a **terminal visualization**, and the intuition for **why
8
+ AI actually uses it**.
9
+
10
+ The same code runs fast in production *or* teaches you exactly what it's doing.
11
+ micrograd shows you scalar backprop; EpyNN walks you through MLPs — OptimumAI
12
+ gives you a single, traceable API that runs the whole way from `a · b` up to
13
+ `softmax(QKᵀ/√dₖ)·V`.
14
+
15
+ ```python
16
+ from optimumai import Vector
17
+
18
+ Vector([1, 2, 3]).dot(Vector([4, 5, 6]), explain=True)
19
+ ```
20
+
21
+ ```
22
+ ╭───────────────────────── OptimumAI ──────────────────────────╮
23
+ │ DOT │
24
+ │ a · b = Σᵢ aᵢ·bᵢ │
25
+ ╰───────────────────────────────────────────────────────────────╯
26
+ # Step Computation
27
+ 1 Multiply component 0 1 × 4 = 4
28
+ 2 Multiply component 1 2 × 5 = 10
29
+ 3 Multiply component 2 3 × 6 = 18
30
+ 4 Sum the products 4 + 10 + 18 = 32
31
+ ╭──────── Result · scalar ────────╮
32
+ │ 32 │
33
+ ╰─────────────────────────────────╯
34
+ ╭──────────── Why AI uses this ────────────╮
35
+ │ • Similarity between two embedding vectors │
36
+ │ • The raw attention score q · k │
37
+ │ • The inner loop of every matrix multiply │
38
+ ╰────────────────────────────────────────────╯
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pip install optimumai
47
+ ```
48
+
49
+ Optional extras:
50
+
51
+ ```bash
52
+ pip install "optimumai[llm]" # LLM tutor (Q&A over concepts)
53
+ pip install "optimumai[viz]" # extra plotting backends
54
+ ```
55
+
56
+ ## Quickstart — Python
57
+
58
+ ```python
59
+ from optimumai import Vector, Matrix, softmax, Attention
60
+
61
+ # Linear algebra
62
+ Vector([1, 2, 3]).cosine_similarity(Vector([2, 4, 6]), explain=True) # → 1.0
63
+ Matrix([[1, 2], [3, 4]]).matmul(Matrix([[5, 6], [7, 8]]), explain=True)
64
+
65
+ # Probability
66
+ softmax([2.0, 1.0, 0.1], temperature=0.5, explain=True)
67
+
68
+ # Transformers — the headline
69
+ Attention(d_k=4).forward(Q, K, V, explain=True)
70
+ ```
71
+
72
+ Every `explain=True` call returns the numeric result *and* prints the trace, so
73
+ it drops straight into notebooks, scripts, and tests. Prefer the data over the
74
+ print-out? Use the `*_trace` variants:
75
+
76
+ ```python
77
+ trace = Vector([1, 2, 3]).dot_trace(Vector([4, 5, 6]))
78
+ trace.result # 32.0
79
+ trace.steps # [Step(...), Step(...), ...]
80
+ trace.why_ai # ['Similarity between two embedding vectors', ...]
81
+ ```
82
+
83
+ ## Quickstart — CLI
84
+
85
+ ```bash
86
+ optimumai algebra dot "[1,2,3]" "[4,5,6]"
87
+ optimumai algebra matmul "[[1,2],[3,4]]" "[[5,6],[7,8]]"
88
+ optimumai softmax "[2,1,0.1]" --temperature 0.5
89
+ optimumai attention --demo --level engineer
90
+ optimumai learn # list every topic
91
+ optimumai learn attention --level researcher
92
+ ```
93
+
94
+ ## Explain levels
95
+
96
+ The same math, revealed for four audiences (`--level` on the CLI, `level=` in
97
+ Python):
98
+
99
+ | Level | Adds |
100
+ | -------------- | ------------------------------------------------- |
101
+ | `beginner` | The steps and plain-English "why" |
102
+ | `intermediate` | Per-step detail notes (default) |
103
+ | `engineer` | Intermediate values + complexity |
104
+ | `researcher` | Everything |
105
+
106
+ ## What's inside
107
+
108
+ ```
109
+ optimumai/
110
+ ├── core/ # Tracer, Step/Trace model, ExplainLevel, BaseOp
111
+ ├── algebra/ # Vector (dot, norm, cosine), Matrix (matmul)
112
+ ├── probability/ # softmax (with temperature + stability)
113
+ ├── transformers/ # scaled dot-product Attention
114
+ ├── visualization/ # Rich terminal renderer
115
+ └── cli/ # the `optimumai` command
116
+ ```
117
+
118
+ ## Roadmap
119
+
120
+ `v0.1` ships the spine — algebra → probability → attention — plus the tracer,
121
+ CLI, and terminal visualization. Next up:
122
+
123
+ - **Calculus & optimization** — derivatives, gradients, SGD/Adam convergence
124
+ - **Neural networks** — dense layers, activations, full backprop trace
125
+ - **Multi-head attention, positional encoding, a full transformer block**
126
+ - **Embeddings, RAG pipeline traces, diffusion schedules**
127
+ - **LLM tutor** — `Tutor().ask("Why is LayerNorm after attention?")`
128
+ - **Streamlit explorer** for visual, interactive pipelines
129
+
130
+ ## Development
131
+
132
+ ```bash
133
+ git clone https://github.com/muhammadyahiya/optimumai
134
+ cd optimumai
135
+ uv venv && uv pip install -e ".[dev]"
136
+ pytest
137
+ ```
138
+
139
+ ## License
140
+
141
+ MIT © 2026 Muhammad Yahiya
@@ -0,0 +1,31 @@
1
+ """OptimumAI quickstart — the full arc, from a dot product to attention.
2
+
3
+ Run me: python examples/quickstart.py
4
+ """
5
+
6
+ import numpy as np
7
+
8
+ from optimumai import Attention, Matrix, Vector, softmax
9
+
10
+
11
+ def main() -> None:
12
+ print("\n### 1. Dot product — similarity & the atom of matmul ###")
13
+ Vector([1, 2, 3]).dot(Vector([4, 5, 6]), explain=True)
14
+
15
+ print("\n### 2. Cosine similarity — the RAG ranking score ###")
16
+ Vector([1, 2, 3]).cosine_similarity(Vector([2, 4, 6]), explain=True)
17
+
18
+ print("\n### 3. Matrix multiply — every dense layer, cell by cell ###")
19
+ Matrix([[1, 2], [3, 4]]).matmul(Matrix([[5, 6], [7, 8]]), explain=True)
20
+
21
+ print("\n### 4. Softmax — logits into a probability distribution ###")
22
+ softmax([2.0, 1.0, 0.1], temperature=0.5, explain=True)
23
+
24
+ print("\n### 5. Attention — softmax(QKᵀ/√dₖ)·V, the transformer core ###")
25
+ rng = np.random.default_rng(0)
26
+ Q, K, V = (rng.normal(size=(3, 4)).round(2) for _ in range(3))
27
+ Attention(d_k=4).forward(Q, K, V, explain=True, level="engineer")
28
+
29
+
30
+ if __name__ == "__main__":
31
+ main()
@@ -0,0 +1,76 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "optimumai"
7
+ dynamic = ["version"]
8
+ description = "Unlock the math behind AI — run any operation with explain=True for a step-by-step trace, terminal visualization, and the intuition of why AI uses it."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Muhammad Yahiya" }]
13
+ keywords = [
14
+ "ai",
15
+ "machine-learning",
16
+ "deep-learning",
17
+ "education",
18
+ "mathematics",
19
+ "transformers",
20
+ "attention",
21
+ "explainable",
22
+ "tutorial",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 4 - Beta",
26
+ "Intended Audience :: Education",
27
+ "Intended Audience :: Developers",
28
+ "Intended Audience :: Science/Research",
29
+ "License :: OSI Approved :: MIT License",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.10",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Programming Language :: Python :: 3.13",
35
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
36
+ "Topic :: Education",
37
+ ]
38
+ dependencies = [
39
+ "numpy>=1.26",
40
+ "rich>=13.0",
41
+ "click>=8.1",
42
+ "pydantic-settings>=2.0",
43
+ "python-dotenv>=1.0",
44
+ ]
45
+
46
+ [project.optional-dependencies]
47
+ llm = ["litellm>=1.0"]
48
+ viz = ["plotext>=5.2", "matplotlib>=3.8"]
49
+ dev = ["pytest>=8.0", "pytest-cov>=5.0", "ruff>=0.5"]
50
+
51
+ [project.scripts]
52
+ optimumai = "optimumai.cli.main:cli"
53
+
54
+ [project.urls]
55
+ Homepage = "https://github.com/muhammadyahiya/optimumai"
56
+ Repository = "https://github.com/muhammadyahiya/optimumai"
57
+ Issues = "https://github.com/muhammadyahiya/optimumai/issues"
58
+
59
+ [tool.hatch.version]
60
+ path = "src/optimumai/__init__.py"
61
+
62
+ [tool.hatch.build.targets.wheel]
63
+ packages = ["src/optimumai"]
64
+
65
+ [tool.pytest.ini_options]
66
+ testpaths = ["tests"]
67
+ addopts = "-q"
68
+
69
+ [tool.ruff]
70
+ line-length = 100
71
+ target-version = "py310"
72
+
73
+ [tool.ruff.lint]
74
+ select = ["E", "F", "I", "N", "UP", "B"]
75
+ # Uppercase names (Q, K, V, A, B, W, ...) are standard mathematical notation here.
76
+ ignore = ["N803", "N806"]
@@ -0,0 +1,31 @@
1
+ """OptimumAI — unlock the math behind AI.
2
+
3
+ Every operation, from a dot product to a full attention block, can be run with
4
+ ``explain=True`` to produce a step-by-step computation trace, a terminal
5
+ visualization, and the context for *why* AI uses it.
6
+
7
+ >>> from optimumai import Vector
8
+ >>> Vector([1, 2, 3]).dot(Vector([4, 5, 6]), explain=True)
9
+ 32.0
10
+ """
11
+
12
+ from optimumai.algebra.matrix import Matrix
13
+ from optimumai.algebra.vector import Vector
14
+ from optimumai.core.explain import ExplainLevel
15
+ from optimumai.core.trace import Step, Trace
16
+ from optimumai.probability.softmax import softmax, softmax_trace
17
+ from optimumai.transformers.attention import Attention
18
+
19
+ __version__ = "0.1.0"
20
+
21
+ __all__ = [
22
+ "Attention",
23
+ "ExplainLevel",
24
+ "Matrix",
25
+ "Step",
26
+ "Trace",
27
+ "Vector",
28
+ "softmax",
29
+ "softmax_trace",
30
+ "__version__",
31
+ ]
@@ -0,0 +1,6 @@
1
+ """Linear algebra with step-by-step explanations."""
2
+
3
+ from optimumai.algebra.matrix import Matrix
4
+ from optimumai.algebra.vector import Vector
5
+
6
+ __all__ = ["Matrix", "Vector"]