reaperdoesntknow commited on
Commit
b1c6219
·
verified ·
1 Parent(s): dac250a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +223 -173
README.md CHANGED
@@ -1,199 +1,249 @@
1
  ---
 
 
 
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
 
 
 
 
10
 
 
11
 
12
- ## Model Details
 
 
 
 
 
13
 
14
- ### Model Description
 
 
 
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
 
76
  ## Training Details
77
 
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
 
 
 
 
 
 
 
182
 
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
 
 
 
 
 
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
 
196
 
197
- ## Model Card Contact
 
 
 
 
198
 
199
- [More Information Needed]
 
1
  ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
  library_name: transformers
6
+ tags:
7
+ - text-generation
8
+ - causal-lm
9
+ - swarm-intelligence
10
+ - multi-agent
11
+ - pytorch
12
+ - transformers
13
+ pipeline_tag: text-generation
14
+ model-index:
15
+ - name: SAGI
16
+ results: []
17
  ---
18
 
19
+ # SAGI - Swarm AGI Language Model
20
+
21
+ SAGI is a novel causal language model that integrates **swarm intelligence dynamics** with transformer architecture. The model treats cognition as a dynamic, adaptive system where multiple internal "agents" collaborate through differentiable routing, trust mechanisms, and shared memory.
22
+
23
+ ## Model Description
24
+
25
+ | Property | Value |
26
+ |----------|-------|
27
+ | Parameters | 52.72M |
28
+ | Architecture | Transformer Decoder + Swarm Dynamics |
29
+ | Hidden Size | 512 |
30
+ | Layers | 6 |
31
+ | Attention Heads | 8 |
32
+ | Context Length | 2048 |
33
+ | Vocabulary | GPT-2 tokenizer (50,257 tokens) |
34
+
35
+ ### Key Innovations
36
+
37
+ - **Differentiable Routing**: Continuous mixture-of-experts via attention (`DiffRouter`) instead of hard module selection
38
+ - **Adaptive Gating & Trust**: `MetaController` activates capacity under resource constraints; trust dynamics bias reliable components
39
+ - **Episodic + Semantic Memory**: Dual memory system with trainable retrieval utility
40
+ - **Curiosity Engine**: Injects novel goals when surprise is low, promoting exploration
41
+ - **Self-Model & Rollback**: Predicts state transitions and detects anomalies for self-correction
42
+ - **Resource Dynamics**: Soft conservation with learned converter; cognition consumes/recovers compute, memory, energy
43
+ - **Value Monitoring**: Tracks alignment to core values and freezes plasticity under drift
44
+
45
+ ## How It Works
46
+
47
+ ```
48
+ ┌─────────────────────────────────────────────────────────┐
49
+ │ SAGI Model │
50
+ ├─────────────────────────────────────────────────────────┤
51
+ │ ┌─────────────────┐ ┌─────────────────────────┐ │
52
+ │ │ Swarm-7 V2.2 │─────▶│ Swarm State S, T │ │
53
+ │ │ (Cognitive │ │ (Working Memory) │ │
54
+ │ │ Dynamics) │ └───────────┬─────────────┘ │
55
+ │ └────────▲────────┘ │ │
56
+ │ │ ▼ │
57
+ │ │ ┌─────────────────────────┐ │
58
+ │ │ │ Transformer Decoder │ │
59
+ │ │ │ - Swarm-conditioned │ │
60
+ │ │ │ attention & FFN │ │
61
+ │ │ │ - RoPE embeddings │ │
62
+ │ │ └───────────┬─────────────┘ │
63
+ │ │ │ │
64
+ │ ┌────────┴────────┐ ┌─────────────────────────┐ │
65
+ │ │ Observation │◀─────│ LM Head │ │
66
+ │ │ (from tokens) │ └─────────────────────────┘ │
67
+ │ └─────────────────┘ │
68
+ └─────────────────────────────────────────────────────────┘
69
+ ```
70
+
71
+ The swarm processes observations derived from token embeddings, updating its internal state **S**. This state conditions the transformer's attention patterns and feed-forward activations via learned projections, creating bidirectional information flow between symbolic (tokens) and subsymbolic (swarm dynamics) processing.
72
+
73
+ ## Usage
74
+
75
+ ### Installation
76
+
77
+ ```bash
78
+ pip install torch transformers datasets
79
+ ```
80
+
81
+ ### Quick Start
82
+
83
+ ```python
84
+ from transformers import AutoTokenizer
85
+ from modeling_swarm import SwarmForCausalLM
86
+ from configuration_swarm import SwarmConfig
87
+
88
+ # Load model and tokenizer
89
+ model = SwarmForCausalLM.from_pretrained("your-username/SAGI")
90
+ tokenizer = AutoTokenizer.from_pretrained("your-username/SAGI")
91
+
92
+ # Generate text
93
+ model.eval()
94
+ model.reset_swarm_state() # Reset for clean generation
95
+
96
+ prompt = "Once upon a time"
97
+ inputs = tokenizer(prompt, return_tensors="pt")
98
+
99
+ outputs = model.generate(
100
+ **inputs,
101
+ max_new_tokens=100,
102
+ temperature=0.8,
103
+ top_k=50,
104
+ top_p=0.9,
105
+ do_sample=True,
106
+ pad_token_id=tokenizer.eos_token_id,
107
+ )
108
+
109
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
110
+ ```
111
+
112
+ ### Inspecting Swarm State
113
+
114
+ ```python
115
+ # Get current swarm state
116
+ state = model.get_swarm_state()
117
+ print(f"Active agents: {sum(state['active'][0])}")
118
+ print(f"Goal stack depth: {state['goal_stack_size']}")
119
+
120
+ # Reset swarm state between generations
121
+ model.reset_swarm_state()
122
+ ```
123
+
124
+ ### Training
125
+
126
+ ```python
127
+ from datasets import load_dataset
128
+ from transformers import Trainer, TrainingArguments
129
+
130
+ # Load dataset
131
+ dataset = load_dataset("roneneldan/TinyStories", split="train[:5%]")
132
+
133
+ # Tokenize
134
+ def tokenize(examples):
135
+ return tokenizer(examples["text"], truncation=True, max_length=256)
136
+
137
+ tokenized = dataset.map(tokenize, batched=True, remove_columns=["text"])
138
+
139
+ # Train
140
+ training_args = TrainingArguments(
141
+ output_dir="./sagi-finetuned",
142
+ per_device_train_batch_size=4,
143
+ learning_rate=3e-4,
144
+ num_train_epochs=1,
145
+ save_steps=500,
146
+ )
147
+
148
+ trainer = Trainer(
149
+ model=model,
150
+ args=training_args,
151
+ train_dataset=tokenized,
152
+ )
153
+
154
+ trainer.train()
155
+ ```
156
+
157
+ ## Model Architecture Details
158
+
159
+ ### Swarm Configuration
160
+
161
+ | Parameter | Value | Description |
162
+ |-----------|-------|-------------|
163
+ | `max_agents` | 20 | Number of internal cognitive agents |
164
+ | `dim_s` | 64 | State dimension |
165
+ | `dim_t` | 32 | Task/goal dimension |
166
+ | `dim_obs` | 48 | Observation dimension |
167
+ | `topk_route` | 5 | Sparse routing top-k |
168
+ | `K_thought_max` | 5 | Maximum thinking iterations per step |
169
 
