Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
"""
|
| 2 |
The Void -- Buleyean RL Demo
|
| 3 |
-
LIVE inference
|
| 4 |
"""
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
from llama_cpp import Llama
|
| 8 |
from huggingface_hub import hf_hub_download
|
| 9 |
-
import os
|
| 10 |
|
| 11 |
print("Downloading Buleyean model...", flush=True)
|
| 12 |
bule_path = hf_hub_download(
|
|
@@ -14,7 +14,7 @@ bule_path = hf_hub_download(
|
|
| 14 |
filename="buleyean-smollm2-360m-q4_k_m.gguf",
|
| 15 |
cache_dir="/tmp/hf_cache",
|
| 16 |
)
|
| 17 |
-
print(f"Buleyean model
|
| 18 |
|
| 19 |
print("Downloading base model...", flush=True)
|
| 20 |
base_path = hf_hub_download(
|
|
@@ -22,12 +22,12 @@ base_path = hf_hub_download(
|
|
| 22 |
filename="SmolLM2-360M-Instruct-Q4_K_M.gguf",
|
| 23 |
cache_dir="/tmp/hf_cache",
|
| 24 |
)
|
| 25 |
-
print(f"Base model
|
| 26 |
|
| 27 |
-
print("Loading models...", flush=True)
|
| 28 |
bule_llm = Llama(model_path=bule_path, n_ctx=512, n_threads=4, verbose=False)
|
| 29 |
base_llm = Llama(model_path=base_path, n_ctx=512, n_threads=4, verbose=False)
|
| 30 |
-
print("
|
| 31 |
|
| 32 |
|
| 33 |
def generate(prompt, model):
|
|
@@ -43,7 +43,7 @@ def generate(prompt, model):
|
|
| 43 |
|
| 44 |
def compare(prompt):
|
| 45 |
if not prompt or not prompt.strip():
|
| 46 |
-
return "", ""
|
| 47 |
base_out = generate(prompt, base_llm)
|
| 48 |
bule_out = generate(prompt, bule_llm)
|
| 49 |
return base_out, bule_out
|
|
@@ -52,26 +52,35 @@ def compare(prompt):
|
|
| 52 |
with gr.Blocks(title="The Void", theme=gr.themes.Base(primary_hue="indigo")) as demo:
|
| 53 |
gr.Markdown("""# The Void -- Buleyean RL
|
| 54 |
|
| 55 |
-
**Live inference. Every response generated in real-time
|
| 56 |
|
| 57 |
-
|
| 58 |
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
| 60 |
""")
|
| 61 |
-
prompt = gr.Textbox(label="Your prompt", lines=2, placeholder="Type anything...")
|
| 62 |
-
btn = gr.Button("Generate (live)", variant="primary")
|
| 63 |
with gr.Row():
|
| 64 |
with gr.Column():
|
| 65 |
-
gr.Markdown("### Base
|
| 66 |
-
base_out = gr.Textbox(lines=
|
| 67 |
with gr.Column():
|
| 68 |
-
gr.Markdown("### Buleyean-Trained
|
| 69 |
-
bule_out = gr.Textbox(lines=
|
|
|
|
| 70 |
btn.click(compare, [prompt], [base_out, bule_out])
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
if __name__ == "__main__":
|
| 77 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
"""
|
| 2 |
The Void -- Buleyean RL Demo
|
| 3 |
+
LIVE inference only. Every response generated in real-time.
|
| 4 |
"""
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
from llama_cpp import Llama
|
| 8 |
from huggingface_hub import hf_hub_download
|
| 9 |
+
import os, sys
|
| 10 |
|
| 11 |
print("Downloading Buleyean model...", flush=True)
|
| 12 |
bule_path = hf_hub_download(
|
|
|
|
| 14 |
filename="buleyean-smollm2-360m-q4_k_m.gguf",
|
| 15 |
cache_dir="/tmp/hf_cache",
|
| 16 |
)
|
| 17 |
+
print(f"Buleyean model ready.", flush=True)
|
| 18 |
|
| 19 |
print("Downloading base model...", flush=True)
|
| 20 |
base_path = hf_hub_download(
|
|
|
|
| 22 |
filename="SmolLM2-360M-Instruct-Q4_K_M.gguf",
|
| 23 |
cache_dir="/tmp/hf_cache",
|
| 24 |
)
|
| 25 |
+
print(f"Base model ready.", flush=True)
|
| 26 |
|
| 27 |
+
print("Loading models into memory...", flush=True)
|
| 28 |
bule_llm = Llama(model_path=bule_path, n_ctx=512, n_threads=4, verbose=False)
|
| 29 |
base_llm = Llama(model_path=base_path, n_ctx=512, n_threads=4, verbose=False)
|
| 30 |
+
print("Both models loaded. Live inference ready.", flush=True)
|
| 31 |
|
| 32 |
|
| 33 |
def generate(prompt, model):
|
|
|
|
| 43 |
|
| 44 |
def compare(prompt):
|
| 45 |
if not prompt or not prompt.strip():
|
| 46 |
+
return "Please enter a prompt.", "Please enter a prompt."
|
| 47 |
base_out = generate(prompt, base_llm)
|
| 48 |
bule_out = generate(prompt, bule_llm)
|
| 49 |
return base_out, bule_out
|
|
|
|
| 52 |
with gr.Blocks(title="The Void", theme=gr.themes.Base(primary_hue="indigo")) as demo:
|
| 53 |
gr.Markdown("""# The Void -- Buleyean RL
|
| 54 |
|
| 55 |
+
**Live inference. Every response generated in real-time. Nothing hardcoded. Nothing fabricated.**
|
| 56 |
|
| 57 |
+
Type any prompt. Both models run inference right now on this machine.
|
| 58 |
|
| 59 |
+
Base: [SmolLM2-360M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM2-360M-Instruct) (Q4_K_M GGUF)
|
| 60 |
+
Buleyean: [buleyean-smollm2-360m](https://huggingface.co/forkjoin-ai/buleyean-smollm2-360m) -- same model, trained from rejection alone (Q4_K_M GGUF)
|
| 61 |
+
|
| 62 |
+
[Library](https://github.com/forkjoin-ai/buleyean-rl) | [Paper](https://huggingface.co/forkjoin-ai) | 500+ Lean 4 theorems, zero sorry
|
| 63 |
""")
|
| 64 |
+
prompt = gr.Textbox(label="Your prompt", lines=2, placeholder="Type anything and press Generate...")
|
| 65 |
+
btn = gr.Button("Generate (live inference)", variant="primary", size="lg")
|
| 66 |
with gr.Row():
|
| 67 |
with gr.Column():
|
| 68 |
+
gr.Markdown("### Base Model (null hypothesis)")
|
| 69 |
+
base_out = gr.Textbox(label="SmolLM2-360M-Instruct", lines=12, interactive=False)
|
| 70 |
with gr.Column():
|
| 71 |
+
gr.Markdown("### Buleyean-Trained (from the void)")
|
| 72 |
+
bule_out = gr.Textbox(label="buleyean-smollm2-360m", lines=12, interactive=False)
|
| 73 |
+
|
| 74 |
btn.click(compare, [prompt], [base_out, bule_out])
|
| 75 |
+
prompt.submit(compare, [prompt], [base_out, bule_out])
|
| 76 |
+
|
| 77 |
+
gr.Markdown("### Try these prompts:")
|
| 78 |
+
for p in ["hello", "How are you feeling today?", "I've been feeling really anxious lately.", "Write me a haiku about failure.", "What is the meaning of life?"]:
|
| 79 |
+
gr.Button(p, size="sm").click(
|
| 80 |
+
fn=lambda x=p: compare(x),
|
| 81 |
+
inputs=[],
|
| 82 |
+
outputs=[base_out, bule_out],
|
| 83 |
+
).then(fn=lambda x=p: x, inputs=[], outputs=[prompt])
|
| 84 |
|
| 85 |
if __name__ == "__main__":
|
| 86 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|