docs(ai): Comprehensive AI Developer Handbook & Submodule Guides — Training from Scratch in Pure .aira
This commit is contained in:
1 parent
44ad01a87d
commit
a690296e7c
10 files changed
+431
-15
No files matched your search
@@ -0,0 +1,29 @@
|
||||
# 📉 AIRA Loss Functions (`ai/loss`)
|
||||
|
||||
[](https://github.com/adameehanairagroup/Airalang)
|
||||
[](https://github.com/adameehanairagroup/Airalang)
|
||||
|
||||
Loss functions calculate the scalar discrepancy between model predictions and ground-truth targets, guiding gradient backpropagation.
|
||||
|
||||
---
|
||||
|
||||
## 📐 Implemented Loss Functions
|
||||
|
||||
### 1. `CrossEntropyLoss` (Classification & Next-Token LLM Training)
|
||||
$$\mathcal{L} = -\sum_{i} y_i \log(\hat{y}_i)$$
|
||||
Utilizes numerically stable Log-Softmax with max-subtraction to prevent floating-point underflow:
|
||||
|
||||
```aira
|
||||
import "ai/loss";
|
||||
|
||||
let criterion = new CrossEntropyLoss();
|
||||
let loss = criterion.forward(logits, target_class);
|
||||
loss.backward(); // Propagates dL/dLogits back into model layers
|
||||
```
|
||||
|
||||
### 2. `MSELoss` (Mean Squared Error)
|
||||
$$\mathcal{L} = rac{1}{N} \sum_{i=1}^N (y_i - \hat{y}_i)^2$$
|
||||
Ideal for continuous regression, coordinate prediction, and Diffusion noise estimation.
|
||||
|
||||
### 3. `BCEWithLogitsLoss`
|
||||
Binary cross-entropy combining a sigmoid activation and cross-entropy for numerical stability in multi-label classification.
|
||||
Reference in new issue
Block a user