LoganResearch commited on
Commit
2f40d7e
Β·
verified Β·
1 Parent(s): d6131a4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +674 -69
README.md CHANGED
@@ -6,115 +6,720 @@ library_name: transformers
6
  pipeline_tag: text-generation
7
  tags:
8
  - llama
9
- - dense
10
- - self-improvement
11
- - cf-hot
12
  - representation-engineering
 
 
13
  base_model: NousResearch/Hermes-3-Llama-3.1-8B
14
- model-index:
15
- - name: ARC-Base-8B-Condensed
16
- results:
17
- - task:
18
- type: text-generation
19
- metrics:
20
- - name: Information Density
21
- type: custom
22
- value: 28.5
23
- - name: Token Reduction
24
- type: custom
25
- value: 57%
26
  ---
27
 
28
- # ARC-Base-8B-Condensed
29
 
30
- An 8B language model optimized for **information density** and **stable self-improvement**.
31
 
32
- ## Features
33
 
34
- - **CF-HoT 125Γ—**: Repetition detection with 125Γ— class separation
35
- - **Dense Responses**: 70% improvement in information density
36
- - **Stable RSI**: Recursive self-improvement with automatic rollback
37
- - **Full Agentic Stack**: Browser, email, code execution
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  ## Quick Start
40
 
41
  ```bash
 
42
  git clone https://huggingface.co/LoganResearch/ARC-Base-8B-Condensed
43
  cd ARC-Base-8B-Condensed
44
- pip install -r requirements.txt
 
 
 
 
45
  python arc_engine_v21_multimedia.py
46
  ```
47
 
48
- **Requires Python 3.11** (3.13 has diffusers compatibility issues)
49
-
50
- ## Usage
 
 
51
 
52
- ```python
53
- from transformers import AutoModelForCausalLM, AutoTokenizer
 
 
 
 
 
 
 
 
 
54
 
55
- model = AutoModelForCausalLM.from_pretrained(
56
- "LoganResearch/ARC-Base-8B-Condensed",
57
- torch_dtype=torch.bfloat16,
58
- device_map="auto"
59
- )
60
- tokenizer = AutoTokenizer.from_pretrained("LoganResearch/ARC-Base-8B-Condensed")
61
 
62
- prompt = "<|im_start|>user\nWhat is recursion?<|im_end|>\n<|im_start|>assistant\n"
63
- output = model.generate(tokenizer(prompt, return_tensors="pt").input_ids.cuda(), max_new_tokens=100)
64
- print(tokenizer.decode(output[0]))
65
- # Output: "Function calls itself until base case. Stack frames accumulate, unwind."
66
  ```
67
 
68
- ## Key Commands
 
 
 
 
69
 
70
  | Command | Description |
71
  |---------|-------------|
72
- | `!improve` | Run self-improvement loop |
73
- | `!eval` | Evaluate model quality |
74
- | `!cfhot` | Toggle 125Γ— repetition head |
75
- | `!rsi15` | 15-iteration stress test |
76
- | `!book` | Extended generation mode |
77
- | `!stream` | Live token visualization |
78
 
79
- ## Metrics
80
 
81
- | Metric | Base | ARC | Change |
82
- |--------|------|-----|--------|
83
- | Information Density | 17.0 | 28.5 | +67% |
84
- | Avg Tokens | 150 | 65 | -57% |
85
- | CF-HoT Separation | - | 125Γ— | - |
 
86
 
87
- ## Architecture
88
 
89
- Built on [Hermes-3-Llama-3.1-8B](https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B) with:
 
 
 
 
 
90
 
91
- 1. **CF-HoT Heads**: Multi-head predictors on hidden states for behavior control
92
- 2. **CONDENSATOR Training**: SFT β†’ DPO β†’ RL pipeline for density
93
- 3. **RSI Loop**: Evaluate β†’ Train β†’ Compare β†’ Keep/Rollback
 
94
 
95
- ## Requirements
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  ```
98
- torch>=2.0
99
- transformers>=4.40.0
100
- accelerate
101
- peft
102
- bitsandbytes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  ```
104
 
105
- See `requirements.txt` for full list.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  ## Citation
108
 
