Semantic anomaly detection using vector databases
Traditional anomaly-detection systems rely on statistical thresholds, rule-based matching, or supervised learning, but they often fail to capture semantic relationships embedded in high-dimensional scientific and environmental datasets. With the rise of deep learning, high-dimensional vector embeddings have emerged as a powerful representation for encoding contextual relationships between data points. Vector databases are explicitly designed to store and retrieve these embeddings efficiently using Approximate Nearest Neighbor (ANN) search structures such as HNSW and IVF. This study evaluated semantic anomaly detection using PostgreSQL-pgvector and compared it to classical relational anomaly detection implemented in standard PostgreSQL. A dataset of 100,000 environmental sensor readings (temperature, humidity, CO₂, VOC, and PM2.5) was transformed into embeddings using a transformer-based encoder. Anomaly detection was performed by measuring vector distances between incoming observations and the semantic neighborhood of historical data. Results showed that vector-based retrieval achieved 94.6% anomaly-detection accuracy compared to 62.3% for rule-based and 74.1% for statistical Z-score methods. Query latency improved from 242 ms (RDBMS scan) to 14 ms using pgvector HNSW indexing. The findings demonstrated that vector databases enable semantically aware, scalable anomaly detection for scientific and environmental monitoring systems
Authors
- Okonta Samson Iwenyan
Publication Details
- Journal
- Journal of ICT Development Applications and Research
- Published
- 2025-12-31
- DOI
- https://doi.org/10.47524/jictdar.v7i2.86
- Primary Topic
- Anomaly Detection Techniques and Applications
- Type
- article
- Field-Weighted Citation Impact
- 0.00