myspace / app.py
preetidav's picture
Update app.py
2eb2428 verified
raw
history blame
736 Bytes
import gradio as gr
from transformers import pipeline
# Load pre-trained model for CoLA (linguistic acceptability)
model_name = "sentence-transformers/all-MiniLM-L6-v2"
classifier = pipeline("text-classification", model=model_name)
def classify_sentence(sentence):
result = classifier(sentence)[0]
return f"Label: {result['label']} (Confidence: {result['score']:.2f})"
# Create Gradio interface
iface = gr.Interface(
fn=classify_sentence,
inputs=gr.Textbox(lines=2, placeholder="Enter a sentence..."),
outputs="text",
title="Sentence Acceptability Classifier",
description="This model classifies whether a sentence is linguistically acceptable (LABEL_1) or not (LABEL_0).",
)
# Launch app
iface.launch()