thefinalboss commited on
Commit
6be150b
·
verified ·
1 Parent(s): ec5053e

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +53 -47
README.md CHANGED
@@ -1,75 +1,81 @@
1
  ---
2
- license: mit
3
  language:
4
  - en
5
  - fr
6
- - code
 
7
  tags:
8
- - non-transformer
9
- - cognitive-routing
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
- **A 1.02B parameter non-transformer language model with O(n) cognitive routing and hierarchical memory.**
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
- | Component | Detail |
29
- |-----------|--------|
30
- | **Architecture** | Non-transformer (Cognitive Routing) |
31
- | **Parameters** | ~1,020,000,000 (~1B) |
32
- | **Hidden Dim** | 2048 |
33
- | **Blocks** | 16 cognitive blocks |
34
- | **Channels** | 8 routing channels x 384 dim |
35
- | **FF Dim** | 8192 |
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
- ### Cognitive Routing
46
 
47
- Unlike self-attention (O(n2)), CogNet uses multi-channel routing for O(n) linear scaling.
 
 
48
 
49
  ## Files
50
 
51
  | File | Description |
52
  |------|-------------|
53
- | `cognet_1b.py` | 1B model architecture |
54
- | `infer.py` | Inference engine |
 
 
 
55
  | `chat_infer.py` | Chat-style inference |
56
- | `train_1b_final.py` | Training script (RTX 5090 32GB) |
57
- | `train_pipeline.py` | Training pipeline |
58
- | `train_bg.py` | Background training |
59
- | `gen_data_1b.py` | Training data generation |
60
- | `cognet_data_prep.py` | Data preparation pipeline |
61
- | `tokenizer_v3.json` | Character-level tokenizer |
62
- | `checkpoints/` | Model checkpoints (40M base) |
63
 
64
- ## Quick Start
65
 
66
- ```python
67
- from infer import CogNetInference
 
 
 
 
68
 
69
- ai = CogNetInference("checkpoints/cognet_best.pt", "tokenizer_v3.json")
70
- print(ai.generate("Once upon a time"))
71
  ```
72
 
73
- ## License
 
 
 
 
74
 
75
- MIT License
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ```