Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: it
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
library_name: peft
|
| 5 |
+
base_model: Qwen/Qwen2.5-1.5B
|
| 6 |
+
tags:
|
| 7 |
+
- lora
|
| 8 |
+
- cognitive-architecture
|
| 9 |
+
- progressive-learning
|
| 10 |
+
- dream-pruning
|
| 11 |
+
- svd
|
| 12 |
+
- math
|
| 13 |
+
- arithmetic
|
| 14 |
+
- intuition
|
| 15 |
+
- tool-use
|
| 16 |
+
datasets:
|
| 17 |
+
- custom
|
| 18 |
+
pipeline_tag: text-generation
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# Progressive Cognitive Architecture β Dream-LoRA (Qwen 2.5 1.5B)
|
| 22 |
+
|
| 23 |
+
**The model that develops mathematical intuition through a 4-phase cognitive curriculum + SVD Dream Pruning.**
|
| 24 |
+
|
| 25 |
+
## π§ What is this?
|
| 26 |
+
|
| 27 |
+
This is a LoRA adapter trained with the **Progressive Cognitive Architecture**, a bio-inspired training methodology that teaches LLMs to develop mathematical intuition rather than memorize answers. The training follows 4 cognitive phases:
|
| 28 |
+
|
| 29 |
+
1. **Foundations** β Learn exact arithmetic (2,000 examples)
|
| 30 |
+
2. **Consolidation** β SVD Dream Pruning compresses exact circuits into intuition (rank 16β8), then fine-tune on approximation (1,500 examples)
|
| 31 |
+
3. **Delegation** β Learn when to delegate to a calculator tool vs compute internally (1,500 examples)
|
| 32 |
+
4. **Orchestration** β Full pipeline: intuition β routing β tool β validation (1,000 examples)
|
| 33 |
+
|
| 34 |
+
## π¬ Dream Pruning (SVD Low-Rank Factorization)
|
| 35 |
+
|
| 36 |
+
Instead of zeroing out small weights (magnitude pruning), Dream Pruning uses **SVD decomposition** to reduce the effective rank of LoRA matrices from 16 to 8, preserving the principal directions (the "logical connections") while discarding noise. Think of it as the model "sleeping" and consolidating its memories.
|
| 37 |
+
|
| 38 |
+
## π Results (Ablation Study: 100 tests Γ 3 seeds)
|
| 39 |
+
|
| 40 |
+
| Metric | Dream-LoRA | Flat-LoRA | Base |
|
| 41 |
+
|--------|-----------|-----------|------|
|
| 42 |
+
| Exact Accuracy | 58.6% Β± 2.9 | 60.6% Β± 3.8 | 18.2% Β± 2.9 |
|
| 43 |
+
| Number Sense | 60.0% Β± 0.8 | 0.0% | 57.0% Β± 1.4 |
|
| 44 |
+
| Metacognition (delegation) | **100.0%** | 0.0% | 84.9% |
|
| 45 |
+
| Sensible Errors | 81.3% | β | β |
|
| 46 |
+
|
| 47 |
+
**Key insight**: Flat-LoRA wins on raw accuracy but *destroys* number sense and metacognition. Dream-LoRA preserves both while achieving comparable accuracy.
|
| 48 |
+
|
| 49 |
+
## π Quick Start
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 53 |
+
from peft import PeftModel
|
| 54 |
+
|
| 55 |
+
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B", device_map="auto")
|
| 56 |
+
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-1.5B")
|
| 57 |
+
|
| 58 |
+
# Load LoRA adapter (note: adapters are in lora_adapters/ subfolder)
|
| 59 |
+
model = PeftModel.from_pretrained(base_model, "dexmac/progressive-cognitive-dream-lora", subfolder="lora_adapters")
|
| 60 |
+
|
| 61 |
+
# Test it
|
| 62 |
+
inputs = tokenizer("Calcola: 347 + 891 =", return_tensors="pt").to(model.device)
|
| 63 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
| 64 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
## βοΈ Training Details
|
| 68 |
+
|
| 69 |
+
- **Base model**: Qwen/Qwen2.5-1.5B (1.5B parameters, frozen)
|
| 70 |
+
- **LoRA config**: rank=16, alpha=32, dropout=0.05, targets=q_proj, k_proj, v_proj, o_proj
|
| 71 |
+
- **Dream Pruning**: SVD rank reduction 16β8 via QR+SVD decomposition
|
| 72 |
+
- **Training data**: 6,000 synthetic math examples (Italian prompts)
|
| 73 |
+
- **Hardware**: NVIDIA T4 (16GB VRAM) on Hugging Face Spaces
|
| 74 |
+
- **Training time**: ~45 minutes
|
| 75 |
+
|
| 76 |
+
## π Paper & Code
|
| 77 |
+
|
| 78 |
+
- **Article**: [Published on Towards AI](https://pub.towardsai.net/)
|
| 79 |
+
- **GitHub**: [dexmac221/progressive-cognitive](https://github.com/dexmac221/progressive-cognitive)
|
| 80 |
+
|
| 81 |
+
## π License
|
| 82 |
+
|
| 83 |
+
Apache 2.0
|