V2 CamemBERT-NER-PII French - ONNX FP32
Version ONNX FP32 du modèle CamemBERT-NER-PII V2 pour exécution dans le navigateur.
📦 Taille
- Modèle ONNX FP32 : ~440 MB (précision maximale)
- Mémoire requise : ~600 MB
- Temps d'inférence : 200-500ms pour 512 tokens
🚀 Utilisation avec Transformers.js
Installation
npm install @huggingface/transformers
Code JavaScript
import { pipeline, env } from '@huggingface/transformers';
// Configuration optimale
env.backends.onnx.wasm.numThreads = 4;
// Charger le modèle ONNX FP32
const ner = await pipeline(
'token-classification',
'Anonym-IA/V2-camembert-ner-pii-onnx-fp32'
);
// Détecter les PII
const text = "Jean Dupont habite au 12 rue de la Paix, 75001 Paris";
const entities = await ner(text, { aggregation_strategy: 'simple' });
console.log(entities);
// [
// { entity_group: 'PRENOM_PERSONNE', word: 'Jean', score: 0.95, ... },
// { entity_group: 'NOM_PERSONNE', word: 'Dupont', score: 0.92, ... },
// ...
// ]
Anonymisation côté client
async function anonymizeInBrowser(text) {
const entities = await ner(text, { aggregation_strategy: 'simple' });
let anonymized = text;
const mapping = {};
const counters = {};
// Tri par position décroissante
entities.sort((a, b) => b.start - a.start);
for (const entity of entities) {
const type = entity.entity_group;
counters[type] = (counters[type] || 0) + 1;
const marker = `[${type}${counters[type]}]`;
mapping[marker] = entity.word;
anonymized = anonymized.slice(0, entity.start) +
marker +
anonymized.slice(entity.end);
}
return { anonymized, mapping };
}
// Utilisation
const result = await anonymizeInBrowser(
"Jean Dupont habite au 12 rue de la Paix, 75001 Paris"
);
console.log(result.anonymized);
// "[PN1] [NOM1] habite au [NUM1] [VOIE1], [CP1] [VI1]"
console.log(result.mapping);
// { "[PN1]": "Jean", "[NOM1]": "Dupont", ... }
📊 Performance navigateur
Testé sur :
- ✅ Chrome/Edge (meilleur)
- ✅ Firefox
- ⚠️ Safari (plus lent)
Benchmarks (MacBook Pro M1) :
- Temps de chargement : ~5-8 secondes
- Inférence (256 tokens) : ~300ms
- Mémoire utilisée : ~250 MB
🔧 Optimisations
Multi-threading
env.backends.onnx.wasm.numThreads = navigator.hardwareConcurrency || 4;
Cache du modèle
env.cacheDir = './.cache/transformers';
📄 Modèle PyTorch
Pour utilisation serveur (Python), voir le repo PyTorch :
Anonym-IA/V2-camembert-ner-pii-french
🔗 Liens
- Modèle PyTorch : https://huggingface.co/Anonym-IA/V2-camembert-ner-pii-french
- GitHub : Anonym-IA_LLM_Pseudonymisation
- Transformers.js : https://huggingface.co/docs/transformers.js
Généré automatiquement le 2026-01-19 21:55:26
- Downloads last month
- 34