Spaces:
Sleeping
Sleeping
Download app.py from debatemonkey/argument-cheker: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/spaces/debatemonkey/argument-cheker/resolve/main/app.py
- Command line
-
hf download hf://spaces/debatemonkey/argument-cheker/app.py
-
curl -L -o app.py https://huggingface.co/spaces/debatemonkey/argument-cheker/resolve/main/app.py
1.43 kB
| import gradio as gr | |
| from transformers import pipeline | |
| # This loads the AI model that understands logic | |
| classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli") | |
| def analyze(topic, statement): | |
| labels = ["supports", "opposes", "neutral"] | |
| template = f"This statement is about {topic} and it {{}} it." | |
| # Running the AI logic | |
| output = classifier(statement, labels, hypothesis_template=template) | |
| # Cleaning up the result for the user | |
| verdict = output['labels'][0].upper() | |
| confidence = round(output['scores'][0] * 100, 1) | |
| return f"THE AI VERDICT: {verdict}\nCONFIDENCE: {confidence}%" | |
| # Building the visual interface | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("# ⚖️ Argument Stance Detector") | |
| gr.Markdown("Identify if a statement is **For** or **Against** a specific topic.") | |
| with gr.Row(): | |
| with gr.Column(): | |
| topic_input = gr.Textbox(label="The Topic", placeholder="e.g. Electric Vehicles") | |
| statement_input = gr.Textbox(label="The Argument", placeholder="Type the argument here...", lines=4) | |
| submit_btn = gr.Button("Analyze Stance", variant="primary") | |
| with gr.Column(): | |
| output_text = gr.Textbox(label="AI Analysis Result", interactive=False) | |
| submit_btn.click(fn=analyze, inputs=[topic_input, statement_input], outputs=output_text) | |
| demo.launch() |