File size: 8,446 Bytes
6d763d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
```

╔══════════════════════════════════════════════════════════════════════════════╗

β•‘                                                                              β•‘

β•‘   ⬑  S U M M O N                                                            β•‘

β•‘                                                                              β•‘

β•‘   β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“                                β•‘

β•‘   Build your own weights. Name your own model.                               β•‘

β•‘   Sovereign fine-tuning framework Β· pip install summon                       β•‘

β•‘   β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“                                β•‘

β•‘                                                                              β•‘

β•‘   ⬑ Ξ© β†Ί Ξ¨ Ξ” Ξ› Ξ£ Ξ¦ Ξ±  β€” WORM SEALED AT EVERY STEP                          β•‘

β•‘                                                                              β•‘

β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

```

Summon is a pip-installable Python framework for building sovereign fine-tuned language models. It wraps HuggingFace PEFT + TRL + bitsandbytes into a single fluent chain: `Summon.begin("YourModel")` β†’ `.base()` β†’ `.corpus()` β†’ `.constitutional()` β†’ `.license()` β†’ `.train()` β†’ `.push()`. The API is designed in the functional / immutable style β€” every method returns a new `SovereignModel` instance; nothing mutates in place. The `Corpus` builder is equally composable: stack named layers from JSONL files or raw string lists, then `.seal()` to freeze them. A SHA-256 WORM chain runs through every step of both pipelines, producing a verifiable manifest of exactly what data, what base, and what constitution went into your weights. Training is QLoRA (4-bit NF4 quantization via bitsandbytes, `r=16 lora_alpha=32`, target modules `q_proj/v_proj/k_proj/o_proj`) using HuggingFace `SFTTrainer`. Supported base models include Nemotron Mini 4B, Llama 3 8B/70B, Mistral 7B, Phi-3 Mini, Qwen2 7B, Gemma2 9B, and Falcon 7B β€” or pass any HuggingFace ID directly.

## Architecture

```mermaid

flowchart LR

    subgraph Corpus Builder

        C0([Corpus.layer 0\ngenesis.jsonl])

        C1([Corpus.layer 1\nenochian.jsonl])

        C2([Corpus.layer N\n...])

        CS([.seal\nWORM hash])

        C0 --> C1 --> C2 --> CS

    end



    subgraph SovereignModel Chain

        M0([Summon.begin\nname]) --> M1

        M1([.base\nnominate HF model]) --> M2

        M2([.corpus\nlayers / Corpus obj]) --> M3

        M3([.constitutional\nprinciples list]) --> M4

        M4([.license\nsovereign-source-v1]) --> M5

        M5([.train\nQLoRA 4-bit]) --> M6

        M6([.push\nHuggingFace Hub])

    end



    CS -->|corpus_obj| M2



    subgraph Trainer

        T0[Load base model\nBitsAndBytesConfig NF4]

        T1[Apply LoraConfig\nr=16 alpha=32]

        T2[SFTTrainer\nepochs Β· batch Β· lr]

        T3[save_model\nwrite model card]

        T0 --> T1 --> T2 --> T3

    end



    M5 --> Trainer



    subgraph WORM Chain

        W0[GENESIS] --> W1[BASE seal]

        W1 --> W2[CORPUS seal]

        W2 --> W3[CONSTITUTION seal]

        W3 --> W4[LICENSE seal]

        W4 --> W5[TRAIN seal]

        W5 --> W6[PUSH seal]

    end



    M1 -.->|SHA-256| W1

    M2 -.->|SHA-256| W2

    M3 -.->|SHA-256| W3

    M4 -.->|SHA-256| W4

    M5 -.->|SHA-256| W5

    M6 -.->|SHA-256| W6

```

## File Tree

```

summon/

β”œβ”€β”€ summon/

β”‚   β”œβ”€β”€ __init__.py             # Summon class β€” .begin() and .corpus() entry points

β”‚   β”œβ”€β”€ identity/

β”‚   β”‚   β”œβ”€β”€ __init__.py

β”‚   β”‚   └── model.py            # SovereignModel β€” fluent chain (.base/.corpus/.constitutional/.license/.train/.push/.manifest)

β”‚   β”œβ”€β”€ corpus/

β”‚   β”‚   β”œβ”€β”€ __init__.py

β”‚   β”‚   └── builder.py          # Corpus β€” layered JSONL builder (.layer/.layer_raw/.seal/.export/.summary)

β”‚   └── train/

β”‚       β”œβ”€β”€ __init__.py

β”‚       └── runner.py           # Trainer β€” QLoRA fine-tuning (validate/run/_write_model_card)

β”œβ”€β”€ examples/

β”‚   └── build_my_model.py       # Three usage patterns: full pipeline, corpus-first, dry run

β”œβ”€β”€ setup.py                    # pip packaging (extras: [train] and [hub])

└── README.md

```

