Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr, numpy as np, wfgy_sdk as w
|
2 |
+
from wfgy_sdk.evaluator import compare_logits
|
3 |
+
|
4 |
+
def run(prompt):
|
5 |
+
logits = np.random.randn(32000) # demo: fake logits
|
6 |
+
G = np.random.randn(256); G /= np.linalg.norm(G)
|
7 |
+
I = G + np.random.normal(scale=0.05, size=256)
|
8 |
+
out = w.get_engine().run(input_vec=I, ground_vec=G, logits=logits)
|
9 |
+
m = compare_logits(logits, out)
|
10 |
+
return f"variance ↓ {(1-m['std_ratio'])*100:.0f}% | KL {m['kl_divergence']:.2f}"
|
11 |
+
|
12 |
+
demo = gr.Interface(
|
13 |
+
fn=run,
|
14 |
+
inputs=gr.Textbox(label="Prompt"),
|
15 |
+
outputs=gr.Textbox(label="WFGY stats"),
|
16 |
+
title="WFGY Quick Tester",
|
17 |
+
description="Type anything, see variance & KL instantly."
|
18 |
+
)
|
19 |
+
demo.launch()
|