Automatic coding of economic activity at INSEE
An MLOps pipeline for the APE code: architecture, methods and lessons learned
Every business that registers in France describes its activity in a few words, and INSEE must turn that description into one of about 750 codes of the national activity classification (NAF, the French version of NACE). This APE code shapes business statistics and national accounts.
Since the end of 2022, this coding has been done by a machine learning model, called in real time by the Sirene business register. This note reviews the MLOps pipeline behind it:
- how the data is prepared and cleaned;
- how the model is trained, packaged, deployed and monitored;
- how human expertise and large language models keep its quality under control;
- how the whole system is retrained without regressions.
~2 M descriptions coded per year
~750 possible codes (sub-classes)
~80 % coded with no human involvement
< 300 ms per prediction, on CPU
How to read this note
| Chapter | Content |
|---|---|
| 1. Context and history | The APE code, the one-stop-shop reform, from Sicore to fastText to PyTorch |
| 2. Architecture | Platform, repositories, end-to-end flow |
| 3. Data | Training data, auditable rule engine, the NAF 2025 revision with LLMs, GRAAL agents |
| 4. Model | Architecture, torchTextClassifiers, training, confidence index, calibration, results, future work |
| 5. Evaluation | Metrics beyond accuracy, golden set, auxiliary engines, inference time |
| 6. Serving and deployment | MLflow packaging, API, CI/CD and GitOps |
| 7. Monitoring and annotation | Drift, dashboards, Label Studio, LLM audits |
| 8. Retraining protocol | Golden set, data curation, business rules, quality gates |
| 9. Organisational and infrastructural challenges | The business data scientist, the qualification platform |
| 10. Lessons learned | What worked, what we would do again, open questions |
| Glossary and notation | Symbols of the retraining protocol and the evaluation, terms |
| References | Presentations, papers, code |
Readers interested mainly in methodology can go straight to Evaluation and the Retraining protocol. Readers interested in infrastructure should start with Architecture and Serving.
This note is written by the Innovation Lab, INSEE’s data science team. All the code is open source on GitHub. The team’s slides are collected here. A French version is available.