170
+ ### Resource Budgets
171
 
172
+ | Resource | Budget | Description |
173
+ |----------|--------|-------------|
174
+ | Compute | 60.0 | Compute budget per step |
175
+ | Memory | 20.0 | Memory capacity |
176
+ | Energy | 25.0 | Energy budget |
177
 
178
+ ### Trust & Plasticity
179
 
180
+ - **Trust Learning Rate**: 0.07
181
+ - **Fast EMA (Plasticity)**: 0.10
182
+ - **Slow EMA (Consolidation)**: 0.002
183
+ - **Core Values**: `["truth", "safety", "efficiency"]`
184
+
185
+ ## Limitations
186
 
187
+ - **Early Research Model**: This is an experimental architecture exploring swarm-transformer integration
188
+ - **Training Data**: Currently trained on TinyStories subset; may produce simple, story-like outputs
189
+ - **Compute Requirements**: Swarm dynamics add overhead compared to standard transformers
190
+ - **Generation Quality**: Model is undertrained; outputs may be repetitive or incoherent
191
 
192
+ ## Intended Use
193
 
194
+ This model is intended for:
195
+ - Research into multi-agent cognitive architectures
196
+ - Exploration of dynamic, adaptive language models
197
+ - Educational purposes in understanding swarm intelligence + LLMs
198
 
199
+ Not intended for:
200
+ - Production applications
201
+ - Safety-critical systems
202
+ - Generation of factual content
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
 
204
  ## Training Details
205
 
206
+ - **Dataset**: TinyStories (subset)
207
+ - **Optimizer**: AdamW (lr=3e-4, betas=(0.9, 0.999), weight_decay=0.01)
208
+ - **Scheduler**: Cosine annealing
209
+ - **Precision**: FP32
210
+ - **Hardware**: CPU training (compatible with CUDA)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
+ ## Citation
213
 
214
+ ```bibtex
215
+ @software{sagi2024,
216
+ title={SAGI: Swarm AGI Language Model},
217
+ author={},
218
+ year={2024},
219
+ url={https://huggingface.co/your-username/SAGI}
220
+ }
221
+ ```
222
 
223
+ ## License
224
 
225
+ Apache 2.0
226
 
227
+ ## Files
228
 
229
+ - `config.json` - Model configuration
230
+ - `model.safetensors` / `pytorch_model.bin` - Model weights
231
+ - `tokenizer.json` - Tokenizer configuration
232
+ - `modeling_swarm.py` - Model implementation (required for loading)
233
+ - `configuration_swarm.py` - Config class (required for loading)
234
+ - `model.py` - Swarm-7 V2.2 core system
235
 
236
+ ## Custom Code Notice
237
 
238
+ This model requires custom code to run. When loading, use `trust_remote_code=True`:
239
 
240
+ ```python
241
+ from transformers import AutoModelForCausalLM
242
 
243
+ model = AutoModelForCausalLM.from_pretrained(
244
+ "your-username/SAGI",
245
+ trust_remote_code=True
246
+ )
247
+ ```
248
 
249
+ Or import the classes directly from the model files as shown in the Quick Start section.