INSUREOS Models β Complete Insurance AI Training Pipeline
Created by Bytical AI β AI agents that run insurance operations.
Start Here
If you are trying to understand the Hugging Face repos, start with LEARN.md.
That guide explains, in plain English, why the project is split across model, dataset, code, and search repos, and it walks through the concepts, data, and training code behind each model in this repository.
Overview
INSUREOS is a complete AI/ML training and inference pipeline for UK insurance operations. This repository contains all source code for data generation, model training, evaluation, data collection, and a hybrid search engine.
Model Suite
| Model | HuggingFace | Task | Key Metric |
|---|---|---|---|
| InsureLLM-4B | piyushptiwari/InsureLLM-4B | Insurance domain LLM | ROUGE-1: 0.384 |
| InsureDocClassifier | piyushptiwari/InsureDocClassifier | 12-class document classification | F1: 1.0 |
| InsureNER | piyushptiwari/InsureNER | 13-entity NER | F1: 1.0 |
| InsureFraudNet | piyushptiwari/InsureFraudNet | Fraud detection (3 LoB) | AUC-ROC: 1.0 |
| InsurePricing | piyushptiwari/InsurePricing | Premium pricing (GLM + EBM) | MAE: Β£11,132 |
| InsureSearch | piyushptiwari/insureos-search-engine | Hybrid search engine | 33K docs indexed |
Training Dataset
piyushptiwari/insureos-training-data β 10K SFT, 5K DPO, 50K tabular, 10K docs, 8K NER
Repository Structure
insureos-models/
βββ data/ # Synthetic data generation
β βββ constants.py # UK insurance constants (regions, perils, regulators)
β βββ gen_sft.py # Generate SFT instruction-response pairs
β βββ gen_dpo.py # Generate DPO preference pairs
β βββ gen_documents.py # Generate insurance documents (12 classes)
β βββ gen_ner.py # Generate NER-annotated text
β βββ gen_tabular.py # Generate claims tabular data
β βββ generate_all.py # Run all generators
β
βββ collect/ # Real-world data collection
β βββ config.py # Scraping targets and configuration
β βββ scraper_base.py # Base HTTP scraper with caching
β βββ convert_sft.py # Convert raw docs β SFT/DPO format
β βββ run_fast.py # Fast collection orchestrator
β βββ sources/ # Per-source scrapers
β βββ wikipedia.py # Wikipedia insurance articles
β βββ legislation.py # UK legislation (legislation.gov.uk)
β βββ fca.py # FCA Handbook
β βββ hf_datasets.py # HuggingFace insurance datasets
β βββ rss_news.py # Insurance news RSS feeds
β βββ education.py # Insurance education resources
β
βββ training/ # Model training scripts
β βββ qlora_finetune.py # QLoRA fine-tuning (Qwen3-4B)
β βββ dpo_train.py # DPO alignment training
β βββ retrain_realworld.py # Real-world data retraining
β βββ doc_classifier.py # ModernBERT document classifier
β βββ ner_model.py # ModernBERT NER model
β βββ fraud_model.py # XGBoost + Isolation Forest fraud
β βββ pricing_glm.py # Tweedie GLM + EBM pricing
β βββ distill.py # Model distillation (experimental)
β
βββ evaluation/ # Evaluation suite
β βββ run_eval.py # Full multi-model evaluation
β βββ results/ # Evaluation results (JSON)
β
βββ search/ # Hybrid search engine
β βββ config.py # Search configuration
β βββ embedder.py # BGE-small-en-v1.5 embedding service
β βββ bm25.py # Custom Okapi BM25 implementation
β βββ vector_store.py # Qdrant vector store
β βββ reranker.py # Cross-encoder reranker
β βββ hybrid_engine.py # RRF fusion (vector + BM25 + reranker)
β βββ indexer.py # Document ingestion pipeline
β βββ models.py # Pydantic data models
β βββ api.py # FastAPI REST API
β
βββ serve/ # Model serving
β βββ api.py # FastAPI inference endpoints
β
βββ scripts/ # Automation
βββ setup.sh # Environment setup (NVIDIA, Python, deps)
βββ train_all.sh # Full training pipeline script
Quick Start
1. Environment Setup
# Create virtual environment
python3 -m venv .venv && source .venv/bin/activate
# Install dependencies
pip install torch transformers trl peft bitsandbytes
pip install xgboost scikit-learn interpret
pip install sentence-transformers qdrant-client fastapi uvicorn
2. Generate Training Data
python -m data.generate_all
# Outputs: data/output/ (SFT, DPO, docs, NER, tabular)
3. Train Models
# Train all models sequentially
bash scripts/train_all.sh
# Or individually:
python training/qlora_finetune.py # InsureLLM QLoRA
python training/dpo_train.py # InsureLLM DPO
python training/doc_classifier.py # Document classifier
python training/ner_model.py # NER model
python training/fraud_model.py # Fraud detection
python training/pricing_glm.py # Pricing models
4. Evaluate
python evaluation/run_eval.py
# Results saved to evaluation/results/
5. Run Search Engine
# Index documents
python search/indexer.py
# Start API
python search/api.py
# API at http://localhost:8900
# Endpoints: /search, /search/vector, /search/keyword, /suggest, /facets, /stats
Search Engine β InsureSearch
A hybrid search engine rivaling Azure AI Search, built entirely on open-source components:
| Component | Technology | Details |
|---|---|---|
| Vector Search | BGE-small-en-v1.5 (384-dim) + Qdrant | Semantic similarity |
| Keyword Search | Custom Okapi BM25 | Insurance-aware tokenization |
| Reranking | cross-encoder/ms-marco-MiniLM-L-6-v2 | Cross-encoder reranking |
| Fusion | Reciprocal Rank Fusion (RRF) | Vector 60% + BM25 40% |
| API | FastAPI | REST API with facets, suggestions |
Index stats: 33,034 chunks from 31,679 documents, 51,640 BM25 terms.
Training Pipeline
Stage 1: Synthetic Data Generation
βββ 10K SFT instruction-response pairs
βββ 5K DPO preference pairs
βββ 50K tabular claims (Motor/Property/Liability)
βββ 10K insurance documents (12 classes)
βββ 8K NER-annotated texts (13 entity types)
Stage 2: QLoRA Fine-Tuning β Qwen3-4B
βββ rank=64, alpha=128, all-linear targets
βββ 2 epochs, batch=2, grad_accum=4
βββ Final: train_loss=0.012, eval_loss=0.118
βββ Token accuracy: 95.88%
Stage 3: DPO Alignment
βββ 5K preference pairs
βββ 149 steps, reward_accuracy=1.0
βββ Reward margin: 26.76
Stage 4: Real-World Data Collection
βββ Wikipedia (150 docs), UK Legislation (692)
βββ HuggingFace datasets (31,060), RSS (50), Education (88)
βββ Converted to 3,685 SFT + 776 DPO pairs
βββ Quality filtered (English-only, no echo responses)
Stage 5: Real-World Retraining
βββ 876 steps on real-world SFT data
βββ Claims process score improved 0.40 β 0.60
Stage 6: Specialized Models (parallel)
βββ FraudNet: XGBoost + Isolation Forest β AUC-ROC 1.0
βββ PricingGLM: Tweedie GLM + EBM β MAE Β£11,132
βββ DocClassifier: ModernBERT β F1 1.0
βββ InsureNER: ModernBERT β F1 1.0
Tech Stack
- LLM: Qwen3-4B + QLoRA + DPO (PyTorch, Transformers, TRL, PEFT, bitsandbytes)
- Classification & NER: ModernBERT-base (Transformers)
- Fraud Detection: XGBoost + Isolation Forest (scikit-learn)
- Pricing: Tweedie GLM (scikit-learn) + EBM (InterpretML)
- Search: BGE-small-en-v1.5 + Qdrant + BM25 + cross-encoder
- Training GPU: NVIDIA Tesla T4 16GB
Citation
@misc{bytical2026insureos,
title={INSUREOS: A Complete AI/ML Suite for UK Insurance Operations},
author={Bytical AI},
year={2026},
url={https://huggingface.co/piyushptiwari/insureos-models}
}
About Bytical AI
Bytical builds AI agents that run insurance operations β claims automation, underwriting intelligence, digital sales, and core system modernization for insurers across the UK and Europe. Microsoft AI Partner | NVIDIA | Salesforce.