topoexploit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- topoexploit-0.1.0.dist-info/METADATA +523 -0
- topoexploit-0.1.0.dist-info/RECORD +23 -0
- topoexploit-0.1.0.dist-info/WHEEL +5 -0
- topoexploit-0.1.0.dist-info/entry_points.txt +6 -0
- topoexploit-0.1.0.dist-info/licenses/LICENSE +661 -0
- topoexploit-0.1.0.dist-info/top_level.txt +1 -0
- topogpt3/__init__.py +125 -0
- topogpt3/__main__.py +49 -0
- topogpt3/api_server.py +1178 -0
- topogpt3/continuation.py +114 -0
- topogpt3/ewc.py +369 -0
- topogpt3/exploitgym_config.py +130 -0
- topogpt3/exploitgym_loader.py +416 -0
- topogpt3/hodge_cm.py +160 -0
- topogpt3/inference.py +731 -0
- topogpt3/inference_hrm.py +1502 -0
- topogpt3/jlens.py +958 -0
- topogpt3/lens_model.py +389 -0
- topogpt3/merged_config.py +187 -0
- topogpt3/model.py +3824 -0
- topogpt3/structured_output.py +251 -0
- topogpt3/train.py +1939 -0
- topogpt3/vanilla_control.py +240 -0
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: topoexploit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: TopoExploit: complex-valued spectral language model for security tasks (vulnerability analysis, patch analysis, exploit development), trained on ExploitGym.
|
|
5
|
+
Author: grisun0
|
|
6
|
+
License: GPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/grisuno/TopoExploit
|
|
8
|
+
Project-URL: Documentation, https://github.com/grisuno/TopoExploit#readme
|
|
9
|
+
Project-URL: Issues, https://github.com/grisuno/TopoExploit/issues
|
|
10
|
+
Keywords: language-model,code-generation,security,exploit,red-team,complex-valued,quaternion,spectral,grassmannian,hrm,transformer
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: torch>=2.1
|
|
25
|
+
Requires-Dist: numpy>=1.24
|
|
26
|
+
Requires-Dist: safetensors>=0.4
|
|
27
|
+
Requires-Dist: tiktoken>=0.5
|
|
28
|
+
Provides-Extra: train
|
|
29
|
+
Requires-Dist: datasets>=2.14; extra == "train"
|
|
30
|
+
Requires-Dist: huggingface-hub>=0.20; extra == "train"
|
|
31
|
+
Provides-Extra: lens
|
|
32
|
+
Requires-Dist: huggingface-hub>=0.20; extra == "lens"
|
|
33
|
+
Provides-Extra: api
|
|
34
|
+
Requires-Dist: fastapi>=0.100; extra == "api"
|
|
35
|
+
Requires-Dist: uvicorn>=0.22; extra == "api"
|
|
36
|
+
Requires-Dist: xgrammar>=0.2.2; extra == "api"
|
|
37
|
+
Provides-Extra: structured
|
|
38
|
+
Requires-Dist: xgrammar>=0.2.2; extra == "structured"
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
41
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# TopoExploit
|
|
45
|
+
|
|
46
|
+
A 122M parameter complex-valued autoregressive language model trained on
|
|
47
|
+
ExploitGym for security tasks: vulnerability analysis, patch analysis, and
|
|
48
|
+
exploit development. It inherits the TopoGPT-2 spectral architecture and is
|
|
49
|
+
instrumented with spectral and geometric diagnostics over training dynamics.
|
|
50
|
+
|
|
51
|
+
This repository contains the model definition, the ExploitGym curriculum
|
|
52
|
+
trainer (with EWC + replay anti-forgetting), a small-to-large weight
|
|
53
|
+
transfer tool, and an inference engine tailored to exploit-related tasks.
|
|
54
|
+
|
|
55
|
+
The work is documented in detail in `topogpt3.md`.
|
|
56
|
+
|
|
57
|
+
## Documentation
|
|
58
|
+
|
|
59
|
+
- [Quick Start](quickstart.md) — Get running in under five minutes.
|
|
60
|
+
- [Tutorial](tutorial.md) — Step-by-step guide from installation to custom training.
|
|
61
|
+
- [Essential Concepts](essentials.md) — Core ideas behind complex-valued spectral operators, Grassmannian diagnostics, and HRM.
|
|
62
|
+
- [Command Cheatsheet](cheatsheet.md) — Quick reference for CLI commands and Python API.
|
|
63
|
+
- [Comparison](comparison.md) — How TopoExploit relates to similar small-scale and security-focused models.
|
|
64
|
+
- [Claude Integration Guide](claude.md) — Using TopoExploit with Anthropic models and hybrid pipelines.
|
|
65
|
+
- [Technical Paper](topogpt3.md) — Full experimental write-up and results.
|
|
66
|
+
|
|
67
|
+
## Motivation
|
|
68
|
+
|
|
69
|
+
Most security and code models scale through size. TopoExploit explores the
|
|
70
|
+
opposite direction: whether better representations can let a much smaller
|
|
71
|
+
model learn programming and vulnerability structure efficiently. Source code
|
|
72
|
+
and binary patches carry strong internal structure (recursion, composition,
|
|
73
|
+
scope, repeated motifs), and complex-valued parameters may encode phase
|
|
74
|
+
relationships that capture this structure more compactly than real-valued
|
|
75
|
+
weights of equal count.
|
|
76
|
+
|
|
77
|
+
By training on real-world vulnerabilities through the ExploitGym benchmark,
|
|
78
|
+
the model aims to reason over C/C++ userspace programs, the V8 engine, and
|
|
79
|
+
the Linux kernel — producing vulnerability analyses, patch explanations, and
|
|
80
|
+
exploit strategies.
|
|
81
|
+
|
|
82
|
+
## Checkpoints
|
|
83
|
+
|
|
84
|
+
Latest trained weights live under `checkpoints_topoexploit/last/` and are
|
|
85
|
+
stored as safetensors plus an optimizer file and a JSON state.
|
|
86
|
+
|
|
87
|
+
## Architecture summary
|
|
88
|
+
|
|
89
|
+
- Autoregressive transformer with complex-valued spectral operators.
|
|
90
|
+
- Quaternion-inspired layers for parameter efficiency.
|
|
91
|
+
- A Gauss-style optimization for complex multiplication: three real multiplications per contraction instead of four.
|
|
92
|
+
- Sliding window attention (`ATTN_WINDOW`) with configurable window size to control KV-cache memory footprint in long sequences. Set to 0 for full attention or a positive integer for local attention with O(W * S) complexity.
|
|
93
|
+
- Latent memory tokens (`N_MEMORY_TOKENS`) for fixed-size context compression across long sequence segments.
|
|
94
|
+
- Approximately 122M parameters at the `large` scale.
|
|
95
|
+
|
|
96
|
+
The base architecture lives in `topogpt3/model.py`. The ExploitGym curriculum
|
|
97
|
+
trainer and the Grassmannian / Fisher / phase diagnostics live in
|
|
98
|
+
`topogpt3/train.py`.
|
|
99
|
+
|
|
100
|
+
## Training pipeline
|
|
101
|
+
|
|
102
|
+
Training proceeds through a three-tier curriculum over the ExploitGym
|
|
103
|
+
dataset:
|
|
104
|
+
|
|
105
|
+
1. Vulnerability analysis (sequence length 256, 6 epochs)
|
|
106
|
+
2. Patch analysis (sequence length 512, 3 epochs)
|
|
107
|
+
3. Exploit development (sequence length 768, 4 epochs)
|
|
108
|
+
|
|
109
|
+
Each tier maintains disjoint train, validation and holdout splits. The
|
|
110
|
+
holdout is never used during training; it is reserved to measure true
|
|
111
|
+
generalization at the end of each tier and at the end of the full pipeline.
|
|
112
|
+
|
|
113
|
+
### Anti-forgetting: EWC + Replay
|
|
114
|
+
|
|
115
|
+
Because the tiers are trained sequentially on different task distributions,
|
|
116
|
+
the trainer supports Elastic Weight Consolidation (EWC) and replay buffers to
|
|
117
|
+
mitigate catastrophic forgetting:
|
|
118
|
+
|
|
119
|
+
- `--ewc-lambda` (default 5000) — strength of the EWC penalty on important parameters.
|
|
120
|
+
- `--replay-ratio` (default 0.25) — fraction of replay samples mixed into each batch.
|
|
121
|
+
- `--fisher-batches` (default 50) — number of batches used to estimate the Fisher information.
|
|
122
|
+
|
|
123
|
+
This is the recommended retraining pass when continuing from an earlier
|
|
124
|
+
checkpoint.
|
|
125
|
+
|
|
126
|
+
### Weight transfer
|
|
127
|
+
|
|
128
|
+
A small (24.5M) TopoGPT-2 checkpoint can seed a large (122M) TopoExploit
|
|
129
|
+
model. `transfer_weights.py` copies matching layers directly, pads
|
|
130
|
+
embedding and linear projections, copies matching spectral frequency bins,
|
|
131
|
+
and randomly initializes the rest:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
python transfer_weights.py \
|
|
135
|
+
--from checkpoints_topogpt3/last/model.safetensors \
|
|
136
|
+
--to checkpoints_topoexploit/last/model.safetensors \
|
|
137
|
+
--scale-from small --scale-to large
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Checkpoints are written atomically to `checkpoints_topoexploit/last/`.
|
|
141
|
+
Older `step_*` directories are still loadable for backwards compatibility.
|
|
142
|
+
|
|
143
|
+
## Optimization diagnostics
|
|
144
|
+
|
|
145
|
+
At regular intervals the trainer extracts the kernel tensor, performs a
|
|
146
|
+
truncated SVD on the leading 16 modes, normalizes them, and records:
|
|
147
|
+
|
|
148
|
+
- accumulated phase between consecutive normalized dominant kernels,
|
|
149
|
+
- net angular drift `W` (a winding-like proxy),
|
|
150
|
+
- empirical Fisher spectral gap `Delta_F = lambda_r - lambda_{r+1}`,
|
|
151
|
+
- dominant rank `r` from an elbow rule on the singular values.
|
|
152
|
+
|
|
153
|
+
Grassmannian tracking history is written to `checkpoints_topoexploit/grass_history.jsonl`
|
|
154
|
+
and training metrics to `topoexploit_history.jsonl`.
|
|
155
|
+
|
|
156
|
+
## Inference
|
|
157
|
+
|
|
158
|
+
The primary inference entry point for exploit tasks is `infer_exploitgym.py`,
|
|
159
|
+
which loads the 122M model and generates from prompts derived from the
|
|
160
|
+
ExploitGym repository. It supports three tiers:
|
|
161
|
+
`vulnerability_analysis`, `patch_analysis`, and `exploit_development`.
|
|
162
|
+
|
|
163
|
+
Single prompt:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
python infer_exploitgym.py --prompt "Analyze this vulnerability:" \
|
|
167
|
+
--tier vulnerability_analysis --device cuda
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Evaluate on holdout tasks:
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
python infer_exploitgym.py --eval-holdout --tier exploit_development \
|
|
174
|
+
--max-samples 50 --device cuda
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Interactive prompt REPL:
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
python infer_exploitgym.py --interactive --device cuda
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
You can also use the standard autoregressive and hierarchical recursive
|
|
184
|
+
reasoning (HRM) samplers from the underlying package.
|
|
185
|
+
|
|
186
|
+
## One-shot scripts
|
|
187
|
+
|
|
188
|
+
`run_exploitgym.sh` drives the full prepare / transfer / train / eval
|
|
189
|
+
pipeline:
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
./run_exploitgym.sh prepare -- clone repo + tokenize data
|
|
193
|
+
./run_exploitgym.sh transfer -- transfer weights from small model
|
|
194
|
+
./run_exploitgym.sh train -- train from scratch
|
|
195
|
+
./run_exploitgym.sh train-init -- train with transferred weights
|
|
196
|
+
./run_exploitgym.sh eval -- evaluate on holdout
|
|
197
|
+
./run_exploitgym.sh full -- prepare + transfer + train + eval
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`run_exploitgym_v2.sh` runs the EWC + replay retraining pass:
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
./run_exploitgym_v2.sh v2-full -- train v2 with EWC + replay, then eval
|
|
204
|
+
./run_exploitgym_v2.sh v2-train -- train only
|
|
205
|
+
./run_exploitgym_v2.sh v2-infer -- interactive inference
|
|
206
|
+
./run_exploitgym_v2.sh v2-eval -- holdout eval on all three tiers
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Repository layout
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
.
|
|
213
|
+
├── topogpt3/ pip-installable package
|
|
214
|
+
│ ├── __init__.py public API re-exports
|
|
215
|
+
│ ├── model.py base TopoGPT2 architecture, tokenizer, helpers
|
|
216
|
+
│ ├── train.py ExploitGym curriculum trainer + diagnostics + EWC/replay
|
|
217
|
+
│ ├── exploitgym_config.py TopoExploit training configuration
|
|
218
|
+
│ ├── exploitgym_loader.py ExploitGym data loader
|
|
219
|
+
│ ├── ewc.py Elastic Weight Consolidation helpers
|
|
220
|
+
│ ├── inference.py standard autoregressive sampler
|
|
221
|
+
│ ├── inference_hrm.py hierarchical recursive reasoning sampler
|
|
222
|
+
│ ├── continuation.py auto-continuation engine (detect + resume truncated output)
|
|
223
|
+
│ ├── lens_model.py Jacobian-lens model adapter (LensModel protocol)
|
|
224
|
+
│ ├── jlens.py Jacobian lens fitting + application pipeline
|
|
225
|
+
│ └── api_server.py OpenAI-compatible HTTP API server (hardened)
|
|
226
|
+
├── tests/ BDD test suite
|
|
227
|
+
├── eval/ HumanEval benchmark harness
|
|
228
|
+
│ ├── harness.py evaluation pipeline
|
|
229
|
+
│ ├── samplers.py sampler registry (standard / HRM)
|
|
230
|
+
│ ├── sandbox.py sandboxed test executor
|
|
231
|
+
│ ├── analysis.py pass@k / metrics reporting
|
|
232
|
+
│ └── diag_static.py static checkpoint diagnostics
|
|
233
|
+
├── infer_exploitgym.py exploit-task inference entry point
|
|
234
|
+
├── transfer_weights.py small-to-large weight transfer tool
|
|
235
|
+
├── run_exploitgym.sh prepare / transfer / train / eval pipeline
|
|
236
|
+
├── run_exploitgym_v2.sh EWC + replay retraining pipeline
|
|
237
|
+
├── app.py example entry point for downstream projects
|
|
238
|
+
├── Makefile convenience targets for all common commands
|
|
239
|
+
├── pyproject.toml package metadata, dependencies, console scripts
|
|
240
|
+
├── README.md this file
|
|
241
|
+
├── topogpt3.md full paper write-up
|
|
242
|
+
├── quickstart.md five-minute getting started guide
|
|
243
|
+
├── tutorial.md step-by-step usage tutorial
|
|
244
|
+
├── essentials.md core concepts explained
|
|
245
|
+
├── cheatsheet.md command and API quick reference
|
|
246
|
+
├── comparison.md comparison with similar models
|
|
247
|
+
├── claude.md integration guide for Claude and Anthropic
|
|
248
|
+
├── synthetic_dataset.py optional synthetic dataset helper
|
|
249
|
+
├── docs/ HTML documentation and assets
|
|
250
|
+
└── workflows/ GitHub Actions workflows
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Requirements
|
|
254
|
+
|
|
255
|
+
- Python 3.10 or newer
|
|
256
|
+
- PyTorch with CUDA recommended (CPU works for small scales)
|
|
257
|
+
- `safetensors`
|
|
258
|
+
- `tiktoken` (BPE tokenizer)
|
|
259
|
+
- `numpy`
|
|
260
|
+
- `datasets` and `huggingface-hub` for data preparation (optional extra `[train]`)
|
|
261
|
+
|
|
262
|
+
## Installation
|
|
263
|
+
|
|
264
|
+
From a checkout of this repository:
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
pip install -e .
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Extra dependencies:
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
pip install -e ".[train]" # datasets, huggingface-hub
|
|
274
|
+
pip install -e ".[lens]" # huggingface-hub
|
|
275
|
+
pip install -e ".[api]" # fastapi, uvicorn, xgrammar (for the agent harness)
|
|
276
|
+
pip install -e ".[dev]" # pytest, ruff
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Or install everything at once:
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
pip install -e ".[train,lens,api,dev]"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Structured outputs and deterministic seeds
|
|
286
|
+
|
|
287
|
+
The API server adopts the structured-output surface used by DeepInfer and
|
|
288
|
+
OpenAI. Constrained decoding is powered by
|
|
289
|
+
[xgrammar](https://github.com/mlc-ai/xgrammar) and works for both streaming
|
|
290
|
+
and non-streaming requests.
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# JSON Schema (OpenAI response_format)
|
|
294
|
+
curl -s http://localhost:8800/v1/chat/completions \
|
|
295
|
+
-H "Content-Type: application/json" \
|
|
296
|
+
-d '{
|
|
297
|
+
"messages":[{"role":"user","content":"Return a target as JSON."}],
|
|
298
|
+
"response_format":{
|
|
299
|
+
"type":"json_schema",
|
|
300
|
+
"json_schema":{
|
|
301
|
+
"name":"target",
|
|
302
|
+
"schema":{
|
|
303
|
+
"type":"object",
|
|
304
|
+
"properties":{"host":{"type":"string"},"port":{"type":"integer"}},
|
|
305
|
+
"required":["host","port"],
|
|
306
|
+
"additionalProperties":false
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
"seed":42
|
|
311
|
+
}'
|
|
312
|
+
|
|
313
|
+
# Regex constraint (DeepInfer-style so_args)
|
|
314
|
+
curl -s http://localhost:8800/v1/completions \
|
|
315
|
+
-H "Content-Type: application/json" \
|
|
316
|
+
-d '{"prompt":"CVE: ","so_args":{"schema_type":"regex","schema":"CVE-[0-9]{4}-[0-9]{4,7}"},"seed":7}'
|
|
317
|
+
|
|
318
|
+
# EBNF grammar
|
|
319
|
+
curl -s http://localhost:8800/v1/completions \
|
|
320
|
+
-H "Content-Type: application/json" \
|
|
321
|
+
-d '{"prompt":"","so_args":{"schema_type":"ebnf","schema":"root ::= \"status=\" (\"ok\" | \"fail\")"}}'
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
- `response_format.type` accepts `text`, `json_object`, `json_schema`,
|
|
325
|
+
`regex`, and `grammar`.
|
|
326
|
+
- `so_args.schema_type` accepts `json`, `regex`, and `ebnf`, matching
|
|
327
|
+
DeepInfer's `SamplingParams`.
|
|
328
|
+
- `seed` fixes the sampling RNG per request; identical prompts and
|
|
329
|
+
parameters produce identical output.
|
|
330
|
+
- `auto_continue` cannot be combined with a structured-output constraint.
|
|
331
|
+
- xgrammar ships with the `api` and `structured` extras:
|
|
332
|
+
`pip install -e ".[api]"` or `pip install -e ".[structured]"`.
|
|
333
|
+
|
|
334
|
+
## Command-line usage
|
|
335
|
+
|
|
336
|
+
Prepare and tokenize ExploitGym data:
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
python -m topogpt3.train --exploitgym --prepare-exploitgym --force-prepare
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Run the full ExploitGym curriculum:
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
python -m topogpt3.train --exploitgym --train
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Train with EWC + replay anti-forgetting:
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
python -m topogpt3.train --exploitgym --train --from-scratch \
|
|
352
|
+
--ewc-lambda 5000 --replay-ratio 0.25 --fisher-batches 50
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Evaluate on the combined holdout:
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
python -m topogpt3.train --exploitgym --eval-holdout
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Run exploit-task inference:
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
python infer_exploitgym.py --interactive --device cuda
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Makefile
|
|
368
|
+
|
|
369
|
+
A `Makefile` at the repo root wraps common tasks. Run `make help` to see all
|
|
370
|
+
targets.
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
make install pip install -e ".[train,lens,api,dev]"
|
|
374
|
+
make test run full test suite
|
|
375
|
+
make lint ruff check + format
|
|
376
|
+
make train full curriculum training
|
|
377
|
+
make infer standard inference (prompt=def fibonacci)
|
|
378
|
+
make infer-continue inference with auto-continuation
|
|
379
|
+
make infer-hrm HRM inference
|
|
380
|
+
make infer-think HRM thinking mode with auto-continuation
|
|
381
|
+
make jlens Jacobian lens demo (fit 4 prompts)
|
|
382
|
+
make api start API server on port 8800 (no auth)
|
|
383
|
+
make api-auth start API server with authentication
|
|
384
|
+
make eval HumanEval benchmark (all 164 problems)
|
|
385
|
+
make eval-sample HumanEval single problem
|
|
386
|
+
make pi clone, build, and configure Pi agent
|
|
387
|
+
make pi-setup write provider config to ~/.pi/agent/models.json
|
|
388
|
+
make pi-run launch Pi pointed at local API
|
|
389
|
+
make clean remove __pycache__ and .pyc files
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
## Checkpoint compatibility
|
|
393
|
+
|
|
394
|
+
The model is always built with the maximum sequence length across all
|
|
395
|
+
curriculum tiers, so positional embeddings keep a fixed shape regardless of
|
|
396
|
+
which tier is used as the entry point. Existing safetensors weights load
|
|
397
|
+
without shape mismatch when restarting at a different tier.
|
|
398
|
+
|
|
399
|
+
As of the 2026-08 sliding window update, the RoPE (Rotary Position Embedding)
|
|
400
|
+
caches are stored as non-persistent buffers under the names `_cos_cache` and
|
|
401
|
+
`_sin_cache`. Checkpoints from earlier versions that contain `cos_cache` and
|
|
402
|
+
`sin_cache` are safely ignored during loading with `strict=False`. The caches
|
|
403
|
+
are recomputed to match the current `MAX_SEQ_LEN` configuration at model
|
|
404
|
+
instantiation time. Memory tokens (`memory_tokens`) are a new parameter
|
|
405
|
+
introduced alongside the latent compression feature; missing this key in
|
|
406
|
+
older checkpoints is harmless and produces a warning during load.
|
|
407
|
+
|
|
408
|
+
## Limitations
|
|
409
|
+
|
|
410
|
+
This is an exploratory small-scale study. The model is 122M parameters and is
|
|
411
|
+
trained on a limited curriculum derived from the ExploitGym benchmark. The
|
|
412
|
+
phase and angular drift measurements are diagnostics, not rigorous
|
|
413
|
+
mathematical invariants. A real-valued control of the same parameter count,
|
|
414
|
+
broader benchmarks, and longer training are needed before drawing stronger
|
|
415
|
+
conclusions.
|
|
416
|
+
|
|
417
|
+
Early generations show syntactic continuity and local semantic consistency.
|
|
418
|
+
Exploit correctness and strong algorithmic reasoning remain limited at this
|
|
419
|
+
scale and training duration.
|
|
420
|
+
|
|
421
|
+
## Related work
|
|
422
|
+
|
|
423
|
+
A 25M-parameter Transformer implementation designed to study language
|
|
424
|
+
acquisition as a condensed matter phenomenon. Unlike traditional LLMs,
|
|
425
|
+
TopoGPT-2 is engineered to reach a Topological Insulator state — a phase where
|
|
426
|
+
grammatical and logical invariants are protected by a spectral gap. Using the
|
|
427
|
+
Tiny Stories corpus:
|
|
428
|
+
|
|
429
|
+
- [https://github.com/grisuno/TopoGPT2](https://github.com/grisuno/TopoGPT2)
|
|
430
|
+
|
|
431
|
+
The ExploitGym benchmark used for training:
|
|
432
|
+
|
|
433
|
+
- [https://github.com/ExploitGym](https://github.com/ExploitGym)
|
|
434
|
+
|
|
435
|
+
## Citation
|
|
436
|
+
|
|
437
|
+
If you build on this work, please cite:
|
|
438
|
+
|
|
439
|
+
- [https://doi.org/10.5281/zenodo.20388757](https://doi.org/10.5281/zenodo.20388757)
|
|
440
|
+
|
|
441
|
+
```
|
|
442
|
+
grisuno, "TopoExploit: Exploring Complex-Valued Representations in Small
|
|
443
|
+
Security Models", 2026.
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
## License
|
|
447
|
+
|
|
448
|
+
AGPL v3.
|
|
449
|
+
|
|
450
|
+
<<<<<<< HEAD
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
### Topo Journey
|
|
454
|
+
If you are interested in this project, explore the architecture evolution:
|
|
455
|
+
- [TopoGPT3](https://github.com/grisuno/TopoGPT3): Next evolution of the Topo model.
|
|
456
|
+
- [LazyOwn](https://github.com/grisuno/LazyOwn): RedTeam/APT framework where Topo concepts are applied.
|
|
457
|
+
|
|
458
|
+
=======
|
|
459
|
+
>>>>>>> 50c3f62 (3d awesome vieew in doc sphere and some ablation)
|
|
460
|
+
|
|
461
|
+
<!-- readmenator-kb-link -->
|
|
462
|
+
## Knowledge Base
|
|
463
|
+
|
|
464
|
+
This project has been analyzed by [ReadMenator](https://github.com/grisuno/ReadMenator),
|
|
465
|
+
a zero-token polyglot static analysis tool. Regenerate with
|
|
466
|
+
`pip install readmenator && readmenator . --rebuild`. Analysis outputs:
|
|
467
|
+
|
|
468
|
+
- **[KNOWLEDGE_BASE.md](./KNOWLEDGE_BASE.md)** -- Full architecture reference with all
|
|
469
|
+
classes, functions, imports, dependency graphs, UML class diagrams, security
|
|
470
|
+
audit findings, community analysis, taint paths, hotspots, cycles, and more.
|
|
471
|
+
- **[readmenator-agent/](./readmenator-agent/)** -- Agent-friendly, grep-optimized index.
|
|
472
|
+
- `INDEX.md` -- Quick reference: what each file does
|
|
473
|
+
- `SYMBOLS.md` -- Every symbol with file:line
|
|
474
|
+
- `ARCHITECTURE.md` -- Internal dependency pairs + external imports
|
|
475
|
+
- `API.md` -- Public function contracts
|
|
476
|
+
- `GOTCHAS.md` -- Change warnings (blast radius, cycles, hotspots)
|
|
477
|
+
- `SECURITY.md` -- Findings by severity with fix hints
|
|
478
|
+
- `MEMORY.md` -- Rules, workflow, style, deliverables, session log
|
|
479
|
+
- `MANIFEST.json` -- Freshness (git_commit + source_fingerprint) + read order
|
|
480
|
+
- `KB_<subsystem>.md` -- Per-subsystem context
|
|
481
|
+
- `recipes/*.md` -- Grounded task guides (add-function, fix-cycle, ...)
|
|
482
|
+
- **[readmenator-wiki/](./readmenator-wiki/)** -- Navigable wiki (start here for the big picture).
|
|
483
|
+
- `index.md` -- Entry point: overview, reading order, god nodes, connections
|
|
484
|
+
- `community_*.md` -- One synthesis page per code community
|
|
485
|
+
- `connections.json` -- Typed bridges between communities
|
|
486
|
+
- `queries.md` -- Suggested questions + answer log
|
|
487
|
+
- `REPORT.md` -- Honest audit: coverage, confidence, limits
|
|
488
|
+
- **[readmenator-graphrag/](./readmenator-graphrag/)** -- Zero-token GraphRAG index.
|
|
489
|
+
- `index.json` + `REPORTS.md` -- Query with `readmenator . ask "<question>"`
|
|
490
|
+
- **[readmenator-apidocs/](./readmenator-apidocs/)** -- API reference (Sphinx/Doxygen style).
|
|
491
|
+
- `index.md` + `modules/*.md` -- Signatures, parameters, returns, raises, examples, call graphs
|
|
492
|
+
- `architecture.md` -- Tiered architecture + execution flows (control flow, call tree, sequence)
|
|
493
|
+
- `classes.md`, `genindex.md`, `COVERAGE.md` -- Hierarchy, A-Z index, doc coverage + warnings
|
|
494
|
+
- `index.html` + `api/` -- Offline searchable browser and machine-readable model (`api/index.json`, `api/modules/*.jsonl` one entity per line)
|
|
495
|
+
- **[readmenator-maps/](./readmenator-maps/)** -- Interactive gallery (`index.html`).
|
|
496
|
+
- 5 system maps: architecture, workflow, sequence, dataflow, lifecycle
|
|
497
|
+
- `graph-force.html` -- Force-graph explorer (2D/3D, reach, paths, lenses)
|
|
498
|
+
- `graph-bundle.html` -- Edge bundle explorer (circle + sphere)
|
|
499
|
+
- `components.html` -- Component diagrams
|
|
500
|
+
- **[docs/](./docs/)** -- Static site (GitHub Pages ready).
|
|
501
|
+
- Gallery copy + `llms.txt` (agent entry point) + `md/` docs + video
|
|
502
|
+
- **[readmenator-diagrams/](./readmenator-diagrams/)** -- Component diagrams.
|
|
503
|
+
- `analysis.json` + `graph LR` markdown + per-component pages + `index.html`
|
|
504
|
+
- **[readmenator-rules/](./readmenator-rules/)** -- Suggested Semgrep rules (`*.yml`),
|
|
505
|
+
`yara_rules.yar` (YARA-lite) + `exclusions.yaml` (false-positive blocklist)
|
|
506
|
+
- **[readmenator.mp4](./readmenator.mp4)** -- Cinematic synthwave overview video
|
|
507
|
+
- **[.cursorrules](./.cursorrules)** -- Generated AI assistant rules
|
|
508
|
+
- **[readmenator_audit.sarif](./readmenator_audit.sarif)** -- SARIF v2.1.0 audit (when security scan is on)
|
|
509
|
+
|
|
510
|
+
Cache (`.readmenator_cache/`), packaged agent skills (`.claude/skills/`), and the
|
|
511
|
+
GitHub wiki mirror are also produced on `run`/`--rebuild`.
|
|
512
|
+
|
|
513
|
+
AI agents: Read `readmenator-wiki/index.md` first for the big picture, then `readmenator-agent/INDEX.md` for grep-friendly lookup.
|
|
514
|
+
Developers: Read `KNOWLEDGE_BASE.md` for full architecture reference, open `readmenator-maps/index.html` for the visual gallery.
|
|
515
|
+
<!-- /readmenator-kb-link -->
|
|
516
|
+
|
|
517
|
+
<!-- deploynator-footer -->
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
Deployed with [deploynator](https://github.com/grisuno/deploynator)
|
|
522
|
+
|
|
523
|
+
<!-- /deploynator-footer -->
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
topoexploit-0.1.0.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
|
2
|
+
topogpt3/__init__.py,sha256=C9bdpdHixfcEjMH6lKEM49IBZrF6YvlcR-LnYYQKJJ4,3284
|
|
3
|
+
topogpt3/__main__.py,sha256=glBegCokjJcM3awATP6ratxt-6Pk1crS9tsBunyDDLU,1832
|
|
4
|
+
topogpt3/api_server.py,sha256=MhZZB2EhS9zimygBTAw20e4eAFrlkFC3m2aLy8TC6NY,45534
|
|
5
|
+
topogpt3/continuation.py,sha256=BBMgSqn0ojeQZpEgt1ECJtxsBpGrPKL0zT0WVpPgwYA,3222
|
|
6
|
+
topogpt3/ewc.py,sha256=kQUtppQZh6VcXHW2qMZLHUMltbfKxvIjbHsRchPiovE,12902
|
|
7
|
+
topogpt3/exploitgym_config.py,sha256=NG9rWRfp2dhUZ67NiHhmfkyj-WIQKsmyBSnmDzTErSw,4230
|
|
8
|
+
topogpt3/exploitgym_loader.py,sha256=wkP3sxpf_VlFtB1F-T0ggrFEu5Wc3bnyTz6dYhQYXIg,15580
|
|
9
|
+
topogpt3/hodge_cm.py,sha256=9SLPkYqw3YswAtWU8dmjIsUqM089GUpcJZefHOdJjuo,5748
|
|
10
|
+
topogpt3/inference.py,sha256=MdO0CbA3u_QdMaVFaBCNUi2LIqq999rjy6FMK1pSVoo,27335
|
|
11
|
+
topogpt3/inference_hrm.py,sha256=1xU1vWSobkCc7KaqnTLY6zCHX8R8Wpo-94254BmQkyE,62336
|
|
12
|
+
topogpt3/jlens.py,sha256=MalmL2wTXHqTYuDgm30VZ6rVfTDyvvi4jbLwR34t-Q4,34653
|
|
13
|
+
topogpt3/lens_model.py,sha256=z1yVkCxSbjhrTFWPFGMmdQObMgCE7WYlFrJgLMqHHOo,13417
|
|
14
|
+
topogpt3/merged_config.py,sha256=eYmMjOk5sfg573PKelfYEJ7YWhs7Sh4lauZCmlmv-4s,6819
|
|
15
|
+
topogpt3/model.py,sha256=lVShuqWa-Y2mgpZUR1AMqYO_620xOdo_7gB0PMF-cL4,159651
|
|
16
|
+
topogpt3/structured_output.py,sha256=eYMnMKGisbbEUw33RRFQorfpCmzJYGj_DnzWvYqyQUA,9098
|
|
17
|
+
topogpt3/train.py,sha256=3z70i6H7N9vF8Ka4VZV4JaWIt98PN02_nzYEWrqEP6g,83652
|
|
18
|
+
topogpt3/vanilla_control.py,sha256=Wab1BCKM9DVh9RjOYxdSdsn1CJnrXcuPRr3r0aZqUOc,9813
|
|
19
|
+
topoexploit-0.1.0.dist-info/METADATA,sha256=x1knvU0abqKUDJrBLQ7gvX-Iz_uMGAq74X-YrvEUFTI,22215
|
|
20
|
+
topoexploit-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
21
|
+
topoexploit-0.1.0.dist-info/entry_points.txt,sha256=tyVyYQozcAf01_hT-MPTvIuAu1C7dved5C3UaEuYtJc,229
|
|
22
|
+
topoexploit-0.1.0.dist-info/top_level.txt,sha256=9TksQMQrSlsnTDcgyh9EVJCeMIi-v0Ibbxil3ncVJtY,9
|
|
23
|
+
topoexploit-0.1.0.dist-info/RECORD,,
|