File size: 2,134 Bytes
1c6cfc6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import gradio as gr
from transformers import pipeline
# Load a multilingual zero-shot classification model that supports French
classifier = pipeline("zero-shot-classification", model="joeddav/xlm-roberta-large-xnli")
# Skill classification function in French
def classify_skills(text_input, candidate_labels):
labels = [label.strip() for label in candidate_labels.split(',')]
prediction = classifier(text_input, candidate_labels=labels)
# Formatting output as a dictionary of skills and confidence scores
output = {prediction['labels'][i]: prediction['scores'][i] for i in range(len(prediction['labels']))}
return output
# Examples related to skill classification in French
examples = [["Je maîtrise l'utilisation d'Excel et d'autres outils bureautiques", "compétence bureautique, programmation, gestion de projet"]]
# Custom CSS to give a distinct look and feel
css = """
footer {display:none !important}
.output-markdown{display:none !important}
.gr-button-primary {
z-index: 14;
height: 43px;
width: 130px;
left: 0px;
top: 0px;
padding: 0px;
cursor: pointer !important;
background: #112c45 !important;
border: none !important;
text-align: center !important;
font-family: Poppins !important;
font-size: 14px !important;
font-weight: 500 !important;
color: #ffffff !important;
line-height: 1 !important;
border-radius: 12px !important;
transition: box-shadow 200ms ease 0s, background 200ms ease 0s !important;
box-shadow: none !important;
}
.gr-button-primary:hover{
background: #4285F4 !important;
box-shadow: 0px 1px 7px 0px rgba(0, 0, 0, 0.23) !important;
}
"""
# Gradio interface for skill classification in French
demo = gr.Interface(
fn=classify_skills,
inputs=[gr.Textbox(label="Texte à classifier"), gr.Textbox(label="Compétences potentielles (séparées par des virgules)")],
outputs=gr.Label(label="Résultat de Classification des Compétences"),
title="Classification des Compétences | Modèle Multilingue",
examples=examples,
css=css
)
# Launch the interface
demo.launch()
|