WFGY/gradio_app.py
2025-06-15 13:23:24 +08:00

50 lines
2.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
╭──────────────────────────────────────────────────────────╮
│ WFGY SDK · Self-Healing Variance Gate for Any LLM │
│----------------------------------------------------------│
│ 💌 Contact : hello@onestardao.com / TG @PSBigBig │
│ 🌐 Docs : https://onestardao.com/papers │
│ 🐙 GitHub : https://github.com/onestardao/WFGY │
│ │
│ ★ Star WFGY 1.0 → Unlock 2.0 │
│ 10k ⭐ by **Aug 1st** = next-gen AI alchemy │
│ Your click = our quantum leap │
│ │
│ 🔍 Official PDF of WFGY 1.0 (Zenodo DOI): │
│ https://doi.org/10.5281/zenodo.15630969 │
│ (Hosted on Zenodo trusted international archive) │
│ │
│ 🧬 WFGY BigBang Prompt Pack (v1.0): │
│ https://doi.org/10.5281/zenodo.15657016 │
│ (Prompts to trigger the gate; multilingual updates coming) │
│ │
│ 🧠 Hidden folder inside repo: /I_am_not_lizardman │
│ (X secret papers, wild prompts, and Einstein drama) │
│ │
│ ⚠ GPT-2 demo is just the appetizer. With bigger LLMs, │
│ WFGY activates variance-drop lasers and KL fireworks. │
│ │
│ 🎮 Bonus: Honest Hero RPG Channel → │
│ https://www.youtube.com/@OneStarDao │
╰──────────────────────────────────────────────────────────╯
"""
import wfgy_sdk as w, numpy as np, gradio as gr
from wfgy_sdk.evaluator import compare_logits, pretty_print
def run_wfgy(prompt):
logits = w.call_remote_model(prompt, model_id="gpt2")
G = np.random.randn(128); G /= np.linalg.norm(G)
I = G + np.random.normal(scale=0.05, size=128)
out = w.get_engine().run(input_vec=I, ground_vec=G, logits=logits)
m = compare_logits(logits, out)
delta = (1 - m["std_ratio"]) * 100
return f"variance drop {delta:.0f}% • KL {m['kl_divergence']:.2f}"
demo = gr.Interface(fn=run_wfgy,
inputs=gr.Textbox(),
outputs="textbox",
title="WFGY Quick Test",
description="Type any prompt. GPT-2 baseline, variance/KL will appear.")
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860)