Taylor commited on
Commit
16078d7
·
0 Parent(s):

fix: remove emojis from UI text

Browse files
Files changed (3) hide show
  1. README.md +23 -0
  2. app.py +171 -0
  3. requirements.txt +1 -0
README.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Glossolalia Examples
3
+ emoji: 🔬
4
+ colorFrom: green
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: 5.23.0
8
+ python_version: 3.12
9
+ app_file: app.py
10
+ pinned: false
11
+ license: mit
12
+ ---
13
+
14
+ # Glossolalia Examples — A/B Comparison Gallery
15
+
16
+ Pre-computed outputs from TinyLlama-1.1B showing the difference between standard
17
+ top-k/top-p sampling and Glossolalia fork/race/fold decoder on the same prompts.
18
+
19
+ **The model is the brain. Glossolalia is the voice.**
20
+
21
+ Loads instantly — no API calls needed.
22
+
23
+ [Paper](https://forkracefold.com) | [Source](https://github.com/forkjoin-ai/aether) | [Live Demo](https://huggingface.co/spaces/forkjoin-ai/glossolalia-engine)
app.py ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Glossolalia Examples — Curated A/B Comparison Gallery
3
+
4
+ Pre-computed outputs showing Glossolalia fork/race/fold vs standard
5
+ sampling on the same model (TinyLlama-1.1B) and prompt. Every example
6
+ is a real output from the production Aether coordinator on Cloud Run.
7
+
8
+ No API calls needed — loads instantly.
9
+ """
10
+
11
+ import gradio as gr
12
+
13
+ # Pre-computed results from TinyLlama-1.1B on Cloud Run (v91)
14
+ # Each entry: (prompt, standard_output, glossolalia_output, standard_time, glossolalia_time)
15
+ EXAMPLES = [
16
+ {
17
+ "prompt": "What is the shape of failure?",
18
+ "standard": "\\treturn err\\n}\\n```</s>",
19
+ "glossolalia": "The shape of failure is a complex and ever-",
20
+ "standard_time": "25s",
21
+ "glossolalia_time": "192s",
22
+ "analysis": "Standard sampling returns a Go error handler -- syntactically valid code but semantically disconnected from the prompt. Glossolalia produces a philosophical continuation that treats failure as having shape, complexity, and ongoing process. The fork/race/fold topology suppresses high-frequency memorized patterns (code) and elevates tokens with broad distributional support (natural language).",
23
+ },
24
+ {
25
+ "prompt": "Hello",
26
+ "standard": "I'm glad to",
27
+ "glossolalia": "'s friend",
28
+ "standard_time": "135s",
29
+ "glossolalia_time": "47s",
30
+ "analysis": "Both produce English continuations. Standard gives a common greeting pattern. Glossolalia takes a less predictable path -- 'Hello's friend' suggests a personification or narrative framing. The temperature-ensemble agents at different temperatures explore both the obvious and the unexpected, and the deficit-weighted merge preserves the less obvious path when it has multi-agent support.",
31
+ },
32
+ {
33
+ "prompt": "The theory of failure is",
34
+ "standard": "based on two main components of an argument for which is that it has been used in order to explain why people do not have this kind and how we are all",
35
+ "glossolalia": "based on two main components of an argument for which is that it has been used in order to explain why people do not have this kind and how we are all",
36
+ "standard_time": "190s",
37
+ "glossolalia_time": "190s",
38
+ "analysis": "Both paths converge to similar output for this prompt. When the model's probability distribution is strongly peaked (high-confidence tokens), all three temperature agents agree and the deficit-weighted merge produces the same result as standard sampling. Convergence is expected: Glossolalia differs most when the distribution is flat (uncertain) and agents disagree.",
39
+ },
40
+ ]
41
+
42
+
43
+ def display_example(idx):
44
+ """Display a pre-computed example."""
45
+ ex = EXAMPLES[idx]
46
+ return (
47
+ ex["prompt"],
48
+ ex["standard"],
49
+ f"*Standard top-k/top-p* | {ex['standard_time']}",
50
+ ex["glossolalia"],
51
+ f"*Glossolalia fork/race/fold* | {ex['glossolalia_time']}",
52
+ ex["analysis"],
53
+ )
54
+
55
+
56
+ with gr.Blocks(
57
+ title="Glossolalia Examples",
58
+ theme=gr.themes.Base(primary_hue="teal"),
59
+ ) as demo:
60
+ gr.Markdown("""
61
+ # Glossolalia Engine — A/B Comparison Gallery
62
+
63
+ Real outputs from TinyLlama-1.1B on Google Cloud Run. Same model, same weights, same prompt.
64
+ The only difference: how tokens are sampled from the logit distribution.
65
+
66
+ **Standard**: top-k/top-p nucleus sampling (pick the most probable token)
67
+
68
+ **Glossolalia**: FORK 3 agents at different temperatures → RACE (filter NaN) → FOLD (deficit-weighted Buleyean complement merge). Tokens survive by *not being rejected* rather than by being any single agent's top pick.
69
+
70
+ *The model is the brain. Glossolalia is the voice.*
71
+
72
+ [Paper: Being Irreversible, section 8.4](https://forkracefold.com) |
73
+ [Source](https://github.com/forkjoin-ai/aether) |
74
+ [Live Demo](https://huggingface.co/spaces/forkjoin-ai/glossolalia-engine) (calls Cloud Run, slow but real)
75
+ """)
76
+
77
+ # Example selector
78
+ example_buttons = []
79
+ with gr.Row():
80
+ for i, ex in enumerate(EXAMPLES):
81
+ btn = gr.Button(
82
+ f'"{ex["prompt"][:30]}..."' if len(ex["prompt"]) > 30 else f'"{ex["prompt"]}"',
83
+ size="sm",
84
+ )
85
+ example_buttons.append((btn, i))
86
+
87
+ # Display area
88
+ prompt_display = gr.Textbox(label="Prompt", interactive=False)
89
+
90
+ with gr.Row():
91
+ with gr.Column():
92
+ gr.Markdown("### Standard Sampling")
93
+ standard_display = gr.Textbox(label="Output", lines=4, interactive=False)
94
+ standard_meta = gr.Markdown()
95
+ with gr.Column():
96
+ gr.Markdown("### Glossolalia (fork/race/fold)")
97
+ glossolalia_display = gr.Textbox(label="Output", lines=4, interactive=False)
98
+ glossolalia_meta = gr.Markdown()
99
+
100
+ analysis_display = gr.Markdown(label="Analysis")
101
+
102
+ # Wire up buttons
103
+ for btn, idx in example_buttons:
104
+ btn.click(
105
+ lambda i=idx: display_example(i),
106
+ outputs=[
107
+ prompt_display,
108
+ standard_display,
109
+ standard_meta,
110
+ glossolalia_display,
111
+ glossolalia_meta,
112
+ analysis_display,
113
+ ],
114
+ )
115
+
116
+ # Load first example by default
117
+ demo.load(
118
+ lambda: display_example(0),
119
+ outputs=[
120
+ prompt_display,
121
+ standard_display,
122
+ standard_meta,
123
+ glossolalia_display,
124
+ glossolalia_meta,
125
+ analysis_display,
126
+ ],
127
+ )
128
+
129
+ gr.Markdown("""
130
+ ---
131
+
132
+ ### How Glossolalia Works
133
+
134
+ At each token position, the model produces a vector of logits (one per vocabulary token).
135
+ Standard sampling applies softmax, top-k filtering, nucleus (top-p) filtering, then samples.
136
+ Glossolalia replaces this with:
137
+
138
+ ```
139
+ FORK: 3 agents apply temperatures {τ-0.3, τ, τ+0.3} to the same logits
140
+ RACE: filter agents with NaN/Inf distributions
141
+ FOLD: for each candidate token:
142
+ count agents that "accept" it (logit ≥ agent mean)
143
+ complement weight = (accepts + 1) / (agents + 1)
144
+ merged logit = mean(agent logits) × complement weight
145
+ ```
146
+
147
+ The key insight: standard sampling asks "which token is most probable?"
148
+ Glossolalia asks "which token do multiple perspectives agree is acceptable?"
149
+
150
+ This is **Buleyean complement voting** -- tokens survive by not being rejected,
151
+ not by being any single agent's top pick. The deficit = k-1 exactly
152
+ (proved in Lean 4).
153
+
154
+ ### Why It Works
155
+
156
+ A 1.1B parameter model trained on code + text memorizes high-frequency patterns.
157
+ Standard sampling at temperature 0.8 often selects these memorized patterns
158
+ (code fragments, closing tags, common subwords). The conservative agent (τ=0.5)
159
+ strongly favors these patterns. The exploratory agent (τ=1.1) strongly disfavors them.
160
+ The deficit-weighted fold averages across perspectives, suppressing tokens that only
161
+ one agent favors and elevating tokens with broad support. Broad support correlates
162
+ with semantic coherence -- natural language has wider distributional support than
163
+ memorized code patterns.
164
+
165
+ *Running on self-hosted CPU inference. Zero GPU cost. Zero external API calls.
166
+ Model weights loaded from Google Cloud Storage, inference on Cloud Run.*
167
+ """)
168
+
169
+
170
+ if __name__ == "__main__":
171
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio>=5.0.0