Spaces:
Runtime error
Runtime error
Create app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import gradio as grfrom transformers import pipeline
# Load a summarization model from Hugging Facesummarizer = pipeline("summarization")
def evaluate_text_against_rubric(rubric, text): # Split rubric into criteria criteria = rubric.split('\n') # Use summarizer for each criterion as a dummy placeholder evaluations = {} for i, criterion in enumerate(criteria): if criterion.strip(): summary = summarizer(text, max_length=50, min_length=25, do_sample=False)[0]['summary_text'] evaluations[f'Criteria {i+1}'] = { "Criterion": criterion, "Score": 3, # Dummy score for now "Comment": f"Evaluation based on criterion: {criterion}", "Example": summary } return evaluations
def evaluate(rubric, text): evaluation = evaluate_text_against_rubric(rubric, text) evaluation_text = "" for criterion, details in evaluation.items(): evaluation_text += f"{criterion}:\n" evaluation_text += f" Criterion: {details['Criterion']}\n" evaluation_text += f" Score: {details['Score']}\n" evaluation_text += f" Comment: {details['Comment']}\n" evaluation_text += f" Example: {details['Example']}\n\n" return evaluation_text
# Create Gradio interfaceinterface = gr.Interface( fn=evaluate, inputs=[ gr.Textbox(lines=10, placeholder="Enter your rubric here..."), gr.Textbox(lines=10, placeholder="Paste the text to be evaluated here...") ], outputs="text", title="Text Evaluator", description="Upload or enter a rubric and paste text for evaluation. The system will grade the text against the rubric and provide feedback.")
# Launch the interfaceinterface.launch()app.pyAdded+48