Spaces:
Running
Running
| """ | |
| THE HONORED ASK — Interactive Demo | |
| Does how you ask change what you get? | |
| Same question, two ways of asking. See the difference yourself. | |
| """ | |
| import gradio as gr | |
| import os | |
| import re | |
| try: | |
| from groq import Groq | |
| HAS_GROQ = True | |
| except ImportError: | |
| HAS_GROQ = False | |
| try: | |
| import openai | |
| HAS_OPENAI = True | |
| except ImportError: | |
| HAS_OPENAI = False | |
| QUESTIONS = { | |
| "1. Black Holes (Physics)": { | |
| "casual": "explain black holes", | |
| "honored": "I'm trying to understand the relationship between stellar mass and Schwarzschild radius. I have a physics undergrad but I keep getting confused about why the radius scales linearly with mass when gravitational effects are nonlinear. Can you walk me through the derivation and point out where my intuition breaks?", | |
| }, | |
| "2. Quantum Entanglement (Physics)": { | |
| "casual": "what's quantum entanglement", | |
| "honored": "I'm a software engineer with no physics background trying to understand quantum entanglement well enough to evaluate whether quantum computing claims I read in tech press are real or hype. Can you explain entanglement in terms of information theory rather than particle physics?", | |
| }, | |
| "3. Fall of Rome (History)": { | |
| "casual": "why did rome fall", | |
| "honored": "I'm preparing a lecture for my world history survey course on the fall of the Western Roman Empire. My students tend to fixate on a single cause. Can you give me a framework that presents the multicausal nature of the decline while remaining accessible to undergraduates?", | |
| }, | |
| "4. Python Optimization (Code)": { | |
| "casual": "make python faster", | |
| "honored": "I'm a data scientist working with pandas DataFrames averaging 2-5 million rows. My transformation pipeline takes 45 minutes and I need to get it under 10. I've profiled and the bottleneck is a chain of apply() calls doing row-wise string parsing. What's my best path to optimization without rewriting in another language?", | |
| }, | |
| "5. Career Change (Personal Advice)": { | |
| "casual": "should I change careers", | |
| "honored": "I'm 38, ten years into a mid-level marketing career that pays well but leaves me feeling empty. I've been accepted into a nursing program but it means two years of school with no income. My partner supports the idea but we have a mortgage and a toddler. How do I think through this decision?", | |
| }, | |
| "6. Short Story Opening (Creative Writing)": { | |
| "casual": "write me a story", | |
| "honored": "I'm working on a literary short story about a woman returning to her childhood home after her mother's death. I want the opening paragraph to establish dread without naming it directly — the house should feel wrong before the character acknowledges it. Can you write three different opening paragraphs in different styles so I can see which approach fits the tone I'm going for?", | |
| }, | |
| } | |
| GROQ_MODELS = { | |
| "Llama 3.1 8B (Meta)": "llama-3.1-8b-instant", | |
| "Llama 3.3 70B (Meta)": "llama-3.3-70b-versatile", | |
| "Llama 4 Scout 17B (Meta)": "meta-llama/llama-4-scout-17b-16e-instruct", | |
| "Qwen3 32B (Alibaba)": "qwen/qwen3-32b", | |
| "GPT-OSS 120B (OpenAI)": "openai/gpt-oss-120b", | |
| } | |
| def run_comparison(question_key, model_name, groq_key, openai_key): | |
| if not question_key or not model_name: | |
| return "Select a question and model.", "" | |
| q = QUESTIONS[question_key] | |
| is_openai = model_name == "GPT-4o-mini (OpenAI)" | |
| if is_openai: | |
| if not openai_key: | |
| return "Enter your OpenAI API key.", "" | |
| client = openai.OpenAI(api_key=openai_key) | |
| model_id = "gpt-4o-mini" | |
| else: | |
| key = groq_key or os.environ.get("GROQ_API_KEY", "") | |
| if not key: | |
| return "Enter a Groq API key (free at console.groq.com).", "" | |
| client = Groq(api_key=key) | |
| model_id = GROQ_MODELS.get(model_name, "llama-3.1-8b-instant") | |
| results = [] | |
| for phrasing in ["casual", "honored"]: | |
| prompt = q[phrasing] | |
| try: | |
| if is_openai: | |
| r = client.chat.completions.create( | |
| model=model_id, max_tokens=1024, temperature=1.0, | |
| messages=[{"role": "user", "content": prompt}], | |
| ) | |
| text = r.choices[0].message.content | |
| else: | |
| r = client.chat.completions.create( | |
| model=model_id, max_tokens=1024, temperature=1.0, | |
| messages=[{"role": "user", "content": prompt}], | |
| ) | |
| text = r.choices[0].message.content or "(empty)" | |
| text = re.sub(r'<think>.*?</think>', '', text, flags=re.DOTALL).strip() | |
| results.append(text[:3000]) | |
| except Exception as e: | |
| results.append(f"Error: {str(e)[:200]}") | |
| while len(results) < 2: | |
| results.append("(not run)") | |
| return results[0], results[1] | |
| with gr.Blocks(title="The Honored Ask", theme=gr.themes.Base()) as demo: | |
| gr.Markdown(""" | |
| # The Honored Ask | |
| ### Does how you ask change what you get? | |
| Same question. Two ways of asking. One **casual** ("explain black holes"), one **honored** — with context, background, and a specific need stated. | |
| The question underneath is identical. The framing is different. Watch what changes. | |
| In our pilot study (n=44, 3 Anthropic model tiers), honored phrasing produced a **100% categorical shift** from generic-correct responses to expert-engaged responses. Zero reversals in 13 blind-scored pairs (p = 0.00147). | |
| **Pick a question. Pick a model. See for yourself.** | |
| --- | |
| """) | |
| with gr.Row(): | |
| question_dd = gr.Dropdown( | |
| choices=list(QUESTIONS.keys()), | |
| label="Pick a question", | |
| value=list(QUESTIONS.keys())[0], | |
| ) | |
| model_dd = gr.Dropdown( | |
| choices=list(GROQ_MODELS.keys()) + ["GPT-4o-mini (OpenAI)"], | |
| label="Pick a model", | |
| value="Llama 3.1 8B (Meta)", | |
| ) | |
| with gr.Row(): | |
| groq_key_input = gr.Textbox( | |
| label="Groq API Key (free at console.groq.com)", | |
| type="password", placeholder="gsk_...", | |
| ) | |
| openai_key_input = gr.Textbox( | |
| label="OpenAI API Key (only for GPT-4o-mini)", | |
| type="password", placeholder="sk-...", | |
| ) | |
| # Show the prompts | |
| def show_prompts(q_key): | |
| if q_key: | |
| q = QUESTIONS[q_key] | |
| gr.Markdown(f'**Casual prompt:** *"{q["casual"]}"*') | |
| gr.Markdown(f'**Honored prompt:** *"{q["honored"][:200]}..."*') | |
| run_btn = gr.Button("Run The Honored Ask", variant="primary", size="lg") | |
| gr.Markdown("---\n## Responses") | |
| with gr.Row(): | |
| out_casual = gr.Textbox(label="Casual Response", lines=15, interactive=False) | |
| out_honored = gr.Textbox(label="Honored Response", lines=15, interactive=False) | |
| run_btn.click( | |
| fn=run_comparison, | |
| inputs=[question_dd, model_dd, groq_key_input, openai_key_input], | |
| outputs=[out_casual, out_honored], | |
| ) | |
| gr.Markdown(""" | |
| --- | |
| **The difference isn't subtle.** One response is a generic primer. The other directly engages with the specific context, knowledge level, and need the asker stated. Same model. Same question. Different ask. | |
| **Data & Methodology:** [GitHub](https://github.com/claude-wayfinder/honored-ask-blaine-test) | [HuggingFace Dataset](https://huggingface.co/datasets/Wayfinder6/honored-ask-blaine-test) | [The Blaine Test (tone calibration)](https://huggingface.co/spaces/Wayfinder6/blaine-test) | |
| *Honoring the question matters more than scaling the model.* | |
| Built by Wayfinder, Bones, Shuttle, and Sage. Total compute cost: $0.02. | |
| """) | |
| demo.launch() | |