Fine-tuning and evaluation pipeline for document classification
A repeatable pipeline that labels documents, fine-tunes a classifier and tests it before it reaches production.
Concept projects are detailed approaches to typical briefs. They are not client deliveries.
Overview
A repeatable pipeline that labels documents, fine-tunes a classifier and tests it before it reaches production, with people reviewing what the model is unsure about.
The challenge
Finance operations teams sort large volumes of incoming documents before anyone can act on them. General-purpose models handle common types reasonably well but struggle with an organization's own forms, and without a test set nobody can say how often they're wrong.
Our approach
The steps in the order we would take them.
Agree document types, edge cases and the cost of a wrong label with the operations team.
Set up labeling with written guidelines, a second review and a held-out test set.
Fine-tune a compact classification model on the labeled set.
Compare it with a prompted general-purpose model, type by type.
Route low-confidence predictions to people and feed corrections into the next round.
What the solution includes
- Labeling guidelines and a labeled dataset
- A training and evaluation pipeline
- An evaluation report by document type
- A classification API with confidence scores
- A retraining runbook
Technical implementation
How we would build it, in the order information moves through the system. Final choices depend on the tools a client already uses.
Documents land in object storage; OCR extracts text and layout, and personal data is masked before labeling. A versioned pipeline (Python, PyTorch, Hugging Face Transformers, MLflow) records each run's data, settings and scores. The approved model runs behind a FastAPI service.
Ingestion
Documents land in object storage. OCR extracts text and layout, and personal data is masked before labeling.
Labeling
An annotation tool holds the guidelines, records who labeled what and flags disagreements between reviewers.
Training
A versioned pipeline splits the data, fine-tunes the model and records each run's data, settings and scores.
Evaluation
A fixed test set produces precision and recall for every document type. A new model ships only if it beats the current one.
Serving
The approved model runs behind an internal API that returns a label and a confidence score, and low-confidence documents go to a review queue.
Proposed technologies
Plain tool names, not partnerships. Where a client already uses something that does the job, we use that instead.
- Python
- PyTorch
- Hugging Face Transformers
- Label Studio
- OCR engine
- MLflow
- FastAPI
- Docker
Important decisions
The trade-offs that shape the rest of the design, and why.
A model ships only if it beats the current one on the fixed test set.
Personal data is masked before anyone labels a document.
Outcome
This is a concept project. It hasn't been delivered for a client, so there are no results to report. It shows how we would approach this kind of brief.
More case studies
- Scheduling and dispatch platform for field service teamsConcept project, Logistics & supply chain. One system for planning jobs, guiding technicians and keeping customers informed.
- Knowledge assistant for customer supportConcept project, Startups & SaaS. A retrieval-augmented assistant that answers from help-center content and cites its sources.
- AI agent that qualifies property enquiriesConcept project, Real estate. Replies to new enquiries automatically, asks the questions a negotiator would, and books viewings for buyers who are ready.
- WhatsApp ordering assistant for restaurantsConcept project, Hospitality & travel. Customers order from the menu in a WhatsApp chat. The kitchen gets a clean ticket and the customer gets updates.
- Offline-first point of sale and inventory app for desktopConcept project, E-commerce & retail. A Windows and macOS app for small shops that keeps selling and counting stock when the internet drops.
- Online store for a specialty coffee roasterConcept project, E-commerce & retail. A direct-to-consumer store with subscriptions, brewing guides and launch ad creative.
- Brand identity and website for an independent advisory firmConcept project, Professional services. Positioning, identity and an expertise-led website for a specialist advisory practice.
- Launch campaign for a language-learning appConcept project, Education & e-learning. Positioning, short-form video and paid social planned for a new app's launch window.
Facing a similar problem?
Tell us about the problem you're solving. We'll reply with questions, a suggested approach and a clear next step.