Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| import os | |
| api_key = os.environ["api_key"] | |
| pipeline = pipeline(task="text-generation", model="nkthiebaut/summarizely", use_auth_token=api_key) | |
| prediction_parameters = { | |
| "max_length": 100, | |
| "repetition_penalty": 2.0, | |
| "top_k": 1, | |
| "top_p": 1, | |
| "temperature": 2.0, | |
| "return_full_text": False, # remove input from output | |
| } | |
| def predict(job_title, skills, temperature): | |
| prompt = f"Skills list: {skills} Job title: {job_title} Summary: " | |
| prediction_parameters["temperature"] = temperature | |
| predictions = pipeline(prompt, **prediction_parameters) | |
| return predictions[0]["generated_text"] | |
| title = "Summarizely: Generate Realistic Experience Descriptions" | |
| description = """ | |
| Enter your job title and skills and Summarizely will generate an experience summary. | |
| Summarizely is a Hackathon project by the Machine Learning team at Hired.com. | |
| """ | |
| interface = gr.Interface( | |
| predict, | |
| inputs=[ | |
| gr.Textbox(value="Full Stack Engineer", label="👩🔧 Job title"), | |
| gr.Textbox(value="HTML, React, Docker", label="🧠 Skills list"), | |
| gr.Slider(0.0, 10.0, value=2.0, label="🌡 Temperature (~degree of uncertainty)"), | |
| ], | |
| outputs=gr.Textbox(label="📚 Summary"), | |
| examples=[ | |
| ["Full Stack Engineer", "React, JavaScript, HTML, PHP, Scrum, Python, SQL", 2.0], | |
| ["Backend Engineer", "Python, Ruby, Rails, AWS, Jenkins", 2.0], | |
| ["Machine Learning Engineer", "PyTorch, TensorFlow, Scikit-learn, SQL, Machine Learning, Deep Learning", 2.0] | |
| ], | |
| title=title, | |
| description=description, | |
| ) | |
| interface.queue(default_enabled=False) | |
| interface.launch(auth=("hired", os.environ["password"])) | |