Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,75 +1,81 @@
|
|
| 1 |
---
|
| 2 |
-
license: mit
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
- fr
|
| 6 |
-
|
|
|
|
| 7 |
tags:
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
- hierarchical-memory
|
| 11 |
-
- character-level
|
| 12 |
- aicl
|
| 13 |
-
- text-generation
|
| 14 |
- custom-architecture
|
| 15 |
-
- 1b
|
| 16 |
-
pipeline_tag: text-generation
|
| 17 |
-
library_name: pytorch
|
| 18 |
---
|
| 19 |
|
| 20 |
# CogNet-1B
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
CogNet-1B is the scaled-up version of the CogNet architecture — a novel non-transformer design that replaces self-attention with **cognitive routing** for O(n) complexity.
|
| 25 |
|
| 26 |
## Architecture
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
| **Max Seq Len** | 256 |
|
| 37 |
-
| **Tokenizer** | Character-level (136 vocab) |
|
| 38 |
-
|
| 39 |
-
### Hierarchical Memory System
|
| 40 |
-
|
| 41 |
-
- **Working Memory** (128 slots): Active processing
|
| 42 |
-
- **Episodic Memory** (256 slots): Short-term recall
|
| 43 |
-
- **Semantic Memory** (512 slots): Long-term knowledge
|
| 44 |
|
| 45 |
-
##
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
## Files
|
| 50 |
|
| 51 |
| File | Description |
|
| 52 |
|------|-------------|
|
| 53 |
-
| `
|
| 54 |
-
| `
|
|
|
|
|
|
|
|
|
|
| 55 |
| `chat_infer.py` | Chat-style inference |
|
| 56 |
-
| `
|
| 57 |
-
| `
|
| 58 |
-
| `
|
| 59 |
-
| `
|
| 60 |
-
| `cognet_data_prep.py` | Data preparation pipeline |
|
| 61 |
-
| `tokenizer_v3.json` | Character-level tokenizer |
|
| 62 |
-
| `checkpoints/` | Model checkpoints (40M base) |
|
| 63 |
|
| 64 |
-
##
|
| 65 |
|
| 66 |
-
```
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
```
|
| 72 |
|
| 73 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
- fr
|
| 5 |
+
license: mit
|
| 6 |
+
library_name: pytorch
|
| 7 |
tags:
|
| 8 |
+
- cognet
|
| 9 |
+
- language-model
|
|
|
|
|
|
|
| 10 |
- aicl
|
|
|
|
| 11 |
- custom-architecture
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
# CogNet-1B
|
| 15 |
|
| 16 |
+
A ~1.06B parameter language model with a novel cognitive architecture featuring working, episodic, and semantic memory systems.
|
|
|
|
|
|
|
| 17 |
|
| 18 |
## Architecture
|
| 19 |
|
| 20 |
+
- **Hidden dim**: 2048
|
| 21 |
+
- **Blocks**: 16 (8 channels each)
|
| 22 |
+
- **Channel dim**: 384
|
| 23 |
+
- **FF dim**: 8192
|
| 24 |
+
- **Working slots**: 128
|
| 25 |
+
- **Episodic slots**: 256
|
| 26 |
+
- **Semantic slots**: 512
|
| 27 |
+
- **Tokenizer**: CharTokenizer (136 vocab)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
## Training Data
|
| 30 |
|
| 31 |
+
- **HuggingFace datasets**: wikitext-103, codeparrot-clean, fineweb, oscar-fr, the-stack-smol, alpaca-cleaned, c4-en
|
| 32 |
+
- **AICL** (github.com/AFKmoney/AICL): JSONL datasets, 85 .aicl examples, source code, spec, tests (10x repeated)
|
| 33 |
+
- **Synthetic data**: Code + English + French supplementary data
|
| 34 |
|
| 35 |
## Files
|
| 36 |
|
| 37 |
| File | Description |
|
| 38 |
|------|-------------|
|
| 39 |
+
| `runpod_train_1b.py` | **Main training script** (all-in-one: data prep + training + HF push) |
|
| 40 |
+
| `cognet_1b.py` | Model architecture definition |
|
| 41 |
+
| `cognet_data_prep.py` | Standalone data preparation script |
|
| 42 |
+
| `train_1b_final.py` | Previous training script |
|
| 43 |
+
| `infer.py` | Inference script |
|
| 44 |
| `chat_infer.py` | Chat-style inference |
|
| 45 |
+
| `gen_data_1b.py` | Synthetic data generation |
|
| 46 |
+
| `config.json` | Model config |
|
| 47 |
+
| `tokenizer_v3.json` | CharTokenizer vocabulary |
|
| 48 |
+
| `data/aicl/` | AICL datasets and examples |
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
## Training on RunPod
|
| 51 |
|
| 52 |
+
```bash
|
| 53 |
+
# 1. Set your HF token
|
| 54 |
+
export HF_TOKEN=your_token_here
|
| 55 |
+
|
| 56 |
+
# 2. Run (batch=4, grad-accum=8 = effective batch 32)
|
| 57 |
+
python3 runpod_train_1b.py --max-steps 100000
|
| 58 |
|
| 59 |
+
# 3. Or with custom settings
|
| 60 |
+
python3 runpod_train_1b.py --batch-size 4 --grad-accum 8 --max-steps 200000 --seq-len 512
|
| 61 |
```
|
| 62 |
|
| 63 |
+
## Inference
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
from cognet_1b import CogNet1B, CharTokenizer
|
| 67 |
+
import torch
|
| 68 |
|
| 69 |
+
tokenizer = CharTokenizer.load('tokenizer_v3.json')
|
| 70 |
+
model = CogNet1B(vocab_size=136, hidden_dim=2048, n_blocks=16, n_channels=8,
|
| 71 |
+
channel_dim=384, ff_dim=8192, working_slots=128,
|
| 72 |
+
episodic_slots=256, semantic_slots=512, seq_len=512)
|
| 73 |
+
|
| 74 |
+
ckpt = torch.load('checkpoints/cognet_1b_best.pt', map_location='cpu')
|
| 75 |
+
model.load_state_dict(ckpt['model_state_dict'])
|
| 76 |
+
model.eval()
|
| 77 |
+
|
| 78 |
+
prompt = torch.tensor([[tokenizer.bos_token_id]])
|
| 79 |
+
output = model.generate(prompt, max_new_tokens=200, temperature=0.8, top_k=50)
|
| 80 |
+
print(tokenizer.decode(output[0].tolist()))
|
| 81 |
+
```
|