SNAPKITTYWEST commited on
Commit
1867bb7
·
verified ·
1 Parent(s): 24582c8

add README.md

Browse files
Files changed (1) hide show
  1. README.md +71 -0
README.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sovereign XML Compiler
2
+
3
+ **Natural language → valid XML system prompts in one shot. Zero correction iterations.**
4
+
5
+ Three modes using logit gating at the tokenization layer:
6
+
7
+ ## Modes
8
+
9
+ ### 1. GBNF Constrained Decoding (best)
10
+ Uses llama.cpp grammar-based sampling. The model **physically cannot** output invalid XML.
11
+ Token selection at the softmax layer is masked to enforce the grammar.
12
+ Result: 100% valid XML, zero syntax errors, one pass.
13
+
14
+ ```bash
15
+ # Requires llama.cpp server running
16
+ export LLAMA_URL=http://localhost:8080
17
+ python server/compiler.py --mode gbnf --input "You are a Lean 4 proof verifier..."
18
+ ```
19
+
20
+ ### 2. Skeleton In-Filling
21
+ LLM only fills `{{PLACEHOLDER}}` values. Parser injects into template.
22
+ The model never writes `<` or `>` — no tag hallucination possible.
23
+
24
+ ```bash
25
+ python server/compiler.py --mode skeleton --input "You are a sovereign math agent..."
26
+ ```
27
+
28
+ ### 3. Dual-Pass Chain-of-XML
29
+ `<thought_process>` first, `<xml_output>` second.
30
+ Forces attention to compute correct structure before emitting markup.
31
+
32
+ ```bash
33
+ python server/compiler.py --mode dual-pass --input "..."
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```bash
39
+ export OLLAMA_URL=http://localhost:11434
40
+ export XML_MODEL=nemotron
41
+
42
+ python server/compiler.py --mode skeleton \
43
+ --input "You are a zero-sorry Lean 4 verifier. Reject any proof containing sorry." \
44
+ --output my_prompt.xml
45
+ ```
46
+
47
+ ## Files
48
+
49
+ | File | Purpose |
50
+ |------|---------|
51
+ | `grammars/sovereign_prompt.gbnf` | GBNF grammar for llama.cpp constrained decoding |
52
+ | `skeletons/sovereign_prompt.xml` | XML skeleton with `{{PLACEHOLDER}}` tokens |
53
+ | `server/compiler.py` | Three-mode compiler server |
54
+
55
+ ## The Gate Taxonomy
56
+
57
+ | Mode | Gate Type | Mechanism |
58
+ |------|-----------|-----------|
59
+ | GBNF | Weight-level structural gate | Token masking at softmax — invalid tokens → probability 0 |
60
+ | Skeleton | Context gate | LLM sees only leaf values, never writes tags |
61
+ | Dual-pass | Attention gate | CoT forces structure before syntax |
62
+
63
+ ## Connection to Gates Normalization
64
+
65
+ GBNF masking is `P(token | grammar) = 0` for forbidden tokens.
66
+ This is the same logit gate formalism from the Gates Normalization paper:
67
+ `G_P(D_M) = softmax(logits_M + b_P)` where `b_P = -∞` for grammar-violating tokens.
68
+ The simplex constraint holds: ∑P = 1 over the valid token set.
69
+
70
+ ## License
71
+ Sovereign Source License v2.0