Skip to main content

02 / projects / semantic

Semantic Comment Analyzer

Explainable Sub-15ms NLP Intent Engine. Dense vector intent classification combining MiniLM-L6-v2 embeddings with an L2 logistic regression head, giving sub-15ms CPU latency with exact token-level explainability.

Python 3.13FastAPISentence-TransformersScikit-LearnRoBERTaPandasReact 18
01Context

Problem & hardware constraints

Dense vector intent classification combining MiniLM-L6-v2 embeddings with an L2 logistic regression head, giving sub-15ms CPU latency with exact token-level explainability.

02Layers

System architecture & pipeline

The runtime is structured into decoupled execution layers to avoid latency jitter and unpredictable heap fragmentation:

01/Text Preprocessing & Normalization

Cleans noisy input text, strips unicode artifacts, and tokenizes in single-pass CPython routines.

02/Bi-Encoder Vector Extraction

Generates 384-dimensional dense vectors using a pruned MiniLM encoder tuned for sentence-level semantic intent.

03/L2 Logistic Decision Head

Computes classification probabilities via optimized matrix multiplications with calibrated threshold cutoffs.

04/Word Occlusion Explainability

Runs selective word masking to surface exact token contributions without the overhead of heavy SHAP approximations.

03Decisions

Engineering trade-offs & alternatives rejected

Logistic regression head over end-to-end transformer fine-tuning

Fine-tuning the whole transformer made inference 6x slower and required GPU hardware. Keeping the transformer frozen and training a logistic regression head on cached embeddings yielded 94% accuracy with 15ms CPU latency.

04Field Notes

Field notes & edge cases

  • 01Token explainability does not need 1,000 Monte Carlo samples. Occluding the top 5 noun and verb tokens gives 95% of the same insight with 1% of the compute.

— / deploy

Explore source & live runtime

Source code, static headers, and benchmarks are open for review on GitHub.

Other systems

Keep exploring