109
  ```bibtex
110
- @software{arc_engine_2025,
111
- title = {ARC-Base-8B-Condensed: Dense Self-Improving Language Model},
112
- author = {Napolitano, Logan Matthew},
113
- year = {2025},
114
- url = {https://huggingface.co/LoganResearch/ARC-Base-8B-Condensed}
 
115
  }
116
  ```
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  ## License
119
 
120
- CC BY 4.0
 
 
 
 
 
 
 
 
 
 
 
 
6
  pipeline_tag: text-generation
7
  tags:
8
  - llama
9
+ - dense-responses
10
+ - self-optimization
 
11
  - representation-engineering
12
+ - cf-hot
13
+ - recursive-self-improvement
14
  base_model: NousResearch/Hermes-3-Llama-3.1-8B
 
 
 
 
 
 
 
 
 
 
 
 
15
  ---
16
 
17
+ ![ARC Banner](banner.svg)
18
 
19
+ # ARC Engine v2.1: Adaptive Recursive Cognition
20
 
21
+ A comprehensive framework for stable recursive self-improvement of language models, featuring real-time behavioral control through hidden-state monitoring and multi-modal output capabilities.
22
 
23
+ **Author:** Logan Matthew Napolitano
24
+ **Base Model:** NousResearch/Hermes-3-Llama-3.1-8B
25
+ **License:** CC BY 4.0
26
+ **Engine:** 6,861 lines | **Weights:** ~16 GB
27
+
28
+ ---
29
+
30
+ ## Table of Contents
31
+
32
+ 1. [Quick Start](#quick-start)
33
+ 2. [What's New in v2.1](#whats-new-in-v21)
34
+ 3. [Core Technology](#core-technology)
35
+ 4. [Empirical Results](#empirical-results)
36
+ 5. [Command Reference](#command-reference)
37
+ 6. [Installation](#installation)
38
+ 7. [Configuration](#configuration)
39
+ 8. [Repository Structure](#repository-structure)
40
+ 9. [Hardware Requirements](#hardware-requirements)
41
+ 10. [Training From Scratch](#training-from-scratch)
42
+ 11. [API Reference](#api-reference)
43
+ 12. [Limitations](#limitations)
44
+ 13. [Citation](#citation)
45
+
46
+ ---
47
 
48
  ## Quick Start
49
 
50
  ```bash
51
+ # Clone repository
52
  git clone https://huggingface.co/LoganResearch/ARC-Base-8B-Condensed
53
  cd ARC-Base-8B-Condensed
54
+
55
+ # Install dependencies (minimal)
56
+ pip install torch transformers peft bitsandbytes accelerate
57
+
58
+ # Run the engine
59
  python arc_engine_v21_multimedia.py
60
  ```
61
 
62
+ On first run, the engine will:
63
+ 1. Load the base model and DENSE adapter
64
+ 2. Initialize the CF-HoT 125Γ— repetition detection head
65
+ 3. Set up the quality evaluation system
66
+ 4. Present an interactive command prompt
67
 
68
+ ```
69
+ ===========================================================================
70
+ πŸ€– ARC ENGINE v2.1 - Adaptive Recursive Cognition
71
+ ===========================================================================
72
+ DENSE Mode: ON (CONDENSATOR checkpoint)
73
+ CF-HoT Control: ON
74
+ CF-HoT 125Γ—: ON
75
+ Stream Window: ON
76
+ Image Gen: ON
77
+ TTS Audio: ON
78
+ ===========================================================================
79
 
80
+ > hello
81
+ Hello. How can I help?
 
 
 
 
82
 
83
+ [Quality: 0.82 | Density: 12.4 | Coherence: 0.91 | Tokens: 5]
 
 
 
84
  ```
85
 
86
+ ---
87
+
88
+ ## What's New in v2.1
89
+
90
+ ### Multimedia Features
91
 
92
  | Command | Description |
93
  |---------|-------------|
94
+ | `!stream` | Opens a live GUI window displaying tokens as they generate in real-time |
95
+ | `!imagine <prompt>` | Generate images using Stable Diffusion XL |
96
+ | `!dalle <prompt>` | Generate images using DALL-E 3 API |
97
+ | `!audio` | Toggle text-to-speech output |
98
+ | `!say <text>` | Speak text immediately using TTS |
 
99
 
100
+ ### Claude Integration
101
 
102
+ | Command | Description |
103
+ |---------|-------------|
104
+ | `!idea <request>` | Generate extensive ideas using Claude API |
105
+ | `!idea <request> --deep` | Generate 30 detailed ideas with implementation plans |
106
+ | `!claude <prompt>` | Direct prompting to Claude Opus 4.5 |
107
+ | `!expand <idea>` | Expand a specific idea into a comprehensive plan |
108
 
109
+ ### Extended Generation
110
 
111
+ | Command | Description |
112
+ |---------|-------------|
113
+ | `!book` | Toggle book mode (16,384 token limit) |
114
+ | `!write <topic>` | Generate complete books with chapters |
115
+
116
+ ### Advanced RSI Testing
117
 
118
+ | Command | Description |
119
+ |---------|-------------|
120
+ | `!rsi15` | Run 15-iteration stress test with full logging |
121
+ | `!cfhot` / `!125x` | Toggle CF-HoT 125Γ— head on/off at runtime |
122
 
123
+ ### Utilities
124
+
125
+ | Command | Description |
126
+ |---------|-------------|
127
+ | `!plot` | Generate quality history visualization |
128
+ | `!benchmark` | Run comprehensive evaluation suite |
129
+ | `!export [name]` | Package checkpoint for sharing |
130
+ | `!import <path>` | Import checkpoint package |
131
+ | `!learn` | Extract high-quality responses for training |
132
+ | `!api` | Start REST API server on port 8080 |
133
+
134
+ ---
135
+
136
+ ## Core Technology
137
+
138
+ ### 1. CF-HoT: Contrastive Fine-tuning with Hidden-state Oversight Training
139
+
140
+ CF-HoT enables real-time behavioral control by monitoring the model's internal representations and intervening before problematic tokens are generated.
141
+
142
+ **Key Innovation:** The repetition detection head achieves 125Γ— class separation, meaning it can reliably distinguish "about to repeat" states from normal generation states in the model's hidden layers.
143
+
144
+ ```
145
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
146
+ β”‚ CF-HoT Architecture β”‚
147
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
148
+ β”‚ β”‚
149
+ β”‚ Hidden States (Layer 16-24) β”‚
150
+ β”‚ β”‚ β”‚
151
+ β”‚ β–Ό β”‚
152
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
153
+ β”‚ β”‚ Fiber β”‚ Compress to d=16 per layer β”‚
154
+ β”‚ β”‚ Projection β”‚ β”‚
155
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
156
+ β”‚ β”‚ β”‚
157
+ β”‚ β–Ό β”‚
158
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
159
+ β”‚ β”‚ Layer β”‚ Weighted aggregation β”‚
160
+ β”‚ β”‚ Attention β”‚ β”‚
161
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
162
+ β”‚ β”‚ β”‚
163
+ β”‚ β–Ό β”‚
164
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
165
+ β”‚ β”‚ Risk β”‚ Binary classifier β”‚
166
+ β”‚ β”‚ Predictor β”‚ Output: P(repetition) β”‚
167
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
168
+ β”‚ β”‚ β”‚
169
+ β”‚ β–Ό β”‚
170
+ β”‚ If P > threshold: Apply logit penalties β”‚
171
+ β”‚ β”‚
172
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
173
+ ```
174
+
175
+ **Training Process:**
176
+ 1. Collect positive samples (repetitive generations) and negative samples (clean generations)
177
+ 2. Extract hidden states from layers 16-24 at each token position
178
+ 3. Train binary classifier to predict repetition risk
179
+ 4. Deploy at inference time for real-time intervention
180
+
181
+ ### 2. THE CONDENSATOR: Dense Response Training Pipeline
182
+
183
+ A 4-stage training pipeline that teaches the model to communicate with maximum information density.
184
 
185
  ```
186
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
187
+ β”‚ THE CONDENSATOR Pipeline β”‚
188
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
189
+ β”‚ β”‚
190
+ β”‚ Stage 1: Supervised Fine-Tuning (SFT) β”‚
191
+ β”‚ ───────────────────────────────────── β”‚
192
+ β”‚ β€’ 53 gold-standard dense response examples β”‚
193
+ β”‚ β€’ Learning rate: 2e-5 β”‚
194
+ β”‚ β€’ Loss: 1.17 β†’ 0.72 (39% reduction) β”‚
195
+ β”‚ β”‚
196
+ β”‚ Stage 2: Direct Preference Optimization (DPO) β”‚
197
+ β”‚ ───────────────────────────────────────────── β”‚
198
+ β”‚ β€’ Preference pairs: dense response > verbose response β”‚
199
+ β”‚ β€’ Beta: 0.1 β”‚
200
+ β”‚ β€’ Teaches relative quality judgments β”‚
201
+ β”‚ β”‚
202
+ β”‚ Stage 3: Reinforcement Learning (PPO) β”‚
203
+ β”‚ ───────────────────────────────────── β”‚
204
+ β”‚ β€’ Reward = density_score - filler_penalty - length_penalty β”‚
205
+ β”‚ β€’ Conservative KL constraint β”‚
206
+ β”‚ β€’ 300 optimization steps β”‚
207
+ β”‚ β”‚
208
+ β”‚ Stage 4: Checkpointing β”‚
209
+ β”‚ ───────────────────────── β”‚
210
+ β”‚ β€’ Save every 25 training steps β”‚
211
+ β”‚ β€’ Maintain best checkpoint for rollback β”‚
212
+ β”‚ β€’ A/B comparison on held-out prompts β”‚
213
+ β”‚ β”‚
214
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
215
+ ```
216
+
217
+ ### 3. Stable Recursive Self-Improvement
218
+
219
+ The self-improvement loop includes multiple safeguards to prevent quality degradation:
220
+
221
+ ```
222
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
223
+ β”‚ Stable Self-Improvement Loop β”‚
224
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
225
+ β”‚ β”‚
226
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
227
+ β”‚ β”‚ START β”‚ β”‚
228
+ β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β”‚
229
+ β”‚ β”‚ β”‚
230
+ β”‚ β–Ό β”‚
231
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
232
+ β”‚ β”‚ EVALUATE β”‚ β”‚
233
+ β”‚ β”‚ Current Model β”‚ β”‚
234
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
235
+ β”‚ β”‚ β”‚
236
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
237
+ β”‚ β”‚ β”‚ β”‚
238
+ β”‚ β–Ό β–Ό β”‚
239
+ β”‚ Quality >= Target? Quality < Minimum? β”‚
240
+ β”‚ β”‚ β”‚ β”‚
241
+ β”‚ Yes β”‚ Yes β”‚ β”‚
242
+ β”‚ β–Ό β–Ό β”‚
243
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
244
+ β”‚ β”‚ DONE β”‚ β”‚ ROLLBACK β”‚ β”‚
245
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
246
+ β”‚ β”‚ β”‚ β”‚
247
+ β”‚ No β”‚ No β”‚ β”‚
248
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
249
+ β”‚ β”‚ β”‚
250
+ β”‚ β–Ό β”‚
251
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
252
+ β”‚ β”‚ TRAIN β”‚ β”‚
253
+ β”‚ β”‚ (25 steps) β”‚ β”‚
254
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
255
+ β”‚ β”‚ β”‚
256
+ β”‚ β–Ό β”‚
257
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
258
+ β”‚ β”‚ A/B COMPARE β”‚ β”‚
259
+ β”‚ β”‚ Old vs New β”‚ β”‚
260
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
261
+ β”‚ β”‚ β”‚
262
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
263
+ β”‚ β”‚ β”‚ β”‚
264
+ β”‚ Better? Worse? β”‚
265
+ β”‚ β”‚ β”‚ β”‚
266
+ β”‚ β–Ό β–Ό β”‚
267
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
268
+ β”‚ β”‚ KEEP β”‚ β”‚ ROLLBACK β”‚ β”‚
269
+ β”‚ β”‚ New β”‚ β”‚ to Best β”‚ β”‚
270
+ β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β”‚
271
+ β”‚ β”‚ β”‚ β”‚
272
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
273
+ β”‚ β”‚ β”‚
274
+ β”‚ β–Ό β”‚
275
+ β”‚ (Return to EVALUATE) β”‚
276
+ β”‚ β”‚
277
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
278
+ ```
279
+
280
+ **Safeguards:**
281
+
282
+ | Safeguard | Description |
283
+ |-----------|-------------|
284
+ | Multi-metric evaluation | Density (25%) + Coherence (25%) + Helpfulness (25%) + Penalties (25%) |
285
+ | Gibberish detection | Pattern matching for math soup, terminal escape sequences, repetitive tokens |
286
+ | Automatic rollback | Reverts to best checkpoint if quality drops > 0.05 |
287
+ | Conservative training | Learning rate 2e-6, only 25 steps per iteration |
288
+ | Emergency stop | Halts after 3 consecutive rollbacks or coherence < 0.3 |
289
+
290
+ ---
291
+
292
+ ## Empirical Results
293
+
294
+ ### CF-HoT Head Performance
295
+
296
+ | Head Type | Positive Score | Negative Score | Separation Ratio |
297
+ |-----------|---------------|----------------|------------------|
298
+ | Repetition | 0.875 | 0.007 | **125Γ—** |
299
+ | Verbosity | 0.68 | 0.32 | 2.1Γ— |
300
+ | Hedging | 0.58 | 0.39 | 1.5Γ— |
301
+
302
+ The 125Γ— separation for repetition detection is the key empirical finding. This indicates that the model encodes behavioral intent in its hidden states before generating tokens, and this signal is strong enough to enable reliable intervention.
303
+
304
+ ### Response Quality Improvement
305
+
306
+ | Metric | Baseline | ARC Engine | Change |
307
+ |--------|----------|------------|--------|
308
+ | Information Density | 17.0 | 28.5 | **+68%** |
309
+ | Average Response Tokens | 150 | 65 | **-57%** |
310
+ | Filler Phrase Count | High | ~0 | **-95%** |
311
+ | Mode Collapse Events | Frequent | Zero | **Prevented** |
312
+
313
+ ### Response Examples
314
+
315
+ | Prompt | Base Model Response | ARC Engine Response |
316
+ |--------|--------------------|--------------------|
317
+ | "hello" | "Hello! I'm here to help you with any questions or tasks you might have. Feel free to ask me anything!" (23 tokens) | "Hello. How can I help?" (5 tokens) |
318
+ | "What is recursion?" | "That's a great question! Recursion is a programming concept where a function calls itself to solve a problem by breaking it down into smaller subproblems..." (150+ tokens) | "Function calling itself until base case. Stack frames accumulate, unwind on return." (12 tokens) |
319
+ | "How are you?" | "As an AI, I don't have feelings in the traditional sense, but I'm functioning well and ready to assist you with whatever you need!" (28 tokens) | "Operational. Ready to assist." (4 tokens) |
320
+
321
+ ### RSI-15 Stress Test Results
322
+
323
+ The RSI-15 test runs 15 consecutive self-improvement iterations to verify stability:
324
+
325
+ | Metric | Value |
326
+ |--------|-------|
327
+ | Iterations Completed | 15/15 |
328
+ | Successful Improvements | 8 |
329
+ | Rollbacks Triggered | 4 |
330
+ | Marginal (kept) | 3 |
331
+ | Initial Quality | 0.52 |
332
+ | Final Quality | 0.71 |
333
+ | Peak Quality | 0.73 |
334
+ | Emergency Stops | 0 |
335
+
336
+ ---
337
+
338
+ ## Command Reference
339
+
340
+ ### Self-Improvement Commands
341
+
342
+ ```
343
+ !improve Run one iteration of self-improvement
344
+ !eval Evaluate current model quality
345
+ !train <N> Run N training steps (default: 25)
346
+ !compare Compare current checkpoint vs best
347
+ !rollback Revert to best checkpoint
348
+ !load <path> Load specific checkpoint
349
+ !rsi15 Run 15-iteration stress test
350
+ ```
351
+
352
+ ### CF-HoT Control
353
+
354
+ ```
355
+ !cfhot Toggle 125Γ— head on/off
356
+ !125x Alias for !cfhot
357
+ !cfhot status Show head status and intervention count
358
+ ```
359
+
360
+ ### Multimedia
361
+
362
+ ```
363
+ !stream Open live token streaming window
364
+ !stream off Close streaming window
365
+ !audio Toggle text-to-speech
366
+ !audio voices List available TTS voices
367
+ !audio voice <N> Select voice by index
368
+ !audio rate <N> Set speech rate (default: 175)
369
+ !say <text> Speak text immediately
370
+ !imagine <prompt> Generate image with SDXL
371
+ !dalle <prompt> Generate image with DALL-E 3
372
+ !image view View last generated image
373
+ !image view <path> View image from file
374
+ ```
375
+
376
+ ### Claude Integration
377
+
378
+ ```
379
+ !idea <request> Generate ideas (default: 20 ideas)
380
+ !idea <req> --quick Generate 5 quick ideas
381
+ !idea <req> --deep Generate 30 detailed ideas
382
+ !expand <idea> Expand idea into full plan
383
+ !claude <prompt> Direct Claude prompt
384
+ !claude <p> --opus Use Opus 4.5 specifically
385
+ ```
386
+
387
+ ### Extended Generation
388
+
389
+ ```
390
+ !book Toggle book mode (16K tokens)
391
+ !write <topic> Write complete book
392
+ ```
393
+
394
+ ### Agentic Tools
395
+
396
+ ```
397
+ !shell <cmd> Execute shell command
398
+ !python <code> Execute Python code
399
+ !read <path> Read file contents
400
+ !write <path> <text> Write to file
401
+ !ls [path] List directory
402
+ !web <query> Web search
403
+ ```
404
+
405
+ ### Browser Automation
406
+
407
+ ```
408
+ !browse <url> Open URL in browser
409
+ !click <selector> Click element
410
+ !type <text> Type into focused element
411
+ !fill <sel> <text> Fill specific element
412
+ !login <service> Login to service (gmail, twitter, etc.)
413
+ !close Close browser
414
+ ```
415
+
416
+ ### Utilities
417
+
418
+ ```
419
+ !plot Generate quality history plot
420
+ !benchmark Run evaluation suite
421
+ !export [name] Export checkpoint package
422
+ !import <path> Import checkpoint package
423
+ !learn Learn from high-quality responses
424
+ !api Start REST API server
425
+ status Show system status
426
+ history Show quality history
427
+ help Display help
428
+ quit Exit with final report
429
+ ```
430
+
431
+ ---
432
+
433
+ ## Installation
434
+
435
+ ### Minimal Installation (Core Features)
436
+
437
+ ```bash
438
+ pip install torch transformers peft bitsandbytes accelerate safetensors
439
  ```
440
 
441
+ ### Full Installation (All Features)
442
+
443
+ ```bash
444
+ pip install -r requirements.txt
445
+ playwright install firefox # For browser automation
446
+ ```
447
+
448
+ ### Optional Dependencies
449
+
450
+ | Feature | Package | Install Command |
451
+ |---------|---------|-----------------|
452
+ | Image Generation (SDXL) | diffusers | `pip install diffusers` |
453
+ | Image Generation (DALL-E) | openai | `pip install openai` |
454
+ | Text-to-Speech | pyttsx3, gtts, pygame | `pip install pyttsx3 gtts pygame` |
455
+ | Claude Integration | anthropic | `pip install anthropic` |
456
+ | Vector Memory | chromadb, sentence-transformers | `pip install chromadb sentence-transformers` |
457
+ | Plotting | matplotlib | `pip install matplotlib` |
458
+ | Browser Automation | playwright | `pip install playwright` |
459
+
460
+ **Note:** Python 3.11 is recommended. Python 3.13 has compatibility issues with diffusers.
461
+
462
+ ---
463
+
464
+ ## Configuration
465
+
466
+ ### Environment Variables
467
+
468
+ ```bash
469
+ # Claude API (for !idea, !claude commands)
470
+ export ANTHROPIC_API_KEY="sk-ant-..."
471
+
472
+ # OpenAI API (for !dalle command)
473
+ export OPENAI_API_KEY="sk-..."
474
+ ```
475
+
476
+ ### Config Class Options
477
+
478
+ Edit in `arc_engine_v21_multimedia.py`:
479
+
480
+ ```python
481
+ class Config:
482
+ # Generation
483
+ temperature = 0.85
484
+ top_p = 0.9
485
+ max_new_tokens = 512
486
+
487
+ # CF-HoT
488
+ use_cfhot = True
489
+ use_cfhot_125x = True
490
+ cfhot_repetition_threshold = 0.6
491
+ cfhot_repetition_penalty = 6.0
492
+
493
+ # Self-improvement
494
+ min_quality_score = 0.5
495
+ target_quality_score = 0.75
496
+ training_steps_per_iteration = 25
497
+ quality_drop_threshold = 0.1
498
+
499
+ # Book mode
500
+ book_mode = False
501
+ book_max_tokens = 16384
502
+
503
+ # API server
504
+ api_port = 8080
505
+ ```
506
+
507
+ ---
508
+
509
+ ## Repository Structure
510
+
511
+ ```
512
+ ARC-Base-8B-Condensed/
513
+ β”‚
514
+ β”œβ”€β”€ arc_engine_v21_multimedia.py # Main engine (6,861 lines)
515
+ β”œβ”€β”€ requirements.txt # Full dependencies
516
+ β”œβ”€β”€ requirements_minimal.txt # Core dependencies only
517
+ β”‚
518
+ β”œβ”€β”€ training_scripts/
519
+ β”‚ β”œβ”€β”€ the_condensator.py # 4-stage dense training
520
+ β”‚ β”œβ”€β”€ train_cfhot_head.py # CF-HoT head training
521
+ β”‚ β”œβ”€β”€ train_self_improve.py # Self-improvement loop
522
+ β”‚ └── quickstart.py # One-command trainer
523
+ β”‚
524
+ β”œβ”€β”€ dense_checkpoints/
525
+ β”‚ β”œβ”€β”€ step_100/ # Initial checkpoint
526
+ β”‚ β”œβ”€β”€ step_200/ # After iteration 1
527
+ β”‚ └── step_300/ # After iteration 2
528
+ β”‚
529
+ β”œβ”€β”€ cfhot_checkpoints/
530
+ β”‚ └── ckpt_5000/ # 125Γ— repetition head
531
+ β”‚ └── risk_predictor.pt
532
+ β”‚
533
+ β”œβ”€β”€ multi_head_checkpoints/
534
+ β”‚ β”œβ”€β”€ hedging_head/
535
+ β”‚ β”œβ”€β”€ verbosity_head/
536
+ β”‚ └── sycophancy_head/
537
+ β”‚
538
+ β”œβ”€β”€ paper/
539
+ β”‚ └── arc_paper.pdf # Research paper
540
+ β”‚
541
+ β”œβ”€β”€ books/ # Generated books output
542
+ β”œβ”€β”€ images/ # Generated images output
543
+ β”œβ”€β”€ ideas/ # Generated ideas output
544
+ β”œβ”€β”€ improvement_logs/ # RSI logs and results
545
+ └── exports/ # Checkpoint packages
546
+ ```
547
+
548
+ ---
549
+
550
+ ## Hardware Requirements
551
+
552
+ | Component | Minimum | Recommended |
553
+ |-----------|---------|-------------|
554
+ | GPU VRAM | 16 GB | 24 GB |
555
+ | System RAM | 32 GB | 64 GB |
556
+ | Disk Space | 50 GB | 100 GB |
557
+ | Python | 3.10+ | 3.11 |
558
+
559
+ **Tested Configuration:** NVIDIA RTX 3090 (24GB), 64GB RAM, Ubuntu 22.04
560
+
561
+ **Inference Performance:**
562
+ - ~15 tokens/second with CF-HoT enabled
563
+ - ~20 tokens/second with CF-HoT disabled
564
+
565
+ ---
566
+
567
+ ## Training From Scratch
568
+
569
+ ### Quick Start (Automated)
570
+
571
+ ```bash
572
+ python training_scripts/quickstart.py --full
573
+ ```
574
+
575
+ This runs the complete pipeline (~4 hours on RTX 3090):
576
+ 1. CF-HoT head training (5000 steps)
577
+ 2. CONDENSATOR dense training (3 epochs SFT + 300 RL steps)
578
+ 3. Self-improvement loop (5 iterations)
579
+
580
+ ### Manual Training
581
+
582
+ **Step 1: Train CF-HoT Heads**
583
+
584
+ ```bash
585
+ python training_scripts/train_cfhot_head.py \
586
+ --behavior repetition \
587
+ --steps 5000 \
588
+ --batch-size 16 \
589
+ --learning-rate 1e-4
590
+ ```
591
+
592
+ **Step 2: Run CONDENSATOR Pipeline**
593
+
594
+ ```bash
595
+ python training_scripts/the_condensator.py \
596
+ --sft-epochs 3 \
597
+ --dpo-epochs 1 \
598
+ --rl-steps 300 \
599
+ --checkpoint-every 25
600
+ ```
601
+
602
+ **Step 3: Self-Improvement Loop**
603
+
604
+ ```bash
605
+ python training_scripts/train_self_improve.py \
606
+ --iterations 5 \
607
+ --target-quality 0.75 \
608
+ --rollback-threshold 0.05
609
+ ```
610
+
611
+ ---
612
+
613
+ ## API Reference
614
+
615
+ Start the API server:
616
+
617
+ ```bash
618
+ > !api
619
+ [api] Server running on http://0.0.0.0:8080
620
+ ```
621
+
622
+ ### Endpoints
623
+
624
+ **POST /generate**
625
+
626
+ ```bash
627
+ curl -X POST http://localhost:8080/generate \
628
+ -H "Content-Type: application/json" \
629
+ -d '{"prompt": "What is recursion?"}'
630
+ ```
631
+
632
+ Response:
633
+ ```json
634
+ {
635
+ "response": "Function calling itself until base case. Stack frames accumulate, unwind on return.",
636
+ "quality": 0.82,
637
+ "tokens": 12
638
+ }
639
+ ```
640
+
641
+ **POST /status**
642
+
643
+ ```bash
644
+ curl -X POST http://localhost:8080/status
645
+ ```
646
+
647
+ Response:
648
+ ```json
649
+ {
650
+ "quality": 0.71,
651
+ "iteration": 5,
652
+ "checkpoint": "dense_checkpoints/step_300"
653
+ }
654
+ ```
655
+
656
+ **GET /health**
657
+
658
+ ```bash
659
+ curl http://localhost:8080/health
660
+ ```
661
+
662
+ ---
663
+
664
+ ## Limitations
665
+
666
+ | Limitation | Description |
667
+ |------------|-------------|
668
+ | Scale | Tested on 8B parameters only; larger models may behave differently |
669
+ | Language | English only; other languages untested |
670
+ | Iterations | 5-15 stable iterations demonstrated; long-term stability unknown |
671
+ | Evaluation | Heuristic metrics without formal human evaluation study |
672
+ | Scope | Bounded self-optimization within defined metrics; not open-ended self-improvement |
673
+ | SDXL | Requires Python 3.11 (incompatible with Python 3.13) |
674
+ | Memory | Full features require 24GB VRAM; minimal mode works with 16GB |
675
+
676
+ ---
677
 
678
  ## Citation
679
 
680
  ```bibtex
681
+ @software{napolitano2025arc,
682
+ title={ARC: Adaptive Recursive Cognition via Contrastive Hidden-State Control},
683
+ author={Napolitano, Logan Matthew},
684
+ year={2025},
685
+ url={https://huggingface.co/LoganResearch/ARC-Base-8B-Condensed},
686
+ license={CC-BY-4.0}
687
  }
688
  ```
689
 
690
+ ---
691
+
692
+ ## References
693
+
694
+ 1. Zou, A., et al. (2023). Representation Engineering: A Top-Down Approach to AI Transparency. arXiv:2310.01405
695
+ 2. Ouyang, L., et al. (2022). Training language models to follow instructions with human feedback. NeurIPS.
696
+ 3. Rafailov, R., et al. (2023). Direct Preference Optimization: Your Language Model is Secretly a Reward Model. arXiv:2305.18290
697
+ 4. Hu, E. J., et al. (2021). LoRA: Low-Rank Adaptation of Large Language Models. arXiv:2106.09685
698
+ 5. Dettmers, T., et al. (2023). QLoRA: Efficient Finetuning of Quantized LLMs. arXiv:2305.14314
699
+
700
+ ---
701
+
702
+ ## Acknowledgments
703
+
704
+ - **NousResearch** for Hermes-3-Llama-3.1-8B base model
705
+ - **Meta AI** for Llama 3.1 architecture
706
+ - **Hugging Face** for transformers, PEFT, TRL, and Accelerate
707
+ - **Stability AI** for Stable Diffusion XL
708
+ - **Anthropic** for Claude API
709
+
710
+ ---
711
+
712
  ## License
713
 
714
+ This project is licensed under **CC BY 4.0** (Creative Commons Attribution 4.0 International).
715
+
716
+ You are free to:
717
+ - **Share** β€” copy and redistribute the material in any medium or format
718
+ - **Adapt** β€” remix, transform, and build upon the material for any purpose, including commercial
719
+
720
+ Under the following terms:
721
+ - **Attribution** β€” You must give appropriate credit, provide a link to the license, and indicate if changes were made.
722
+
723
+ ---
724
+
725
+ *"Stable self-improvement through hidden-state control."*