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()