jmdanto's picture
Upload MODEL_CARD.md with huggingface_hub
e564114 verified
|
Raw
History Blame Contribute Delete
11.7 kB
---
language: fr
license: mit
tags:
- token-classification
- named-entity-recognition
- ner
- french
- camembert
- distillation
- pruning
- quantization
- fp16
- social-work
- medical-social
datasets:
- custom
metrics:
- f1
- precision
- recall
model-index:
- name: camembert-ner-distilled-pruned-fp16
results:
- task:
type: token-classification
name: Named Entity Recognition
dataset:
name: Rapports Sociaux FR
type: custom
metrics:
- type: f1
value: 85.9
name: F1 Score
- type: precision
value: 86.1
name: Precision
- type: recall
value: 85.8
name: Recall
---
# Model Card: CamemBERT-NER Distilled + Pruned + FP16
## Model Details
### Model Description
Modèle CamemBERT optimisé triple pour reconnaissance d'entités nommées (NER) dans rapports sociaux français :
- **Distillation** : 11 couches (de 12 du teacher) = -8.3% paramètres
- **Pruning** : 20% magnitude-based = 15.14% sparsité effective
- **Quantization** : FP16 = -50% taille mémoire
**Développé par** : Jean-Michel Danto
**Type** : Token Classification (NER)
**Langue** : Français
**License** : Apache 2.0
**Modèle parent** : camembert-base
**Repository** : [laplume](https://github.com/jeanmicheldanto-boop/laplume_test)
### Model Sources
- **Repository** : https://github.com/jeanmicheldanto-boop/laplume_test
- **Teacher Model** : titibongbong/CamemBERT-NER (12 layers, FP16, 210 MB)
- **Base Model** : camembert-base
## Uses
### Direct Use
Reconnaissance d'entités nommées dans documents médico-sociaux français (rapports sociaux, dossiers ASE, RSA, handicap).
### Downstream Use
Pipeline de pseudonymisation automatique pour protection de données personnelles dans secteur social.
### Out-of-Scope Use
- Domaines non médico-sociaux (textes génériques, littérature, etc.)
- Langues autres que français
- Tâches autres que NER (classification, QA, etc.)
## Bias, Risks, and Limitations
### Limitations techniques
- **Domaine spécialisé** : Entraîné sur rapports sociaux, performances réduites hors domaine
- **Trade-off qualité** : -1.3% F1 vs baseline pour gain taille/vitesse
- **Faux positifs** : +11 FP vs baseline (validation humaine recommandée)
- **Catégories rares** : Performance réduite sur LOC, DATE (peu d'exemples training)
### Biais identifiés
- **Biais géographique** : Meilleure détection des grandes villes françaises
- **Biais nominal** : Meilleure détection prénoms français courants
- **Biais institutionnel** : Focus sur institutions françaises (ASE, CAF, MDPH)
### Recommendations
- ✅ **Validation humaine** pour données sensibles (NIR, identifiants)
- ✅ **Post-traitement** avec règles métier et gazetteers
- ✅ **Monitoring** des faux positifs/négatifs en production
- ⚠️ **Prudence** sur entités rares ou hors vocabulaire
## How to Get Started with the Model
```python
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
import torch
model_name = "jmdanto/titibongbong_camemBERT_NER"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForTokenClassification.from_pretrained(
model_name,
torch_dtype=torch.float16
)
# Méthode 1 : Pipeline (recommandé)
ner_pipeline = pipeline(
"ner",
model=model_name,
aggregation_strategy="simple"
)
text = "Marie Dupont habite à Lyon et travaille au Centre Hospitalier."
entities = ner_pipeline(text)
for entity in entities:
print(f"{entity['entity_group']}: {entity['word']} (score: {entity['score']:.2f})")
# Résultat :
# PER: Marie Dupont (score: 0.99)
# LOC: Lyon (score: 0.98)
# ORG: Centre Hospitalier (score: 0.92)
# Méthode 2 : Inférence directe
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.argmax(outputs.logits, dim=-1)
# Les prédictions utilisent le format IOB2 :
# B-PER, I-PER (Person)
# B-LOC, I-LOC (Location)
# B-ORG, I-ORG (Organization)
# B-MISC, I-MISC (Miscellaneous)
# O (Outside)
```
### 🏷️ Entités détectées
Le modèle reconnaît **4 catégories principales** (format IOB2) :
| Catégorie | Description | Exemples |
|-----------|-------------|----------|
| **PER** | Personnes | Marie Dupont, M. Bernard |
| **LOC** | Lieux | Paris, Lyon, rue de la Paix |
| **ORG** | Organisations | Hôpital Sainte-Anne, CCAS |
| **MISC** | Divers | dates, événements |
> **Note** : Pour des catégories fines (39 types comme `ETAB_MECS`, `ID_RSA`, `LOC_CITY`), utiliser le pipeline LaPlume complet avec post-traitement.
## Training Details
### Training Data
- **Corpus d'entraînement** : **50 000 phrases** issues de trois sources :
1. **Contexte médico-social français** :
- Rapports sociaux fictifs mais réalistes (générés pour l'entraînement)
- Rapports publics sur l'organisation médico-sociale et bonnes pratiques
2. **Narratif littéraire** : Grands romans français du XXe siècle (dialogues, descriptions de personnages et lieux)
3. **Articles Wikipedia français** : Contenu encyclopédique général pour généralisation
- **Domaines applicatifs** : Aide sociale à l'enfance, RSA, handicap, hébergement, personnes âgées
- **Annotations** : 4 catégories principales (PER, LOC, ORG, MISC) au format IOB2
- **Base model** : Jean-Baptiste/camembert-ner fine-tuné puis distillé
**Important** : Aucune donnée confidentielle réelle (dossiers ASE/RSA réels) n'a été utilisée. Le corpus médico-social est composé de textes fictifs et de rapports publics uniquement.
Cette diversité de sources (médico-social + littéraire + encyclopédique) permet au modèle de généraliser efficacement tout en conservant une spécialisation pour le domaine cible.
> **Note** : Les 39 catégories fines du pipeline LaPlume (ETAB_*, ID_*, LOC_CITY, etc.) sont ajoutées par post-traitement (règles, gazetteers), pas par le modèle NER de base.
### Training Procedure
#### Distillation
```
Teacher: camembert-ner (12L, F1 87.3%)
Student: 11 layers
Loss: α * CE + (1-α) * KD
Temperature: 2.0
```
#### Pruning
```
Method: Magnitude-based iterative
Target: 20% sparsity
Effective: 15.14% (15.6M params zeroed)
Schedule: Progressive pendant distillation
```
#### Quantization
```
Method: torch.half() conversion
Input: FP32 (392.71 MB)
Output: FP16 (196.36 MB)
Reduction: -50.0%
```
#### Preprocessing
- Tokenization : SentencePiece BPE (32k vocab)
- Max length : 512 tokens
- Padding : dynamic par batch
#### Training Hyperparameters
- **Learning rate** : 2e-5 (AdamW)
- **Batch size** : 16
- **Epochs** : 10
- **Warmup** : 10% steps
- **Weight decay** : 0.01
- **Gradient clipping** : 1.0
#### Speeds, Sizes, Times
- **Training time** : ~12h (distillation + pruning)
- **Quantization time** : ~2 min
- **Final size** : 196.36 MB (FP16)
- **Inference speed** : ~15-20% plus rapide que baseline
- **Memory usage** : -50% RAM vs FP32
## Evaluation
### Testing Data, Factors & Metrics
#### Testing Data
- **Dataset** : train_original.txt + train_gold.txt
- **Taille** : 447 entités gold standard
- **Distribution** : CRIT (4%), HIGH (39%), MED (45%), LOW (11%)
#### Metrics
- F1 Score (macro et weighted)
- Precision / Recall
- Category accuracy
- False positives / Missed entities
### Results
#### Summary (Run 106)
| Métrique | Score | vs Baseline |
|----------|-------|-------------|
| **F1 Score** | **85.9%** | -1.3% |
| **Precision** | **86.1%** | -2.2% |
| **Recall** | **85.8%** | -0.5% |
| **Weighted Score** | **96.4%** | -0.2% |
| **False Positives** | 64 | +11 |
| **Missed** | 52 | +2 |
#### Performance par criticité
| Criticité | Rappel | Précision | F1 |
|-----------|--------|-----------|-----|
| **CRIT** (NIR, identifiants) | 96.8% | 100% | 98.4% |
| **HIGH** (PER, ID_DOSSIER) | 93.0% | 95.7% | 94.4% |
| **MED** (ORG, ETAB) | 81.4% | 77.4% | 79.3% |
| **LOW** (LOC, DATE) | 69.4% | 74.5% | 71.9% |
## Bias, Risks, and Limitations
### Limitations techniques
- **Domaine spécialisé** : Optimisé pour le médico-social français, performances réduites sur d'autres domaines
- **Trade-off qualité/vitesse** : -1.3% F1 vs baseline pour +15-20% vitesse
- **Entités rares** : Moins performant sur entités hors vocabulaire ou très rares
- **Dépendance contextuelle** : Nécessite contexte suffisant (min 5-10 mots)
### Considérations éthiques
- ✅ **Données d'entraînement** : **Aucune donnée confidentielle réelle utilisée**
- Rapports sociaux : fictifs et réalistes (générés)
- Rapports publics : documents publics d'organisation et bonnes pratiques
- **Pas de dossiers ASE/RSA réels** (hautement confidentiels)
- ✅ **Usage recommandé** : Outil d'assistance, pas de décision automatique
- ✅ **Validation humaine** requise pour données sensibles
- ⚠️ **RGPD** : Adapter selon contexte (pseudonymisation, consentement)
- ⚠️ **Biais potentiels** : Sous-représentation de certains groupes dans corpus d'entraînement
### Recommendations
- ✅ **Validation humaine** pour données sensibles (NIR, identifiants)
- ✅ **Post-traitement** avec règles métier et gazetteers
- ✅ **Monitoring** des faux positifs/négatifs en production
- ⚠️ **Prudence** sur entités rares ou hors vocabulaire
- ⚠️ **Ne jamais utiliser ce modèle sur des données confidentielles sans autorisation**
## Environmental Impact
- **Hardware** : NVIDIA GPU (compute capability ≥ 6.0 for FP16)
- **Training hours** : ~12h (distillation + pruning)
- **Cloud provider** : N/A (local training)
- **Carbon emitted** : ~2.5 kg CO2eq (estimation)
**Optimizations réduisant l'empreinte** :
- Distillation → -8% paramètres
- Pruning → -15% poids actifs
- FP16 → -50% mémoire et calculs
## Technical Specifications
### Model Architecture and Objective
- **Architecture** : CamemBERT (RoBERTa français)
- **Layers** : 11 (distilled from 12)
- **Hidden size** : 768
- **Attention heads** : 12 per layer
- **Intermediate size** : 3072
- **Vocabulary** : 32,000 tokens (SentencePiece)
- **Max sequence** : 512 tokens
- **Parameters** : 102,947,333 total (87,350,000 non-zero)
### Compute Infrastructure
#### Hardware
- **Training** : GPU NVIDIA (≥ 12GB VRAM)
- **Inference** : CPU/GPU compatible FP16
#### Software
- Python 3.8+
- PyTorch ≥ 2.0.0
- Transformers ≥ 4.30.0
- SafeTensors ≥ 0.3.0
## Citation
```bibtex
@model{camembert-ner-distilled-pruned-fp16,
title={CamemBERT-NER Distilled + Pruned + FP16},
author={Danto, Patrick},
year={2024},
publisher={HuggingFace Hub},
url={https://huggingface.co/jmdanto/titibongbong_camemBERT_NER},
note={F1: 85.9%, Size: 196MB, Speed: +15-20%}
}
@model{camembert-ner-teacher,
title={CamemBERT-NER: Fine-tuned CamemBERT for NER task},
author={Pollé, Jean-Baptiste},
year={2020},
publisher={HuggingFace Hub},
url={https://huggingface.co/Jean-Baptiste/camembert-ner}
}
```
## Model Card Authors
Patrick Danto
## Model Card Contact
- Email : patrick.danto@outlook.fr
---
**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.