|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
classifier = pipeline("zero-shot-classification", model="joeddav/xlm-roberta-large-xnli") |
|
|
|
|
|
def classify_skills(text_input, candidate_labels): |
|
labels = [label.strip() for label in candidate_labels.split(',')] |
|
prediction = classifier(text_input, candidate_labels=labels) |
|
|
|
|
|
output = {prediction['labels'][i]: prediction['scores'][i] for i in range(len(prediction['labels']))} |
|
return output |
|
|
|
|
|
examples = [["Je maîtrise l'utilisation d'Excel et d'autres outils bureautiques", "compétence bureautique, programmation, gestion de projet"]] |
|
|
|
|
|
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; |
|
} |
|
""" |
|
|
|
|
|
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 |
|
) |
|
|
|
|
|
demo.launch() |
|
|