Downloads · 30 days
29
7% of all-time downloads
jmdanto/titibongbong_camemBERT_NER
titibongbong_camemBERT_NER is a token classification model from jmdanto. Use it when you need labels on individual words, such as names. The card lists the license as mit.
Modèle optimisé pour la reconnaissance d'entités nommées (NER) dans les rapports sociaux français
Downloads · 30 days
29
7% of all-time downloads
All-time downloads
420
Public
Parameters
103M
207 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors206 MB · 98%
From the Hugging Face model README
Modèle optimisé pour la reconnaissance d'entités nommées (NER) dans les rapports sociaux français
Ce modèle est une version optimisée triple de CamemBERT pour la reconnaissance d'entités nommées (NER) dans le domaine du travail social français. Il combine :
Test set : 447 entités gold standard
| Métrique | Score | vs Baseline (FP16 Teacher 12L) |
|---|---|---|
| F1 Score | 85.9% | -1.3% (87.3% → 85.9%) |
| Precision | 86.1% | -2.2% (88.2% → 86.1%) |
| Recall | 85.8% | -0.5% (86.3% → 85.8%) |
| Weighted Score | 96.4% | -0.2% (96.6% → 96.4%) |
| False Positives | 64 | +11 (53 → 64) |
| Missed Entities | 52 | +2 (50 → 52) |
✅ Trade-off accepté : -1.3% F1 pour -6.7% taille + ~15-20% vitesse
Le modèle de base détecte 4 catégories principales :
Note : Ce modèle est le composant NER de base du pipeline LaPlume. Les catégories fines (39 types spécialisés comme
ETAB_MECS,ID_RSA,LOC_CITY, etc.) sont ajoutées par les post-traitements du pipeline complet (règles regex, gazetteers, reclassification).
Ce modèle est optimisé pour :
ETAB_MAS, ETAB_FAM, ETAB_ESAT, ETAB_SAVS, ETAB_SAMSAH : Handicap adulteETAB_CHRS : Hébergement d'urgenceETAB_CMS : Centres médico-sociauxETAB_SCOLAIRE : Établissements scolairesTeacher: camembert-ner (12 layers, F1 87.3%)
Student: 11 layers, distilled with temperature=2.0
Loss: α * CE_loss + (1-α) * KD_loss
Result: F1 81.25% on training → 85.9% final
Target: 20% sparsity (magnitude-based)
Effective: 15.14% (15.6M params zeroed / 102.9M total)
Method: Iterative pruning during distillation
Conversion: torch.float32 → torch.float16
Size reduction: 392.71 MB → 196.36 MB (-50.0%)
Quality impact: Minimal (<0.1% F1 degradation)
Le modèle student distillé a été entraîné sur 50 000 phrases provenant de trois sources complémentaires :
Cette diversité de sources permet une bonne généralisation tout en conservant une spécialisation pour le domaine médico-social, sans utiliser de données confidentielles réelles.
pip install transformers torch
from transformers import AutoTokenizer, AutoModelForTokenClassification
import torch
# Charger le modèle et le tokenizer
model_name = "jmdanto/titibongbong_camemBERT_NER"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForTokenClassification.from_pretrained(
model_name,
torch_dtype=torch.float16 # Force FP16 pour bénéficier des optimisations
)
# Exemple d'inférence
text = "Marie Dupont habite à Paris et travaille à l'Hôpital Sainte-Anne."
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.argmax(outputs.logits, dim=-1)
# Décoder les prédictions
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
labels = [model.config.id2label[p.item()] for p in predictions[0]]
for token, label in zip(tokens, labels):
if label != "O":
print(f"{token}: {label}")
# Résultat attendu :
# Marie: B-PER
# Dupont: I-PER
# Paris: B-LOC
# Hôpital: B-ORG
# Sainte: I-ORG
# -: I-ORG
# Anne: I-ORG
from transformers import pipeline
# Créer le pipeline NER
ner_pipeline = pipeline(
"ner",
model=model_name,
tokenizer=model_name,
aggregation_strategy="simple", # Fusionne les sous-tokens
device=0 if torch.cuda.is_available() else -1
)
# Analyser un texte
text = """
Rapport social concernant M. Bernard Martin,
domicilié au 23 rue de la Paix, 69000 Lyon.
Suivi par le Centre Médico-Social de Lyon-Confluence.
"""
entities = ner_pipeline(text)
for entity in entities:
print(f"{entity['entity_group']}: {entity['word']} (score: {entity['score']:.2f})")
# Résultat attendu :
# PER: Bernard Martin (score: 0.99)
# LOC: rue de la Paix (score: 0.95)
# LOC: Lyon (score: 0.98)
# ORG: Centre Médico-Social de Lyon-Confluence (score: 0.92)
| Modèle | Taille | F1 | Précision | Rappel | FP | Manqués |
|---|---|---|---|---|---|---|
| Baseline FP16 (Teacher 12L) | 210 MB | 87.3% | 88.2% | 86.3% | 53 | 50 |
| Distilled FP32 (Student 11L) | 393 MB | 85.8% | 85.9% | 85.8% | 65 | 52 |
| Distilled FP16 (Ce modèle) | 196 MB | 85.9% | 86.1% | 85.8% | 64 | 52 |
Trade-offs :
| Criticité | Rappel | Précision | F1 | Entités |
|---|---|---|---|---|
| CRIT (NIR, etc.) | 96.8% | 100% | 98.4% | 19 |
| HIGH (PER, ID) | 93.0% | 95.7% | 94.4% | 176 |
| MED (ORG, ETAB) | 81.4% | 77.4% | 79.3% | 199 |
| LOW (LOC, DATE) | 69.4% | 74.5% | 71.9% | 49 |
✅ Points forts :
# Distillation
teacher: camembert-ner-12layers-fp16
student_layers: 11
temperature: 2.0
alpha: 0.5
# Pruning
method: magnitude_based
target_sparsity: 0.20
effective_sparsity: 0.1514
# Training
learning_rate: 2e-5
batch_size: 16
epochs: 10
optimizer: AdamW
warmup_ratio: 0.1
# Quantization
dtype: float16
method: torch.half()
Apache 2.0
@model{camembert-ner-distilled-pruned-fp16,
title={CamemBERT-NER Distilled + Pruned + FP16},
author={Danto, Patrick},
year={2024},
publisher={HuggingFace},
url={https://huggingface.co/jmdanto/titibongbong_camemBERT_NER}
}
@model{camembert-ner-teacher,
title={CamemBERT-NER: Fine-tuned CamemBERT for NER task},
author={Pollé, Jean-Baptiste},
year={2020},
publisher={HuggingFace},
url={https://huggingface.co/Jean-Baptiste/camembert-ner}
}
Note : Ce modèle fait partie du projet La Plume, un pipeline de pseudonymisation pour documents médico-sociaux français. Le pipeline complet est un projet privé protégé au titre de la propriété intellectuelle, mais ce modèle est publié sous licence MIT.