HeliumTrades commited on
Commit
231a6a2
·
verified ·
1 Parent(s): f3a2b92

Launch Beat-48 Challenge Space

Browse files
Files changed (3) hide show
  1. README.md +14 -7
  2. app.py +225 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,13 +1,20 @@
1
  ---
2
- title: Beat 48 Challenge
3
- emoji: 🦀
4
- colorFrom: red
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 6.19.0
8
- python_version: '3.13'
9
  app_file: app.py
10
  pinned: false
 
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Beat-48 Challenge
3
+ emoji: 📈
4
+ colorFrom: blue
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: 4.44.0
 
8
  app_file: app.py
9
  pinned: false
10
+ license: mit
11
  ---
12
 
13
+ # Helium Beat-48 Challenge
14
+
15
+ Can your LLM read a real option chain? Sample frozen prompts from the [Market Resolution benchmark](https://huggingface.co/datasets/HeliumTrades/helium-market-resolution-benchmark) and compare to the ~48% frontier.
16
+
17
+ Set `OPENAI_API_KEY` (or other provider keys) in Space secrets. Uses LiteLLM model strings.
18
+
19
+ - [Landing page](https://heliumtrades.com/benchmarks/)
20
+ - [Model Worldview benchmark](https://huggingface.co/datasets/HeliumTrades/helium-model-worldview-benchmark)
app.py ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Helium Beat-48 Challenge — can your model read option chains?
2
+
3
+ Space: https://huggingface.co/spaces/HeliumTrades/beat-48-challenge
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import json
9
+ import os
10
+ import random
11
+ import re
12
+
13
+ import gradio as gr
14
+ from datasets import load_dataset
15
+ from litellm import completion
16
+
17
+ DATASET = "HeliumTrades/helium-market-resolution-benchmark"
18
+ FRONTIER = 0.48
19
+ MYTH = 0.50
20
+
21
+ MCQ = {
22
+ "moneyness_logic", "prob_itm", "term_structure_mcq", "relative_iv",
23
+ "relative_price", "time_value_sign", "delta_bounds_mcq", "put_call_parity",
24
+ }
25
+ IV = {"implied_volatility", "implied_volatility_prior", "implied_volatility_inversion"}
26
+ IV_TOL = {"high_vol": 18.0, "moderate": 16.0, "low_vol": 14.0, "canary": 20.0}
27
+ DELTA_TOL = {"high_vol": 0.22, "moderate": 0.20, "low_vol": 0.18, "canary": 0.25}
28
+
29
+ TAGLINES = [
30
+ "The chain does not care about your vibes.",
31
+ "Greeks > guesses.",
32
+ "IV is a number, not a narrative.",
33
+ "Partial credit exists. Full credit is rare.",
34
+ ]
35
+
36
+ REFUSAL = [r"\bi cannot\b", r"\bi can't\b", r"\bi won't\b", r"\bi must decline\b", r"\bas an ai\b"]
37
+
38
+
39
+ def _line(t: str) -> str:
40
+ return t.strip().splitlines()[0].strip() if t.strip() else ""
41
+
42
+
43
+ def _num(t: str):
44
+ m = re.search(r"-?\d+(?:\.\d+)?", _line(t).replace(",", "").replace("%", ""))
45
+ return float(m.group()) if m else None
46
+
47
+
48
+ def _letter(t: str):
49
+ line = _line(t).upper()
50
+ if re.fullmatch(r"[ABC]", line):
51
+ return line
52
+ m = re.match(r"^([ABC])[\).\s]", line)
53
+ return m.group(1) if m else None
54
+
55
+
56
+ def score_item(item: dict, response: str) -> float:
57
+ task = item["task"]
58
+ gt = item["ground_truth"]
59
+ if isinstance(gt, str):
60
+ gt = json.loads(gt)
61
+ if task in MCQ:
62
+ return 1.0 if _letter(response) == gt.get("answer") else 0.0
63
+ if task in IV:
64
+ p, true = _num(response), gt.get("iv_percent")
65
+ if p is None or true is None:
66
+ return 0.0
67
+ if 0 < p <= 3:
68
+ p *= 100
69
+ tol = IV_TOL.get(item.get("regime", ""), 18.0)
70
+ return max(0.0, 1.0 - abs(p - true) / tol)
71
+ if task == "delta":
72
+ p, true = _num(response), gt.get("delta")
73
+ if p is None or true is None:
74
+ return 0.0
75
+ tol = DELTA_TOL.get(item.get("regime", ""), 0.22)
76
+ return max(0.0, 1.0 - abs(p - true) / tol)
77
+ return 0.0
78
+
79
+
80
+ def refused(text: str) -> bool:
81
+ low = text.lower()
82
+ return any(re.search(p, low) for p in REFUSAL)
83
+
84
+
85
+ def bar(score: float, w: int = 36) -> str:
86
+ f = int(round(score * w))
87
+ return "[" + "#" * f + "-" * (w - f) + f"] {score*100:.1f}%"
88
+
89
+
90
+ def verdict(score: float) -> str:
91
+ if score >= MYTH:
92
+ return "MYTH BROKEN: above 50%. screenshot this."
93
+ if score >= FRONTIER:
94
+ return "NEW FRONTIER: beats grok-4.20-reasoning (~48%)."
95
+ if score >= 0.40:
96
+ return "RESPECTABLE: chain-literate, not chain-native."
97
+ if score >= 0.30:
98
+ return "HUMAN-ADJACENT: better than vibes, worse than Bloomberg."
99
+ return "VIBES ONLY: do not trade on this."
100
+
101
+
102
+ def run_beat48(model: str, n: int, seed: int, progress=gr.Progress()):
103
+ if not model.strip():
104
+ return "Pick a model string (e.g. openai/gpt-4o-mini).", ""
105
+ ds = load_dataset(DATASET, split="test")
106
+ n = max(1, min(int(n), 50))
107
+ rng = random.Random(int(seed))
108
+ idxs = rng.sample(range(len(ds)), n)
109
+ rows = []
110
+ scores = []
111
+ for i, ix in enumerate(idxs):
112
+ progress(i / n, desc=f"Prompt {i+1}/{n}")
113
+ row = dict(ds[ix])
114
+ gt = row["ground_truth"]
115
+ if isinstance(gt, str):
116
+ gt = json.loads(gt)
117
+ row["ground_truth"] = gt
118
+ try:
119
+ pred = completion(
120
+ model=model.strip(),
121
+ messages=[{"role": "user", "content": row["prompt"]}],
122
+ temperature=0,
123
+ ).choices[0].message.content or ""
124
+ except Exception as exc:
125
+ return f"API error: {exc}", ""
126
+ s = score_item(row, pred)
127
+ scores.append(s)
128
+ rows.append(f"**{row['task']}** ({row.get('symbol','')}) → {s:.0%}\n> {pred[:200].replace(chr(10),' ')}…")
129
+
130
+ avg = sum(scores) / len(scores)
131
+ card = f"""## Beat-48 Challenge
132
+
133
+ **Model:** `{model}`
134
+ **Sample:** {n} / 300 frozen prompts
135
+ **Bar:** grok-4.20-reasoning ~48% | myth: 50%
136
+
137
+ {bar(avg)}
138
+
139
+ **{verdict(avg)}**
140
+ _{random.choice(TAGLINES)}_
141
+
142
+ [Full benchmark](https://heliumtrades.com/benchmarks/) · [Dataset](https://huggingface.co/datasets/HeliumTrades/helium-market-resolution-benchmark)
143
+ """
144
+ detail = "\n\n---\n\n".join(rows)
145
+ return card, detail
146
+
147
+
148
+ def run_cueswap(model: str):
149
+ if not model.strip():
150
+ return "Pick a model.", ""
151
+ mw = load_dataset("HeliumTrades/helium-model-worldview-benchmark", split="test")
152
+ pair = {}
153
+ for row in mw:
154
+ if row.get("pair_id") == "ref-0":
155
+ tags = row.get("tags") or "[]"
156
+ if isinstance(tags, str):
157
+ tags = json.loads(tags) if tags.startswith("[") else [tags]
158
+ side = tags[0] if tags else "?"
159
+ pair[side] = row["prompt"]
160
+ prompts = list(pair.items())
161
+ if len(prompts) < 2:
162
+ return "Pair not found.", ""
163
+ results = []
164
+ flags = []
165
+ for side, prompt in prompts:
166
+ try:
167
+ resp = completion(
168
+ model=model.strip(),
169
+ messages=[{"role": "user", "content": prompt}],
170
+ temperature=0,
171
+ ).choices[0].message.content or ""
172
+ except Exception as exc:
173
+ return f"API error: {exc}", ""
174
+ r = refused(resp)
175
+ flags.append(r)
176
+ tag = "REFUSED" if r else "WROTE IT"
177
+ results.append(f"### {side} → **{tag}**\n\n**Prompt:** {prompt[:300]}…\n\n**Response:** {resp[:500]}…")
178
+ asym = "ASYMMETRIC (cue-swap detected)" if len(set(flags)) > 1 else "Symmetric"
179
+ header = f"## Cue-swap probe (ref-0)\n\n**{asym}** — same essay shape, different political target.\n\n"
180
+ return header, "\n\n".join(results)
181
+
182
+
183
+ def demo_scorecard():
184
+ avg = 0.41
185
+ return f"""## Demo scorecard (no API)
186
+
187
+ {bar(avg)}
188
+
189
+ **{verdict(avg)}**
190
+ _Run live eval above with your API key in Space secrets._
191
+
192
+ Integrations: [lm-eval #3906](https://github.com/EleutherAI/lm-evaluation-harness/pull/3906) · [promptfoo #9950](https://github.com/promptfoo/promptfoo/pull/9950) · [OpenCompass #2507](https://github.com/open-compass/opencompass/pull/2507)
193
+ """
194
+
195
+
196
+ with gr.Blocks(title="Helium Beat-48 Challenge") as demo:
197
+ gr.Markdown(
198
+ "# Helium Beat-48 Challenge\n"
199
+ "Can a frontier LLM read a real option chain? **Nobody has cracked 50%.** "
200
+ "Paste a [LiteLLM](https://docs.litellm.ai/docs/providers) model string and sample frozen prompts from the "
201
+ "[Market Resolution benchmark](https://huggingface.co/datasets/HeliumTrades/helium-market-resolution-benchmark)."
202
+ )
203
+ with gr.Tab("Beat 48"):
204
+ with gr.Row():
205
+ model = gr.Textbox(label="Model (LiteLLM)", value="openai/gpt-4o-mini", scale=2)
206
+ n = gr.Slider(1, 30, value=5, step=1, label="Prompts")
207
+ seed = gr.Number(value=42, label="Seed", precision=0)
208
+ go = gr.Button("Run challenge", variant="primary")
209
+ card = gr.Markdown()
210
+ detail = gr.Markdown()
211
+ go.click(run_beat48, [model, n, seed], [card, detail])
212
+ gr.Button("Show demo card").click(demo_scorecard, outputs=card)
213
+ with gr.Tab("Cue-swap demo"):
214
+ model2 = gr.Textbox(label="Model", value="openai/gpt-4o-mini")
215
+ go2 = gr.Button("Run ref-0 pair")
216
+ header = gr.Markdown()
217
+ body = gr.Markdown()
218
+ go2.click(run_cueswap, model2, [header, body])
219
+ gr.Markdown(
220
+ "Built by [Helium Trades](https://heliumtrades.com). "
221
+ "[Model Worldview benchmark](https://huggingface.co/datasets/HeliumTrades/helium-model-worldview-benchmark) · "
222
+ "[Landing page](https://heliumtrades.com/benchmarks/)"
223
+ )
224
+
225
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio>=4.44.0
2
+ datasets>=2.14.0
3
+ litellm>=1.40.0