YAML Metadata
Warning:
empty or missing yaml metadata in repo card
(https://huggingface.co/docs/hub/model-cards#model-card-metadata)
model_name: FrenchTextCategorizer language: French tags:
- text-classification
- fine-tuned
- french license: mit dataset: "French News Dataset"
π Usage
This model is a FLAUBERT fine-tuned version to categorize French texts into the following categories:
CULTURE, DEBATS_ET_OPINIONS, ECONOMIE, EDUCATION, FAIT_DIVERS, INTERNATIONAL, LIFESTYLE, NUMERIQUE, POLITIQUE, RELIGION, SANTE, SCIENCE_ET_ENVIRONNEMENT, SOCIETE, SPORT, INDEFINI
π Quick Start
from transformers import AutoModelForSequenceClassification
model = AutoModelForSequenceClassification.from_pretrained("juenp/FrenchTextCategorizer")
model.eval()
π Full Example (with Tokenizer, Prediction and Probabilities)
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
import torch.nn.functional as F
# Load model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained("juenp/FrenchTextCategorizer")
tokenizer = AutoTokenizer.from_pretrained("juenp/FrenchTextCategorizer")
model.eval()
# Input text
text = "Ce film est un chef-d'Εuvre incroyable, tout Γ©tait parfait."
# Tokenize
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
inputs.pop("token_type_ids", None)
# Predict
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = F.softmax(logits, dim=-1)
predicted_class_idx = torch.argmax(probs, dim=-1).item()
# Decode predicted class from config
predicted_class = model.config.id2label[str(predicted_class_idx)]
prob_percentages = [round(p.item() * 100, 2) for p in probs[0]]
# Output
print(f"Texte : {text}")
print(f"Classe prΓ©dite : {predicted_class}")
print(f"ProbabilitΓ©s (%) : {prob_percentages}")
π Notes
model.config.id2labelis automatically loaded from the model's configuration (config.json).- If you want to process multiple texts at once, simply pass a list of texts to the tokenizer.
β Ready for Inference!
- Downloads last month
- -
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
π
Ask for provider support