Upload 80 files
Browse filesThis view is limited to 50 files because it contains too many changes. Β See raw diff
Files changed (50)
- .dockerignoreAdded+9
- .gitattributes+1
- .gitignoreAdded+2
- DockerfileAdded+64
- core/__init__.pyAdded
- core/__pycache__/__init__.cpython-312.pycAdded
- core/__pycache__/config.cpython-312.pycAdded
- core/__pycache__/config.cpython-313.pycAdded
- core/__pycache__/exceptions.cpython-312.pycAdded
- core/__pycache__/exceptions.cpython-313.pycAdded
- core/__pycache__/logging.cpython-312.pycAdded
- core/__pycache__/logging.cpython-313.pycAdded
- core/config.pyAdded+41
- core/exceptions.pyAdded+44
- core/logging.pyAdded+40
- main.pyAdded+79
- models/__init__.pyAdded
- models/__pycache__/__init__.cpython-312.pycAdded
- models/__pycache__/artifacts_loader.cpython-312.pycAdded
- models/__pycache__/artifacts_loader.cpython-313.pycAdded
- models/artifacts_loader.pyAdded+134
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/HybridNRMSelectiveClassifier_shap.htmlAdded+3
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/calibrator.joblibAdded+3
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/drift/schema_drift.logAdded+6
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/1_Pooling/config.jsonAdded+5
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/README.mdAdded+173
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/config.jsonAdded+30
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/config_sentence_transformers.jsonAdded+14
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/model.safetensorsAdded+3
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/modules.jsonAdded+20
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/sentence_bert_config.jsonAdded+10
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/tokenizer.jsonAdded
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/tokenizer_config.jsonAdded+23
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/hierarchy_map.jsonAdded+2300
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/label_encoder.joblibAdded+3
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/metadata.jsonAdded+112
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/preprocessor.joblibAdded+3
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/schema.jsonAdded+29
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/shap_background.joblibAdded+3
- models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/threshold.jsonAdded+3
- pyproject.tomlAdded+23
- routers/__init__.pyAdded
- routers/__pycache__/__init__.cpython-312.pycAdded
- routers/__pycache__/health.cpython-312.pycAdded
- routers/__pycache__/health.cpython-313.pycAdded
- routers/__pycache__/home.cpython-312.pycAdded
- routers/__pycache__/predict.cpython-312.pycAdded
- routers/__pycache__/predict.cpython-313.pycAdded
- routers/health.pyAdded+79
- routers/home.pyAdded+13
123456789.venvvenv__pycache__*.pyc.git.gitignore.env.pytest_cache*.log32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textmodels/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/HybridNRMSelectiveClassifier_shap.html filter=lfs diff=lfs merge=lfs -text
12# env
.venv12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364# ---- Stage 1: Builder ----FROM python:3.12-slim AS builder
# Copy uv binary from Astral's official imageCOPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /api
# Environment optimizationsENV PYTHONDONTWRITEBYTECODE=1ENV PYTHONUNBUFFERED=1
# Copy lockfile and project metadata first (to leverage caching)COPY uv.lock pyproject.toml ./
# Install dependencies only (non-editable, without project source)RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --locked --no-install-project --no-editable
# Copy API sourceCOPY . .
# Sync project into environment (non-editable)RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --locked --no-editable
# ---- Stage 2: Runtime ----FROM python:3.12-slim
# Install system dependencies for Chromium (Kaleido) and HealthcheckRUN apt-get update && apt-get install -y --no-install-recommends \ chromium \ curl \ && rm -rf /var/lib/apt/lists/*
# Copy uv binary again so runtime stage has itCOPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /api
# Copy virtual environment and app code from builderCOPY --from=builder /api/.venv /api/.venvCOPY --from=builder /api /api
# Ensure venv binaries are on PATHENV PATH="/api/.venv/bin:$PATH"ENV PYTHONDONTWRITEBYTECODE=1ENV PYTHONUNBUFFERED=1
# Expose app portEXPOSE 7860
# Silence CUDA and oneDNN warnings if not neededENV CUDA_VISIBLE_DEVICES=""ENV TF_ENABLE_ONEDNN_OPTS=0
# Liveness probe β instant check, no model dependencyHEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/api/v1/health/liveness || exit 1
# Start applicationCMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]1234567891011121314151617181920212223242526272829303132333435363738394041from pydantic_settings import BaseSettingsfrom pathlib import Pathimport osfrom functools import lru_cache
# Define Paths# Using __file__ to reliably get the project root.# api/core/config.py -> api/core -> apiBASE_DIR = Path(__file__).resolve().parent.parent
# ENV when using standalone uvicorn server running FastAPI in api directoryENV_PATH = Path(".env")
SAVE_MODELS = ( BASE_DIR / "models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/")
class Settings(BaseSettings): """ Application settings. """
PROJECT_NAME: str = "QS Selective Classification API" VERSION: str = "1.0.0" DESCRIPTION: str = "Intelligent BoQ routing and NRM hierarchy inference."
# Model configuration MODEL_DIR: Path = Path(os.getenv("MODEL_DIR", SAVE_MODELS))
class Config: env_file = ".env" case_sensitive = True
@lru_cache()def get_settings() -> Settings: return Settings()
settings = get_settings()1234567891011121314151617181920212223242526272829303132333435363738394041424344from fastapi import Request, HTTPExceptionfrom fastapi.responses import JSONResponseimport logging
logger = logging.getLogger(__name__)
class ModelPredictionError(Exception): """Raised when model prediction fails.""" def __init__(self, detail: str): self.detail = detail super().__init__(self.detail)
class ArtifactLoadError(Exception): """Raised when artifacts fail to load.""" def __init__(self, detail: str): self.detail = detail super().__init__(self.detail)
async def http_exception_handler(request: Request, exc: HTTPException): """ Custom handler for HTTP exceptions to ensure JSON response. """ logger.error(f"HTTPException: {exc.detail} - Path: {request.url.path}") return JSONResponse( status_code=exc.status_code, content={"detail": exc.detail}, )
async def generic_exception_handler(request: Request, exc: Exception): """ Catch-all exception handler for unhandled errors. """ logger.exception(f"Unhandled exception: {str(exc)} - Path: {request.url.path}") return JSONResponse( status_code=500, content={"detail": "Internal Server Error. Please check logs for more details."}, )
async def model_prediction_exception_handler(request: Request, exc: ModelPredictionError): logger.error(f"Model prediction error: {str(exc)}") return JSONResponse( status_code=500, content={"detail": "Error performing model prediction."}, )12345678910111213141516171819202122232425262728293031323334353637383940import loggingimport sysimport jsonfrom typing import Any, Dict
class JSONFormatter(logging.Formatter): """ Formatter that outputs JSON strings after parsing the LogRecord. """ def format(self, record: logging.LogRecord) -> str: log_record: Dict[str, Any] = { "timestamp": self.formatTime(record, self.datefmt), "level": record.levelname, "message": record.getMessage(), "module": record.module, "funcName": record.funcName, "lineNo": record.lineno, } if record.exc_info: log_record["exception"] = self.formatException(record.exc_info) return json.dumps(log_record)
def setup_logging(log_level: str = "INFO"): """ Setup structured logging. """ root_logger = logging.getLogger() root_logger.setLevel(log_level) handler = logging.StreamHandler(sys.stdout) formatter = JSONFormatter() handler.setFormatter(formatter) root_logger.handlers = [] root_logger.addHandler(handler) logging.getLogger("uvicorn.access").handlers = [] logging.getLogger("uvicorn.access").propagate = True12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import logging
import asyncio
from routers import health, predict, home
from contextlib import asynccontextmanager
from fastapi import FastAPI
# Import deployment functions
from models.artifacts_loader import get_artifacts
from core.config import settings
from core.logging import setup_logging
from core.exceptions import (
ModelPredictionError,
ArtifactLoadError,
generic_exception_handler,
model_prediction_exception_handler,
)
# Setup logging before app startup
setup_logging()
logger = logging.getLogger(__name__)
# -------------------------------------------------------------------------
# 1. Global State Management (The safe way to load ML models in APIs)
# -------------------------------------------------------------------------
@asynccontextmanager
async def lifespan(app: FastAPI):
"""
Lifespan context manager β non-blocking startup.
Model loading is fired as a background task so the server yields
immediately and can answer /health/liveness probes right away.
Traffic is withheld naturally by /health/readiness (returns 503)
until `artifacts.is_loaded` becomes True.
"""
logger.info(f"Starting {settings.PROJECT_NAME} v{settings.VERSION}")
async def _load():
try:
await asyncio.to_thread(get_artifacts().load_artifacts)
except ArtifactLoadError as e:
logger.error(f"Failed to load artifacts: {e.detail}")
except Exception as e:
logger.critical(f"Unhandled error loading artifacts: {e}")
# Fire-and-forget β the server becomes ready for probes instantly.
asyncio.create_task(_load())
yield # Server accepts connections NOW (before model loading completes)
# Cleanup on shutdown
logger.info("Shutting down API...")
get_artifacts().clear()
# -------------------------------------------------------------------------
# 2. App Initialization
# -------------------------------------------------------------------------
app = FastAPI(
title=settings.PROJECT_NAME,
description=settings.DESCRIPTION,
version=settings.VERSION,
lifespan=lifespan,
)
# Exception Handlers
app.add_exception_handler(Exception, generic_exception_handler)
app.add_exception_handler(ModelPredictionError, model_prediction_exception_handler)
# -------------------------------------------------------------------------
# 3. API Endpoints / Routers
# -------------------------------------------------------------------------
API_V1_PREFIX = "/api/v1"
app.include_router(home.router) # Serves HTML landing page β no versioning needed
app.include_router(health.router, prefix=API_V1_PREFIX) # GET /api/v1/health
app.include_router(predict.router, prefix=API_V1_PREFIX) # POST /api/v1/predict123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134import joblibimport jsonimport loggingfrom pathlib import Pathfrom typing import Optional, Union, Any
from utils.model import QSSelectiveCalibratedModelfrom utils.engines import QSRuleBasedFallbackEnginefrom utils.rules import QS_FALLBACK_RULESfrom core.config import settingsfrom core.exceptions import ArtifactLoadError
logger = logging.getLogger(__name__)
def load_qs_model(base: Union[str, Path]) -> QSSelectiveCalibratedModel: """ Safely reconstructs the hermetic QSSelectiveCalibratedModel from serialized artifacts. """ base = Path(base)
# 1. Load Scikit-Learn binaries calibrator = joblib.load(base / "calibrator.joblib") preprocessor = joblib.load(base / "preprocessor.joblib") label_encoder = joblib.load(base / "label_encoder.joblib")
# 2. Safely load JSON metadata using context managers and utf-8 with open(base / "threshold.json", "r", encoding="utf-8") as f: threshold = json.load(f)["threshold"]
with open(base / "hierarchy_map.json", "r", encoding="utf-8") as f: hierarchy_map = json.load(f)
with open(base / "schema.json", "r", encoding="utf-8") as f: schema = json.load(f)
with open(base / "metadata.json", "r", encoding="utf-8") as f: metadata = json.load(f)
# 3. Instantiate the hermetic model container model = QSSelectiveCalibratedModel( calibrator=calibrator, preprocessor=preprocessor, label_encoder=label_encoder, threshold=threshold, # Safely fall back to "Others" if loading an older metadata payload others_label=metadata.get("others_label", "Others"), nrm_hierarchy_map=hierarchy_map, model_version=metadata.get("model_version", "v1.0.0"), schema_version=metadata.get("schema_version", "v1"), hierarchy_version=metadata.get("hierarchy_version", "v1"), drift_log_path=base / "drift" / "schema_drift.log", )
# 4. Restore class-level schema definitions safely # NOTE: Do NOT overwrite model.TRAIN_SCHEMA here because __post_init__ # perfectly reconstructs it directly from the loaded preprocessor pipeline! model.RENAME_MAP = schema.get("RENAME_MAP", model.RENAME_MAP)
return model
class ModelArtifacts: """ Singleton-like container for ML artifacts. Loaded at startup. """
_instance = None
def __init__(self): self.model: Optional[QSSelectiveCalibratedModel] = None self.fallback_engine: Optional[QSRuleBasedFallbackEngine] = None self.shap_background: Any = None self.is_loaded = False
@classmethod def get_instance(cls): if cls._instance is None: cls._instance = cls() return cls._instance
def load_artifacts(self): """ Loads all artifacts from disk into memory. """ if self.is_loaded: logger.info("Artifacts already loaded.") return
model_dir = settings.MODEL_DIR logger.info(f"Loading models from {model_dir}")
try: # 1. Safely reconstruct the hermetic model self.model = load_qs_model(model_dir)
# 2. Instantiate the deterministic fallback engine self.fallback_engine = QSRuleBasedFallbackEngine(rule_map=QS_FALLBACK_RULES)
# 3. Load SHAP Background shap_path = model_dir / "shap_background.joblib" if shap_path.exists(): self.shap_background = joblib.load(shap_path) logger.info(f"Loaded SHAP background from {shap_path}") else: logger.warning( f"SHAP background not found at {shap_path}, SHAP explanations might fail." )
self.is_loaded = True logger.info( f"Successfully loaded model: {self.model.model_name} (version: {self.model.model_version}), Fallback Engine, and SHAP context." )
except Exception as e: logger.error(f"Failed to load artifacts: {e}") raise ArtifactLoadError(f"Critical error loading artifacts: {e}")
def clear(self): """ Unloads all ML artifacts from memory. """ logger.info("Unloading artifacts...") self.model = None self.fallback_engine = None self.shap_background = None self.is_loaded = False logger.info("Artifacts unloaded.")
# Global instancedef get_artifacts() -> ModelArtifacts: return ModelArtifacts.get_instance()123version https://git-lfs.github.com/spec/v1oid sha256:23ace9f3074f2d7bb925243f2b6111e72f92adaa1b33b6902a4860df2d94f310size 230262361123version https://git-lfs.github.com/spec/v1oid sha256:e3315e7a951e87de657be43c803bfd97ec8dceb0c156456b7e7fd637cd4d9f9dsize 28735596123456{"stage": "raw", "model_version": "v1.0.0", "schema_version": "v1", "hierarchy_version": "v1", "model_name": "QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0", "extra_in_raw": ["Amount", "Description", "Item", "Qty", "Rate", "RowNumber", "SheetName", "TabName", "Units"], "incoming_columns": ["Amount", "Description", "Item", "Qty", "Rate", "RowNumber", "SheetName", "TabName", "Units"], "normalized_columns": [], "final_columns": []}
{"stage": "post_normalization", "model_version": "v1.0.0", "schema_version": "v1", "hierarchy_version": "v1", "model_name": "QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0", "extra_after_normalization": ["amount", "rate", "row_number", "sheet_name", "tab_name"], "missing_after_normalization": [], "incoming_columns": ["Amount", "Description", "Item", "Qty", "Rate", "RowNumber", "SheetName", "TabName", "Units"], "normalized_columns": ["amount", "base_date", "basket_of_goods", "client_location", "description", "e", "element", "ge", "group_element", "item", "location", "notes", "package", "project", "qty", "rate", "rate_base_date", "rate_q1_2025", "rate_scope", "row_number", "sheet_name", "tab_name", "typology", "uom"], "final_columns": []}
{"stage": "raw", "model_version": "v1.0.0", "schema_version": "v1", "hierarchy_version": "v1", "model_name": "QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0", "extra_in_raw": ["Amount", "Description", "Item", "Qty", "Rate", "RowNumber", "SheetName", "TabName", "Units"], "incoming_columns": ["Amount", "Description", "Item", "Qty", "Rate", "RowNumber", "SheetName", "TabName", "Units"], "normalized_columns": [], "final_columns": []}
{"stage": "post_normalization", "model_version": "v1.0.0", "schema_version": "v1", "hierarchy_version": "v1", "model_name": "QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0", "extra_after_normalization": ["amount", "rate", "row_number", "sheet_name", "tab_name"], "missing_after_normalization": [], "incoming_columns": ["Amount", "Description", "Item", "Qty", "Rate", "RowNumber", "SheetName", "TabName", "Units"], "normalized_columns": ["amount", "base_date", "basket_of_goods", "client_location", "description", "e", "element", "ge", "group_element", "item", "location", "notes", "package", "project", "qty", "rate", "rate_base_date", "rate_q1_2025", "rate_scope", "row_number", "sheet_name", "tab_name", "typology", "uom"], "final_columns": []}
{"stage": "raw", "model_version": "v1.0.0", "schema_version": "v1", "hierarchy_version": "v1", "model_name": "QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0", "extra_in_raw": ["Amount", "Description", "Item", "Qty", "Rate", "RowNumber", "SheetName", "TabName", "Units"], "incoming_columns": ["Amount", "Description", "Item", "Qty", "Rate", "RowNumber", "SheetName", "TabName", "Units"], "normalized_columns": [], "final_columns": []}
{"stage": "post_normalization", "model_version": "v1.0.0", "schema_version": "v1", "hierarchy_version": "v1", "model_name": "QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0", "extra_after_normalization": ["amount", "rate", "row_number", "sheet_name", "tab_name"], "missing_after_normalization": [], "incoming_columns": ["Amount", "Description", "Item", "Qty", "Rate", "RowNumber", "SheetName", "TabName", "Units"], "normalized_columns": ["amount", "base_date", "basket_of_goods", "client_location", "description", "e", "element", "ge", "group_element", "item", "location", "notes", "package", "project", "qty", "rate", "rate_base_date", "rate_q1_2025", "rate_scope", "row_number", "sheet_name", "tab_name", "typology", "uom"], "final_columns": []}12345{
"embedding_dimension": 384,
"pooling_mode": "mean",
"include_prompt": true
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173---
language: en
license: apache-2.0
library_name: sentence-transformers
tags:
- sentence-transformers
- feature-extraction
- sentence-similarity
- transformers
datasets:
- s2orc
- flax-sentence-embeddings/stackexchange_xml
- ms_marco
- gooaq
- yahoo_answers_topics
- code_search_net
- search_qa
- eli5
- snli
- multi_nli
- wikihow
- natural_questions
- trivia_qa
- embedding-data/sentence-compression
- embedding-data/flickr30k-captions
- embedding-data/altlex
- embedding-data/simple-wiki
- embedding-data/QQP
- embedding-data/SPECTER
- embedding-data/PAQ_pairs
- embedding-data/WikiAnswers
pipeline_tag: sentence-similarity
---
# all-MiniLM-L6-v2
This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search.
## Usage (Sentence-Transformers)
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
```
pip install -U sentence-transformers
```
Then you can use the model like this:
```python
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
embeddings = model.encode(sentences)
print(embeddings)
```
## Usage (HuggingFace Transformers)
Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
```python
from transformers import AutoTokenizer, AutoModel
import torch
import torch.nn.functional as F
#Mean Pooling - Take attention mask into account for correct averaging
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
# Sentences we want sentence embeddings for
sentences = ['This is an example sentence', 'Each sentence is converted']
# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
model = AutoModel.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
# Tokenize sentences
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
# Compute token embeddings
with torch.no_grad():
model_output = model(**encoded_input)
# Perform pooling
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
# Normalize embeddings
sentence_embeddings = F.normalize(sentence_embeddings, p=2, dim=1)
print("Sentence embeddings:")
print(sentence_embeddings)
```
------
## Background
The project aims to train sentence embedding models on very large sentence level datasets using a self-supervised
contrastive learning objective. We used the pretrained [`nreimers/MiniLM-L6-H384-uncased`](https://huggingface.co/nreimers/MiniLM-L6-H384-uncased) model and fine-tuned in on a
1B sentence pairs dataset. We use a contrastive learning objective: given a sentence from the pair, the model should predict which out of a set of randomly sampled other sentences, was actually paired with it in our dataset.
We developed this model during the
[Community week using JAX/Flax for NLP & CV](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104),
organized by Hugging Face. We developed this model as part of the project:
[Train the Best Sentence Embedding Model Ever with 1B Training Pairs](https://discuss.huggingface.co/t/train-the-best-sentence-embedding-model-ever-with-1b-training-pairs/7354). We benefited from efficient hardware infrastructure to run the project: 7 TPUs v3-8, as well as intervention from Googles Flax, JAX, and Cloud team member about efficient deep learning frameworks.
## Intended uses
Our model is intended to be used as a sentence and short paragraph encoder. Given an input text, it outputs a vector which captures
the semantic information. The sentence vector may be used for information retrieval, clustering or sentence similarity tasks.
By default, input text longer than 256 word pieces is truncated.
## Training procedure
### Pre-training
We use the pretrained [`nreimers/MiniLM-L6-H384-uncased`](https://huggingface.co/nreimers/MiniLM-L6-H384-uncased) model. Please refer to the model card for more detailed information about the pre-training procedure.
### Fine-tuning
We fine-tune the model using a contrastive objective. Formally, we compute the cosine similarity from each possible sentence pairs from the batch.
We then apply the cross entropy loss by comparing with true pairs.
#### Hyper parameters
We trained our model on a TPU v3-8. We train the model during 100k steps using a batch size of 1024 (128 per TPU core).
We use a learning rate warm up of 500. The sequence length was limited to 128 tokens. We used the AdamW optimizer with
a 2e-5 learning rate. The full training script is accessible in this current repository: `train_script.py`.
#### Training data
We use the concatenation from multiple datasets to fine-tune our model. The total number of sentence pairs is above 1 billion sentences.
We sampled each dataset given a weighted probability which configuration is detailed in the `data_config.json` file.
| Dataset | Paper | Number of training tuples |
|--------------------------------------------------------|:----------------------------------------:|:--------------------------:|
| [Reddit comments (2015-2018)](https://github.com/PolyAI-LDN/conversational-datasets/tree/master/reddit) | [paper](https://arxiv.org/abs/1904.06472) | 726,484,430 |
| [S2ORC](https://github.com/allenai/s2orc) Citation pairs (Abstracts) | [paper](https://aclanthology.org/2020.acl-main.447/) | 116,288,806 |
| [WikiAnswers](https://github.com/afader/oqa#wikianswers-corpus) Duplicate question pairs | [paper](https://doi.org/10.1145/2623330.2623677) | 77,427,422 |
| [PAQ](https://github.com/facebookresearch/PAQ) (Question, Answer) pairs | [paper](https://arxiv.org/abs/2102.07033) | 64,371,441 |
| [S2ORC](https://github.com/allenai/s2orc) Citation pairs (Titles) | [paper](https://aclanthology.org/2020.acl-main.447/) | 52,603,982 |
| [S2ORC](https://github.com/allenai/s2orc) (Title, Abstract) | [paper](https://aclanthology.org/2020.acl-main.447/) | 41,769,185 |
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title, Body) pairs | - | 25,316,456 |
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title+Body, Answer) pairs | - | 21,396,559 |
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title, Answer) pairs | - | 21,396,559 |
| [MS MARCO](https://microsoft.github.io/msmarco/) triplets | [paper](https://doi.org/10.1145/3404835.3462804) | 9,144,553 |
| [GOOAQ: Open Question Answering with Diverse Answer Types](https://github.com/allenai/gooaq) | [paper](https://arxiv.org/pdf/2104.08727.pdf) | 3,012,496 |
| [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) (Title, Answer) | [paper](https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html) | 1,198,260 |
| [Code Search](https://huggingface.co/datasets/code_search_net) | - | 1,151,414 |
| [COCO](https://cocodataset.org/#home) Image captions | [paper](https://link.springer.com/chapter/10.1007%2F978-3-319-10602-1_48) | 828,395|
| [SPECTER](https://github.com/allenai/specter) citation triplets | [paper](https://doi.org/10.18653/v1/2020.acl-main.207) | 684,100 |
| [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) (Question, Answer) | [paper](https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html) | 681,164 |
| [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) (Title, Question) | [paper](https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html) | 659,896 |
| [SearchQA](https://huggingface.co/datasets/search_qa) | [paper](https://arxiv.org/abs/1704.05179) | 582,261 |
| [Eli5](https://huggingface.co/datasets/eli5) | [paper](https://doi.org/10.18653/v1/p19-1346) | 325,475 |
| [Flickr 30k](https://shannon.cs.illinois.edu/DenotationGraph/) | [paper](https://transacl.org/ojs/index.php/tacl/article/view/229/33) | 317,695 |
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (titles) | | 304,525 |
| AllNLI ([SNLI](https://nlp.stanford.edu/projects/snli/) and [MultiNLI](https://cims.nyu.edu/~sbowman/multinli/) | [paper SNLI](https://doi.org/10.18653/v1/d15-1075), [paper MultiNLI](https://doi.org/10.18653/v1/n18-1101) | 277,230 |
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (bodies) | | 250,519 |
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (titles+bodies) | | 250,460 |
| [Sentence Compression](https://github.com/google-research-datasets/sentence-compression) | [paper](https://www.aclweb.org/anthology/D13-1155/) | 180,000 |
| [Wikihow](https://github.com/pvl/wikihow_pairs_dataset) | [paper](https://arxiv.org/abs/1810.09305) | 128,542 |
| [Altlex](https://github.com/chridey/altlex/) | [paper](https://aclanthology.org/P16-1135.pdf) | 112,696 |
| [Quora Question Triplets](https://quoradata.quora.com/First-Quora-Dataset-Release-Question-Pairs) | - | 103,663 |
| [Simple Wikipedia](https://cs.pomona.edu/~dkauchak/simplification/) | [paper](https://www.aclweb.org/anthology/P11-2117/) | 102,225 |
| [Natural Questions (NQ)](https://ai.google.com/research/NaturalQuestions) | [paper](https://transacl.org/ojs/index.php/tacl/article/view/1455) | 100,231 |
| [SQuAD2.0](https://rajpurkar.github.io/SQuAD-explorer/) | [paper](https://aclanthology.org/P18-2124.pdf) | 87,599 |
| [TriviaQA](https://huggingface.co/datasets/trivia_qa) | - | 73,346 |
| **Total** | | **1,170,060,424** |123456789101112131415161718192021222324252627282930{
"add_cross_attention": false,
"architectures": [
"BertModel"
],
"attention_probs_dropout_prob": 0.1,
"bos_token_id": null,
"classifier_dropout": null,
"dtype": "float32",
"eos_token_id": null,
"gradient_checkpointing": false,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"hidden_size": 384,
"initializer_range": 0.02,
"intermediate_size": 1536,
"is_decoder": false,
"layer_norm_eps": 1e-12,
"max_position_embeddings": 512,
"model_type": "bert",
"num_attention_heads": 12,
"num_hidden_layers": 6,
"pad_token_id": 0,
"position_embedding_type": "absolute",
"tie_word_embeddings": true,
"transformers_version": "5.5.3",
"type_vocab_size": 2,
"use_cache": true,
"vocab_size": 30522
}1234567891011121314{
"__version__": {
"pytorch": "2.11.0+cpu",
"sentence_transformers": "5.4.0",
"transformers": "5.5.3"
},
"default_prompt_name": null,
"model_type": "SentenceTransformer",
"prompts": {
"document": "",
"query": ""
},
"similarity_fn_name": "cosine"
}123version https://git-lfs.github.com/spec/v1oid sha256:675124690d56e46f07b91be24721b00328dcf35c9962067d94d2894dc6970402size 908641761234567891011121314151617181920[
{
"idx": 0,
"name": "0",
"path": "",
"type": "sentence_transformers.base.modules.transformer.Transformer"
},
{
"idx": 1,
"name": "1",
"path": "1_Pooling",
"type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
},
{
"idx": 2,
"name": "2",
"path": "2_Normalize",
"type": "sentence_transformers.sentence_transformer.modules.normalize.Normalize"
}
]12345678910{
"transformer_task": "feature-extraction",
"modality_config": {
"text": {
"method": "forward",
"method_output_name": "last_hidden_state"
}
},
"module_output_name": "token_embeddings"
}1234567891011121314151617181920212223{
"backend": "tokenizers",
"cls_token": "[CLS]",
"do_basic_tokenize": true,
"do_lower_case": true,
"is_local": false,
"mask_token": "[MASK]",
"max_length": 128,
"model_max_length": 256,
"never_split": null,
"pad_to_multiple_of": null,
"pad_token": "[PAD]",
"pad_token_type_id": 0,
"padding_side": "right",
"sep_token": "[SEP]",
"stride": 0,
"strip_accents": null,
"tokenize_chinese_chars": true,
"tokenizer_class": "BertTokenizer",
"truncation_side": "right",
"truncation_strategy": "longest_first",
"unk_token": "[UNK]"
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300{
"Concrete - In situ": [
"1",
"Substructure",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Concrete formwork reinforcement": [
"2",
"Superstructure",
"2.05",
"External walls"
],
"Reinforcement - bars": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"Reinforcement - mesh": [
"2",
"Superstructure",
"2.02",
"Upper floors"
],
"Waterproofing": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Non structural screed": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Excavation": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Carting away - disposal": [
"1",
"Substructure",
"8.06",
"External drainage"
],
"Backfill": [
"1",
"Substructure",
"8.06",
"External drainage"
],
"Water stop": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Expansion joint": [
"2",
"Superstructure",
"2.01",
"Frame"
],
"Contraction joint": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Roof gutter": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Steel staircase": [
"2",
"Superstructure",
"2.04",
"Stairs and ramps"
],
"Staircase finishes": [
"2",
"Superstructure",
"2.04",
"Stairs and ramps"
],
"Timber balustrades": [
"2",
"Superstructure",
"2.04",
"Stairs and ramps"
],
"Masonry block wall": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Wall finishes": [
"2",
"Superstructure",
"2.02",
"Upper floors"
],
"Glass balustrades": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Ceilings and bulkheads - paint finish only": [
"3",
"Internal finishes",
"3.01",
"Wall finishes"
],
"Ceilings and bulkheads - gypsum": [
"3",
"Internal finishes",
"3.01",
"Wall finishes"
],
"Louvres": [
"2",
"Superstructure",
"2.06",
"Windows and external doors"
],
"Glass doors and windows": [
"2",
"Superstructure",
"2.08",
"Internal doors"
],
"Curtain walls": [
"2",
"Superstructure",
"2.06",
"Windows and external doors"
],
"Aluminum door": [
"2",
"Superstructure",
"2.08",
"Internal doors"
],
"Roller shutters": [
"2",
"Superstructure",
"2.01",
"Frame"
],
"Internal partitions - glazed": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"Internal partitions - gypsum": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"Internal partitions - cement board": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Metal doors": [
"2",
"Superstructure",
"2.06",
"Windows and external doors"
],
"Timber doors": [
"2",
"Superstructure",
"2.08",
"Internal doors"
],
"Floor finishes": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Skirting": [
"3",
"Internal finishes",
"3.02",
"Floor finishes"
],
"Ceilings and bulkheads - timber": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Ceilings and bulkheads - decorative pattern": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Furniture and furnishings": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Light fixtures": [
"2",
"Superstructure",
"2.04",
"Stairs and ramps"
],
"Sanitary ware fixtures": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Artwork": [
"4",
"Fittings, furnishings and equipment",
"4.01",
"Fittings, furnishings and equipment"
],
"AV Equipment": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Cold room": [
"5",
"Services",
"5.13",
"Specialist installations"
],
"Kitchen equipment and white goods": [
"5",
"Services",
"5.04",
"Water installations"
],
"Pipework - uPVC": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Cleanout": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Rainwater shoe": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Drains": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Vent terminal": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Oil and greas inceptor": [
"8",
"External works",
"8.07",
"External services"
],
"Gully trap": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Manholes": [
"8",
"External works",
"8.06",
"External drainage"
],
"STP - System": [
"5",
"Services",
"5.04",
"Water installations"
],
"Pipework - Condensate": [
"8",
"External works",
"8.06",
"External drainage"
],
"Pipework - PPR": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Pipework - insulation": [
"5",
"Services",
"5.04",
"Water installations"
],
"Pipework - HDPE": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Booster pump set": [
"5",
"Services",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Water heater": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Duct - Metal": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Duct - Flexible duct": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Duct - Insulation": [
"5",
"Services",
"5.04",
"Water installations"
],
"Duct - Motorized Fire Damper": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Duct - Motorized Damper": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Duct - diffuser": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Duct - Grille": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Duct - Linear flow bar": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Duct - Supply Air Register": [
"5",
"Services",
"5.07",
"Ventilation"
],
"VRF unit": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"DX unit": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Duct - Black steel": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Duct - Accessories": [
"2",
"Superstructure",
"2.06",
"Windows and external doors"
],
"HVAC - Fans": [
"5",
"Services",
"5.04",
"Water installations"
],
"Transformer": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Cabling - Copper Cable": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Distribution boards": [
"5",
"Services",
"5.13",
"Specialist installations"
],
"Motor control center": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Cable tray": [
"8",
"External works",
"8.07",
"External services"
],
"Electric switches": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Electrical Sockets": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Junction box": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Electrical push buttons": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Floor box": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Ceiling box": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Lighting control panel": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"UPS": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Generator": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Earthing system": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Lightning protection": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Distribution cabinet": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Network cabling infrastructure": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Network switches": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Telecommunication Outlet": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Wireless access point": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"RJ45 Outlet": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Optical network Unit": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Cabling - Fibre Optic": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Cabling - Cat 6": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Cable trunking": [
"8",
"External works",
"8.07",
"External services"
],
"Duct - uPVC": [
"8",
"External works",
"8.07",
"External services"
],
"Addressable fire alarm accessories": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"CCTV Camera": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Access control panel": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Door controller": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Door contacts": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Magnetic door lock": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Card reader": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Break glass for emergency release": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Pipework - Blacksteel": [
"8",
"External works",
"8.07",
"External services"
],
"Pipework - fittings, valves": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Fire hose": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Fire hydrant": [
"8",
"External works",
"8.07",
"External services"
],
"Fire pump": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Sprinkler": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Fire extinguisher": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Disc filter": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Irrigation sundries": [
"4",
"Fittings, furnishings and equipment",
"4.01",
"Fittings, furnishings and equipment"
],
"Bell - fire alarm": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Fire Fighter Telephone Jack": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Smoke detector": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"External facade finishes": [
"8",
"External works",
"8.05",
"External fixtures"
],
"Shadow gaps": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Structural steel": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Structural steel - sundries": [
"2",
"Superstructure",
"2.01",
"Frame"
],
"Structural steel - corrosion protection": [
"2",
"Superstructure",
"2.01",
"Frame"
],
"Structural steel - fire protection": [
"2",
"Superstructure",
"2.01",
"Frame"
],
"Profiled metal decking": [
"2",
"Superstructure",
"2.02",
"Upper floors"
],
"External facade - secondary support frame": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Metal handrails, balustrades": [
"8",
"External works",
"8.04",
"Fencing, railings and walls"
],
"Metal grating": [
"4",
"Fittings, furnishings and equipment",
"4.01",
"Fittings, furnishings and equipment"
],
"Cat ladder": [
"2",
"Superstructure",
"2.04",
"Stairs and ramps"
],
"Access hatch": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Access ladder": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Chequered metal plate": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Galvanised metal plate": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Bollard": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Horizontal metal fence": [
"8",
"External works",
"8.04",
"Fencing, railings and walls"
],
"Swing railing gate": [
"8",
"External works",
"8.04",
"Fencing, railings and walls"
],
"Roof covering": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Aluminium louvre": [
"2",
"Superstructure",
"2.06",
"Windows and external doors"
],
"Glass canopy": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Aluminium cladded canopy": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Doors - jamb": [
"2",
"Superstructure",
"2.08",
"Internal doors"
],
"Signage and wayfinding": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Bins": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Dewatering machine": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Baler machine": [
"5",
"Services",
"5.13",
"Specialist installations"
],
"Garbage shut": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Bin compactor": [
"5",
"Services",
"5.13",
"Specialist installations"
],
"Glass crusher": [
"5",
"Services",
"5.13",
"Specialist installations"
],
"Oil storage container": [
"5",
"Services",
"5.02",
"Services equipment"
],
"Storage container": [
"5",
"Services",
"5.13",
"Specialist installations"
],
"Waste storage cabinet": [
"5",
"Services",
"5.13",
"Specialist installations"
],
"Formwork": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"Concrete - precast": [
"4",
"Fittings, furnishings and equipment",
"4.01",
"Fittings, furnishings and equipment"
],
"Structural screed": [
"2",
"Superstructure",
"2.02",
"Upper floors"
],
"Steel ladder": [
"2",
"Superstructure",
"2.04",
"Stairs and ramps"
],
"steel safety post": [
"8",
"External works",
"8.05",
"External fixtures"
],
"Aluminium trellis": [
"2",
"Superstructure",
"2.06",
"Windows and external doors"
],
"Thermal insulation": [
"5",
"Services",
"5.04",
"Water installations"
],
"Rigid insulation": [
"3",
"Internal finishes",
"3.01",
"Wall finishes"
],
"Glass wool insulation": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Gravel": [
"8",
"External works",
"8.07",
"External services"
],
"Geotextile": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Fire stopping": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Doors - hardware set": [
"2",
"Superstructure",
"2.08",
"Internal doors"
],
"Cove lights": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Threshold": [
"3",
"Internal finishes",
"3.02",
"Floor finishes"
],
"Internal partitions - glazed shower partitions": [
"3",
"Internal finishes",
"3.01",
"Wall finishes"
],
"Fire blanket": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Pipework - PP-R PN-20": [
"5",
"Services",
"8.06",
"External drainage"
],
"Hose bib": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Water tank": [
"5",
"Services",
"5.04",
"Water installations"
],
"Goose neck air vent": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Vent cowl": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Rodding eye": [
"8",
"External works",
"8.06",
"External drainage"
],
"Thermostat": [
"5",
"Services",
"5.04",
"Water installations"
],
"Pipework - Refrigerant": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Duct - Volume Control Dampers": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Duct - Wire Mesh": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Split unit": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Busbar": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Cabling - Copper Conduit": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Isolator": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"ICT rack": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Site clearance": [
"8",
"External works",
"8.01",
"Site preperation works"
],
"Crushed aggregate , granular subbase": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Termite control": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Excavation support system": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Hoarding and site fence": [
"8",
"External works",
"8.04",
"Fencing, railings and walls"
],
"Laundry equipment": [
"4",
"Fittings, furnishings and equipment",
"4.01",
"Fittings, furnishings and equipment"
],
"Escalator and elevators": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"Duct - Backdraft damper": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Duct - Fire Damper": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Duct - End cap": [
"8",
"External works",
"8.07",
"External services"
],
"Duct - Sand Trap Fresh Air Louver": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Duct - Exhaust Air Louver": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Air cooled outdoor units": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Draw box": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Router": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"9U Security Rack": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Ceilings and bulkheads - cement board": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Drinking fountain": [
"5",
"Services",
"5.01",
"Sanitary installations"
],
"Circulating pump": [
"5",
"Services",
"5.04",
"Water installations"
],
"Duct - Sound Attenuator": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Air to air energy recovery equipment": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Photocell": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Flow switch": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Ceilings and bulkheads - metal pan": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Compartment floor box": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Skylight": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Acoustic ceiling tile": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Spout": [
"8",
"External works",
"8.06",
"External drainage"
],
"Air handling units": [
"4",
"Fittings, furnishings and equipment",
"4.01",
"Fittings, furnishings and equipment"
],
"Disabled toilet alarm": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Fire alarm control panel": [
"5",
"Services",
"5.09",
"Fuel installations"
],
"Swimming pool finishes": [
"3",
"Internal finishes",
"3.01",
"Wall finishes"
],
"Internal partitions - operable panel": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"Gym equipment": [
"4",
"Fittings, furnishings and equipment",
"4.01",
"Fittings, furnishings and equipment"
],
"Swimming pool - MEP": [
"5",
"Services",
"5.04",
"Water installations"
],
"Dish Antenna": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Background music": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Polycarbonate doors": [
"2",
"Superstructure",
"2.08",
"Internal doors"
],
"Pressure cleaning system": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Air curtain": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Storage shelving": [
"4",
"Fittings, furnishings and equipment",
"4.01",
"Fittings, furnishings and equipment"
],
"Strainer": [
"5",
"Services",
"5.04",
"Water installations"
],
"Flexible connector": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Pipework - Compressed air": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Pipework - Steam pipe": [
"5",
"Services",
"5.05",
"Heat source"
],
"Building Automation System (BAS)": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Workstation": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Printer": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Electrical/Mechanical Control Panels": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"42U Rack": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Telephone handset": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Wall guards": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"HVM control Panel": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Panic button": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Coping": [
"2",
"Superstructure",
"2.01",
"Frame"
],
"Power factor correction equipment": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Imported fill": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Flow indicator": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Anti vortex plate": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Ecentric reducer": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Transfer pump set": [
"5",
"Services",
"5.04",
"Water installations"
],
"Sump pump": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Pipework - PVC": [
"8",
"External works",
"8.06",
"External drainage"
],
"Pipework - LPG": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"LPG Sytem - accessories": [
"5",
"Services",
"5.09",
"Fuel installations"
],
"LPG storage tank": [
"5",
"Services",
"5.09",
"Fuel installations"
],
"Submersible pump": [
"8",
"External works",
"8.06",
"External drainage"
],
"Aluminium balustrades": [
"2",
"Superstructure",
"2.04",
"Stairs and ramps"
],
"Playground equipment": [
"8",
"External works",
"8.05",
"External fixtures"
],
"Shade structure": [
"8",
"External works",
"8.05",
"External fixtures"
],
"Fine grade, including infilling, excavation, disposal": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Gravel Mulc": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Asphalt paving": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Paving": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Landscape - play sand": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Synthetic lawn": [
"8",
"External works",
"8.01",
"Site preperation works"
],
"Chain-link metal fence": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Duct - Pipe for Road Crossings": [
"8",
"External works",
"8.07",
"External services"
],
"Trees - accessories and sundries": [
"8",
"External works",
"8.04",
"Fencing, railings and walls"
],
"Plant mix , sweet soil": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Landscape - organic mulch": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Shrubs and ground covers": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Lawn": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Trees": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Natural boulders": [
"8",
"External works",
"8.05",
"External fixtures"
],
"Bridges": [
"2",
"Superstructure",
"2.01",
"Frame"
],
"Road marking": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Curb stone": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Outfall structures": [
"8",
"External works",
"8.07",
"External services"
],
"Water meter": [
"5",
"Services",
"5.04",
"Water installations"
],
"Tie in connector": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Pipework - Fire Water Utility Distribution": [
"8",
"External works",
"8.06",
"External drainage"
],
"Duct - HDPE": [
"8",
"External works",
"8.07",
"External services"
],
"Cabling - Aluminium": [
"8",
"External works",
"8.07",
"External services"
],
"Cable Trench": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Pull box": [
"5",
"Services",
"5.14",
"Builder's work in connection with services"
],
"Planters": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Pile head treatment": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Concrete - Finish": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Cleaning works": [
"4",
"Fittings, furnishings and equipment",
"4.01",
"Fittings, furnishings and equipment"
],
"Pile": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Pile testing": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Deepwell": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Box culvert": [
"8",
"External works",
"8.07",
"External services"
],
"Parking accessories": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Irrigation system": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Y-strainer": [
"5",
"Services",
"5.04",
"Water installations"
],
"Landscape maintenance - irrigation": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Pile cap": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Internal partitions - wall support": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"Metal frame for ceilings": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"Metal coping": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"HPL Panel Cubicle Partitions": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"Chilled water pump": [
"5",
"Services",
"5.04",
"Water installations"
],
"Air cooled chillers": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Condenser water pumps": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Fan coil unit": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Closed cell rubber insulation": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Energy valve with BTU meter": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Pipework - Copper": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Water cooled chiller": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Air Outlet": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Domestic water pump": [
"5",
"Services",
"5.04",
"Water installations"
],
"Pipework - Steel": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Steel Puddle flange": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"RVC": [
"5",
"Services",
"5.07",
"Ventilation"
],
"SRD": [
"8",
"External works",
"8.06",
"External drainage"
],
"Waste Water Treatment Plant": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Grey water pump": [
"5",
"Services",
"5.04",
"Water installations"
],
"Treated water pump": [
"5",
"Services",
"5.04",
"Water installations"
],
"Sump": [
"8",
"External works",
"8.06",
"External drainage"
],
"Pipework - Cast iron": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Pipework - Galvanized iron": [
"5",
"Services",
"5.03",
"Disposal installations"
],
"Bladder tank": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Aerosol fire protection System": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"Main gas control panel": [
"5",
"Services",
"5.09",
"Fuel installations"
],
"Level indicators": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Miscellaneous lump sums": [
"5",
"Services",
"5.09",
"Fuel installations"
],
"BMS": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Termination kits": [
"8",
"External works",
"8.07",
"External services"
],
"Cable ladder": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Motor control center panels": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Disconnect Switches": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Power Outlet": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Fire alarm repeater panel": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Data/ IT Rooms Network RACKS": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"EV charging station": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Aluminium busway system": [
"5",
"Services",
"5.11",
"Fire and lighting protection"
],
"TAP-Off Units Supply and installation of Busway Trunking tap-off unit": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Reducer unit": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Switchgear connection box": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Transformer connection box": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Pipework - EMT FLEXIBLE": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Acoustic Insulation": [
"5",
"Services",
"5.04",
"Water installations"
],
"Flashings": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Plaster": [
"2",
"Superstructure",
"2.07",
"Internal walls and partitions"
],
"Pipework - Thermal": [
"5",
"Services",
"5.04",
"Water installations"
],
"Duct - system": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"Glass break sensor": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Damp Proof": [
"3",
"Internal finishes",
"3.02",
"Floor finishes"
],
"Hardscape": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Wood handrails": [
"8",
"External works",
"8.05",
"External fixtures"
],
"Testing & Commisioning": [
"7",
"Works to existing buildings",
"7.01",
"Minor demolition works and alteration works"
],
"Door Extra Treatments": [
"2",
"Superstructure",
"2.08",
"Internal doors"
],
"Irrigation ducts": [
"8",
"External works",
"8.03",
"Soft landscaping, planting and irrigation systems"
],
"Alarm panel": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Feature Column": [
"2",
"Superstructure",
"2.01",
"Frame"
],
"Special Masonry": [
"2",
"Superstructure",
"2.05",
"External walls"
],
"Roof Structure - Timber": [
"2",
"Superstructure",
"2.01",
"Frame"
],
"Timber Floors": [
"2",
"Superstructure",
"2.02",
"Upper floors"
],
"Gate": [
"8",
"External works",
"8.04",
"Fencing, railings and walls"
],
"Water feature": [
"5",
"Services",
"5.13",
"Specialist installations"
],
"Feature Wall": [
"8",
"External works",
"8.04",
"Fencing, railings and walls"
],
"Pipework - stormwater": [
"8",
"External works",
"8.06",
"External drainage"
],
"Specialist Finishes": [
"8",
"External works",
"8.05",
"External fixtures"
],
"Fa\u00e7ade Lighting": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Louvres Door": [
"2",
"Superstructure",
"2.08",
"Internal doors"
],
"Fa\u00e7ade Glazing": [
"2",
"Superstructure",
"2.03",
"Roofs"
],
"Fuel tank": [
"5",
"Services",
"5.09",
"Fuel installations"
],
"Boulders": [
"8",
"External works",
"8.02",
"Roads, paths, pavings and surfacings"
],
"Cable conduit": [
"8",
"External works",
"8.07",
"External services"
],
"Dayworks - Labour": [
"9",
"Dayworks",
"99.0",
"Dayworks"
],
"Dayworks - Material": [
"9",
"Dayworks",
"99.0",
"Dayworks"
],
"Dayworks - Plant & Equipment": [
"99",
"Dayworks",
"99.0",
"Dayworks"
],
"Basement Excavation": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Rock Excavation": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Cut & Fill": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"Elevated parking": [
"1",
"Substructure",
"1.01",
"Substructure"
],
"HVAC - Pressurization Unit": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"BWIC": [
"5",
"Services",
"5.14",
"Builder's work in connection with services"
],
"Electrical - load panels": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Cabling - earthing": [
"8",
"External works",
"8.07",
"External services"
],
"Coring": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"Dayworks": [
"9",
"Dayworks",
"99.0",
"Dayworks"
],
"HVAC - Miscellaneous": [
"5",
"Services",
"5.06",
"Space heating and air conditioning"
],
"HVAC - Ecology units": [
"5",
"Services",
"5.07",
"Ventilation"
],
"Ceiling finishes": [
"3",
"Internal finishes",
"3.03",
"Ceiling finishes"
],
"ELV systems": [
"5",
"Services",
"5.12",
"Communication, security and control systems"
],
"ICT Rack": [
"5",
"Services",
"5.08",
"Electrical installations"
],
"Others": [
9999,
"Others",
99.99,
"Others"
]
}123version https://git-lfs.github.com/spec/v1oid sha256:5dc0e296002374267213389f07967b2fb85c83df5954e310aacebd95762a7cc8size 2611123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112{
"model_version": "v1.0.0",
"model_name": "QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0",
"schema_version": "v1",
"hierarchy_version": "v1",
"threshold": 0.4,
"n_classes": 101,
"classes": [
"AV Equipment",
"Access control panel",
"Addressable fire alarm accessories",
"Aerosol fire protection System",
"Air cooled outdoor units",
"Air handling units",
"Aluminium louvre",
"Backfill",
"Bins",
"Building Automation System (BAS)",
"CCTV Camera",
"Cable tray",
"Cabling - Cat 6",
"Cabling - Copper Cable",
"Ceilings and bulkheads - gypsum",
"Ceilings and bulkheads - paint finish only",
"Concrete - In situ",
"Concrete - precast",
"Concrete formwork reinforcement",
"Data/ IT Rooms Network RACKS",
"Dayworks",
"Dayworks - Material",
"Disconnect Switches",
"Distribution boards",
"Doors - hardware set",
"Drains",
"Duct - Accessories",
"Duct - Backdraft damper",
"Duct - Fire Damper",
"Duct - Flexible duct",
"Duct - Grille",
"Duct - Insulation",
"Duct - Metal",
"Duct - Motorized Damper",
"Duct - Motorized Fire Damper",
"Duct - Sand Trap Fresh Air Louver",
"Duct - Sound Attenuator",
"Duct - Supply Air Register",
"Duct - Volume Control Dampers",
"Duct - Wire Mesh",
"Duct - diffuser",
"Electric switches",
"Electrical - load panels",
"Electrical Sockets",
"Escalator and elevators",
"Excavation",
"External facade finishes",
"Fan coil unit",
"Fa\u00e7ade Glazing",
"Fire extinguisher",
"Floor finishes",
"Formwork",
"Furniture and furnishings",
"Glass doors and windows",
"HVAC - Fans",
"Hardscape",
"Internal partitions - gypsum",
"Irrigation system",
"Isolator",
"Kitchen equipment and white goods",
"Light fixtures",
"Lighting control panel",
"Manholes",
"Masonry block wall",
"Metal doors",
"Metal handrails, balustrades",
"Motor control center",
"Motor control center panels",
"Non structural screed",
"Others",
"Pipework - Blacksteel",
"Pipework - Condensate",
"Pipework - HDPE",
"Pipework - PP-R PN-20",
"Pipework - PPR",
"Pipework - Refrigerant",
"Pipework - fittings, valves",
"Pipework - uPVC",
"Plaster",
"RJ45 Outlet",
"Reinforcement - bars",
"Sanitary ware fixtures",
"Shrubs and ground covers",
"Signage and wayfinding",
"Skirting",
"Smoke detector",
"Split unit",
"Sprinkler",
"Staircase finishes",
"Structural screed",
"Structural steel",
"Structural steel - fire protection",
"Sump pump",
"Swimming pool - MEP",
"Thermal insulation",
"Threshold",
"Timber doors",
"Trees",
"VRF unit",
"Wall finishes",
"Waterproofing"
],
"others_label": "Others"
}123version https://git-lfs.github.com/spec/v1oid sha256:edee069390cd5759770360b8605daacc843b4fa8ac4f9c0359aff6bedf7cd28bsize 118471234567891011121314151617181920212223242526272829{
"TRAIN_SCHEMA": [
"ge",
"group_element",
"e",
"element",
"description",
"item",
"uom",
"qty",
"rate_base_date",
"rate_q1_2025",
"project",
"typology",
"location",
"base_date",
"package",
"rate_scope",
"client_location",
"notes",
"basket_of_goods"
],
"RENAME_MAP": {
"desc": "description",
"items": "item",
"units": "uom",
"quantity": "qty"
}
}123version https://git-lfs.github.com/spec/v1oid sha256:34414bbf24f5440e83517c3d2a383c26d411914af6816211125ac951eb6999c4size 680641123{
"threshold": 0.4
}1234567891011121314151617181920212223[project]name = "api"version = "0.1.0"description = "QS BoQ Predictor API"readme = "README.md"requires-python = "==3.12.13"dependencies = [ "fastapi[standard]>=0.136.1", "fastparquet>=2026.5.0", "jinja2>=3.1.6", "joblib==1.5.3", "kaleido>=1.3.0", "openpyxl>=3.1.5", "pandas>=3.0.3", "plotly>=6.7.0", "scikit-learn>=1.8.0", "sentence-transformers>=5.5.0", "shap>=0.51.0", "xgboost==3.2.0",]
[tool.fastapi]entrypoint = "main:app"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879from fastapi import APIRouterfrom fastapi.responses import JSONResponsefrom datetime import datetimefrom core.config import settingsfrom models.artifacts_loader import get_artifacts
router = APIRouter(prefix="/health", tags=["System"])
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# Liveness probe β MUST be instant, no heavy checks.# The platform uses this to know if the *process* is alive.# If this times out, the container gets killed and restarted.# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ@router.get("/liveness", summary="Liveness probe")async def liveness(): """ Minimal liveness probe β always returns 200 immediately. Used by the cloud platform to confirm the process is running. """ return {"status": "alive", "timestamp": datetime.utcnow().isoformat() + "Z"}
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# Readiness probe β checks if the app can actually serve traffic.# Returns 503 while artifacts are still loading so the platform# withholds traffic until the model is warm.# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ@router.get("/readiness", summary="Readiness probe")async def readiness(): """ Readiness probe β returns 200 only when all ML artifacts are loaded. The platform will not route traffic until this returns 200. """ artifacts = get_artifacts() if not artifacts.is_loaded: return JSONResponse( status_code=503, content={ "status": "not_ready", "message": "ML artifacts are still loading. Retry in a moment.", "timestamp": datetime.utcnow().isoformat() + "Z", } ) return {"status": "ready", "timestamp": datetime.utcnow().isoformat() + "Z"}
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# Full health β rich observability payload for dashboards / ops teams.# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ@router.get("", summary="Full health status")async def health_check(): """ Comprehensive health check: artifact status, model details, and timestamps. """ artifacts = get_artifacts() status = "healthy" if artifacts.is_loaded else "degraded"
health_status = { "status": status, "timestamp": datetime.utcnow().isoformat() + "Z", "app": settings.PROJECT_NAME, "version": settings.VERSION, "artifacts_loaded": artifacts.is_loaded, "artifacts_details": { "model_ready": artifacts.model is not None, "fallback_engine_ready": artifacts.fallback_engine is not None, "shap_background_ready": artifacts.shap_background is not None, } }
if artifacts.model is not None: health_status["model_details"] = { "name": artifacts.model.model_name, "version": artifacts.model.model_version, "schema_version": getattr(artifacts.model, "schema_version", "v1"), "hierarchy_version": getattr(artifacts.model, "hierarchy_version", "v1"), }
return health_status12345678910111213from fastapi import APIRouter, Requestfrom fastapi.responses import HTMLResponsefrom fastapi.templating import Jinja2Templatesfrom pathlib import Path
router = APIRouter()BASE_PATH = Path(__file__).resolve().parent.parenttemplates = Jinja2Templates(directory=str(BASE_PATH / "templates"))
@router.get("/", response_class=HTMLResponse, include_in_schema=False)async def home(request: Request): return templates.TemplateResponse(request=request, name="index.html", context={}).dockerignoreAdded+9
.gitattributes+1
.gitignoreAdded+2
DockerfileAdded+64
core/__init__.pyAdded
core/__pycache__/__init__.cpython-312.pycAdded
core/__pycache__/config.cpython-312.pycAdded
core/__pycache__/config.cpython-313.pycAdded
core/__pycache__/exceptions.cpython-312.pycAdded
core/__pycache__/exceptions.cpython-313.pycAdded
core/__pycache__/logging.cpython-312.pycAdded
core/__pycache__/logging.cpython-313.pycAdded
core/config.pyAdded+41
core/exceptions.pyAdded+44
core/logging.pyAdded+40
main.pyAdded+79
models/__init__.pyAdded
models/__pycache__/__init__.cpython-312.pycAdded
models/__pycache__/artifacts_loader.cpython-312.pycAdded
models/__pycache__/artifacts_loader.cpython-313.pycAdded
models/artifacts_loader.pyAdded+134
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/HybridNRMSelectiveClassifier_shap.htmlAdded+3
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/calibrator.joblibAdded+3
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/drift/schema_drift.logAdded+6
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/1_Pooling/config.jsonAdded+5
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/README.mdAdded+173
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/config.jsonAdded+30
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/config_sentence_transformers.jsonAdded+14
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/model.safetensorsAdded+3
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/modules.jsonAdded+20
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/sentence_bert_config.jsonAdded+10
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/tokenizer.jsonAdded
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/embedding_model/SentenceTransformer/all-MiniLM-L6-v2/tokenizer_config.jsonAdded+23
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/hierarchy_map.jsonAdded+2300
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/label_encoder.joblibAdded+3
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/metadata.jsonAdded+112
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/preprocessor.joblibAdded+3
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/schema.jsonAdded+29
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/shap_background.joblibAdded+3
models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/threshold.jsonAdded+3
pyproject.tomlAdded+23
routers/__init__.pyAdded
routers/__pycache__/__init__.cpython-312.pycAdded
routers/__pycache__/health.cpython-312.pycAdded
routers/__pycache__/health.cpython-313.pycAdded
routers/__pycache__/home.cpython-312.pycAdded
routers/__pycache__/predict.cpython-312.pycAdded
routers/__pycache__/predict.cpython-313.pycAdded
routers/health.pyAdded+79
routers/home.pyAdded+13