🎩 Application Administrator: Acting as the functional lead for the SIRENE register. I bridge the gap between business needs and IT by writing functional specifications for system maintenance and evolution.
🧢 Data Scientist: Managing the end-to-end ML workflow for APE classification from model training and delivery to its integration into the production application.
torchTextClassifiers: a wrapper to handle them all☺️ ➡️ Fast implementation: just grab-and-go 🛍️
Let’s dive into the different components🤓 (experts) ➡️ More control: modular customization 🔧👌😎
Some tips for data import
Just update the import section and match your column names. Works out-of-the-box with Parquet or CSV for instance (Can ask our AI chat)
8 6️⃣ NACE Rev 2.1: update our classifier using LLMs
8.1 Statistical classifications, briefly
The Problem
What NACE is
The EU classification of economic activities
Every business unit in production registers gets a NACE code
Hierarchical: section → division → group → class → sub-class
Revised every ~15 years — the current move: NACE 2.0 → NACE 2.1
The French specificity: NAF
Nomenclature d’Activités Française: The national adaptation of NACE, managed by INSEE
Same structure as NACE + an extra 5th character (a letter) for national specifics
Assigned to every French company as the well-known APE code (Activité Principale Exercée)
Note
Our work was actually conducted using the French NAF. However, I will use NACE in this presentation to make it more universally understandable and to demonstrate that our approach perfectly adapts to this broader European classification level.
8.2 When a classification is revised
A recurring challenge for every statistical institute (NACE, COICOP, ISCO, …).
Standard ML maintenance
Inputs may drift over time
We monitor and retrain on fresh labels
The target variable stays the same
Classification revision
The target variable itself changes
New labelled data are scarce or missing
Legacy labels are in the wrong space
Standard retraining is not possible
At Insee, a TorchTextClassifiers classifier (fastText-inspired) in production since 2025-2026 to assign NACE 2.0 codes
Trained on a 2.7-million-label training set.
Central question: how can we leverage years of accumulated production knowledge in the old classification to bootstrap a model in the new one?
8.3 Our strategy: shifting the old trainset
The Problem
8.4 NACE 2.0 → 2.1 and the one-to-many codes
The Problem
Scope of the change
Change in the number of sub-classes? Moderate…
from 746 to 732
Mostly splits at level 4, with a few merges and recompositions
Complexity lies in non-bijective cases!
Univocal: one-to-one mapping
One-to-many: 1-to-many relation (~2 to 5)
8.5 The scale of the problem
The Problem
One-to-many
Univocal
Correspondence table
25 %
75 %
Actual training set
52 %
48 %
~1.4 M
observations that cannot be recoded by table lookup
The problem cannot be solved by a deterministic mapping table alone.
Experts are far from converging systematically: we stay cautious when interpreting our precision metrics
Explicit reasoning protocol
Description, then check the legacy code, then consult candidates and explanatory notes, then decide
A sequence we can encode into an LLM prompt at scale
8.8 3. Methodology
8.9 Rule-Based Augmented Generation as constrained selection
Methodology
Why not ask the LLM directly?
732 codes is too large a space for reliable open generation.
Hallucinations are very frequent.
Capabilities depend heavily on the LLM’s implicit knowledge base.
Constrained selection instead:
For each observation, we already know the NACE 2.0 code
The correspondence table gives the set of admissible NACE 2.1 codes
The task becomes: pick the right code from a short, restricted list
Output aligned with official rules
8.10 The pipeline
Methodology
For each observation:
Retrieve the activity description (free text + optional precisions: secondary activity, legal category)
Retrieve the legacy NACE 2.0 code
Use the correspondence table to get the set of candidate NACE 2.1 codes
Inject the explanatory notes of each candidate code into the prompt
Ask the LLM to pick the most appropriate code
Parse the structured JSON response
A form of Rule-Based Augmented Generation (RBAG) with a deterministic retriever.
Inputs to the prompt
Element
Source
Activity text + precisions
Production register
NACE 2.0 code
Insee NACE Experts
Candidate set
Correspondence table
Explanatory notes
Official NACE 2.1 documentation
8.11 The prompt structure
Methodology
System prompt — same for every observation
You are an expert in the NACE classification. Your task is to assign a NACE 2.1 code to a business based on its activity description, using a candidate list derived from the existing NACE 2.0 code…
User prompt — observation-specific
# Main activity : {{activity}}
# NACE 2.0 code : {{nace_old}}
# Candidate NACE 2.1 codes + notes : {{proposed_codes}}
========
# Instructions (7 rules)
→ candidate list only — no external code
→ first activity only
→ strict JSON — no explanation
86.95: Physiotherapy activities
Includes: physiotherapy, medical massage, occupational therapy, praxitherapy…
Does not include: osteopaths, chiropractors, non-medical massage parlors…
86.96: Traditional, complementary, and alternative medicine [...]
86.99: Other human health activities n.e.c. [...]
8.12 Multi-model annotation
Methodology
Model
Size
Inference speed
Behaviour
Qwen3-6-35B MoE
35B
Very fast (13 it/s)
Moderately restrictive
Qwen3-6-35B MoE + thinking
35B
Less fast (1 it/s)
Less restrictive
Gemma4-26B MoE
26B
Fast (8 it/s)
Moderately restrictive
➕️ Aggregation: majority vote.
Different sizes, different throughput.
8.13 4. Infrastructure
8.14 Our MLOps stack on the SSPCloud
Infrastructure
SSPCloud is Insee’s data science platform, built on the open-source Onyxia project and powered by Kubernetes as its underlying technology stack.
Main elements of the technical stack:
MinIO — S3-compatible storage for datasets and model artifacts
llm.lab — SSPCloud’s LLM provider on premise, (OpenWebUI + vLLM)
Langfuse — prompt versioning
MLflow — experiment tracking
Argo Workflows — the end-to-end pipeline orchestrator