docs(ai): Comprehensive AI Developer Handbook & Submodule Guides — Training from Scratch in Pure .aira

This commit is contained in:
Adam Eehan committed 2026-11-12 23:51:15 +05:30
1 parent 44ad01a87d
commit a690296e7c
10 files changed
+431 -15

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
# 🎯 AIRA Attention Mechanisms (`ai/attention`)
[![Language: Aira](https://img.shields.io/badge/Language-Aira%20100%25-ff007f.svg)](https://github.com/adameehanairagroup/Airalang)
[![Domain: ai/attention](https://img.shields.io/badge/Domain-Multi--Head%20Attention-00e5ff.svg)](https://github.com/adameehanairagroup/Airalang)
[![Architect: Er. Adam Eehan](https://img.shields.io/badge/Architect-Er.%20Adam%20Eehan-gold.svg)](https://github.com/adameehanairagroup)
The `ai/attention` package provides native implementations of modern self-attention and cross-attention architectures.
---
## 🧮 Mathematical Formulation
### Scaled Dot-Product Attention
$$ ext{Attention}(Q, K, V) = ext{softmax}\left( rac{Q K^T}{\sqrt{d_k}}␍ight) V$$
In pure `.aira`:
```aira
import "ai/attention";
// Instantiate MultiHeadAttention with 8 heads across 512 dimensions
let mha = new MultiHeadAttention(512, 8);
// Forward pass: Query, Key, Value, and Causal Attention Mask
let context_vectors = mha.forward(Q, K, V, causal_mask);
```
### Rotary Positional Embeddings (RoPE)
Enables transformers to dynamically encode relative token positions without hard positional tables:
```aira
let rope = new RotaryEmbedding(dim_per_head=64, max_seq_len=4096);
let q_rotated = rope.apply(Q, position_ids);
let k_rotated = rope.apply(K, position_ids);
```