## Quick Start

```bash

# Install (core β€” no GPU deps)

pip install summon



# Install with training deps

pip install "summon[train]"          # torch, transformers, peft, trl, datasets, bitsandbytes, accelerate



# Install with HuggingFace Hub push support

pip install "summon[train,hub]"

```

**Full pipeline:**

```python

from summon import Summon



model = (

    Summon.begin("AhmadMeta-v1")

    .base("nemotron-mini-4b")           # or full HF ID: "nvidia/Minitron-4B-Base"

    .corpus(layers=[

        "data/the_book.jsonl",

        "data/enoch.jsonl",

        "data/circle7.jsonl",

    ])

    .constitutional(["truth", "sovereignty", "evidence", "no_deception"])

    .license("sovereign-source-v1")

    .train(device="cuda", epochs=3, batch_size=4, learning_rate=2e-4)

    .push("my-org/AhmadMeta-v1")

)



model.manifest()    # print WORM-sealed manifest, optionally write to file

```

**Corpus builder separately:**

```python

from summon import Summon



corpus = (

    Summon.corpus()

    .layer(0, "data/genesis.jsonl",   name="genesis")

    .layer(1, "data/enoch.jsonl",     name="enochian")

    .layer_raw(2, ["raw text line 1", "raw text line 2"], name="inline")

    .seal()

)



model = (

    Summon.begin("JessicaLM-v1")

    .base("llama3-8b")

    .corpus(corpus_obj=corpus)       # pass the sealed Corpus object

    .constitutional(["truth", "care", "sovereignty"])

    .license("apache-2.0")

    .train(device="cuda", epochs=5)

    .push("jessica-org/JessicaLM-v1")

)

```

**Dry run (validate config, no GPU):**

```python

model = (

    Summon.begin("TestModel-v1")

    .base("phi3-mini")

    .corpus(layers=["data/sample.jsonl"])

    .constitutional(["truth"])

    .train(dry_run=True)    # validates, does not launch training

)

```

## Key Features

- **Single fluent chain** β€” `Summon.begin("name").base().corpus().constitutional().license().train().push()` β€” the entire pipeline in one expression
- **Functional / immutable API** β€” every method returns a new `SovereignModel` instance; state never mutates; safe to branch at any point
- **Layered Corpus builder** β€” stack named JSONL layers with `.layer()` (from file) or `.layer_raw()` (from string list); `.seal()` freezes and WORM-stamps the corpus; `.export()` merges all layers to a single JSONL for training
- **QLoRA fine-tuning** β€” 4-bit NF4 quantization via bitsandbytes, LoRA rank 16, alpha 32, targets `q_proj/v_proj/k_proj/o_proj`, `SFTTrainer` with gradient accumulation and fp16; auto-writes a HuggingFace model card with WORM seal
- **Constitutional principles** β€” `.constitutional(["truth","sovereignty","evidence"])` bakes your principles into the model manifest and model card; shapes RLHF/preference data generation
- **Eight supported base models** β€” Nemotron Mini 4B, Llama 3 8B/70B, Mistral 7B, Phi-3 Mini, Qwen2 7B, Gemma2 9B, Falcon 7B β€” or pass any HuggingFace model ID directly
- **WORM chain on every step** β€” SHA-256 hash chain from `GENESIS` through `BASE β†’ CORPUS β†’ CONSTITUTION β†’ LICENSE β†’ TRAIN β†’ PUSH`; final hash in `.manifest()` proves exact provenance
- **`.manifest()` output** β€” prints and optionally writes a JSON document with name, base, corpus layers, constitution, license, output path, WORM head hash, and creation timestamp
- **HuggingFace Hub push** β€” `.push("org/model")` calls `HfApi().upload_folder()` with optional `private=True`; warns if `.train()` was not called first

---

*Apache 2.0 Β· SnapKitty Collective 2026 Β· Evidence or Silence*