Metadata-Version: 2.4
Name: sre-embedding-model
Version: 1.0.0
Summary: Fine-tuned SRE sentence embedding model — semantic search & similarity for Site Reliability Engineering
Author-email: Senthil Kumar Thanapal <senthilthepro@hotmail.com>
License: Apache-2.0
Project-URL: Homepage, https://pypi.org/project/sre-embedding-model/
Project-URL: Repository, https://github.com/senthilthepro/sre-embedding-model
Project-URL: Bug Tracker, https://github.com/senthilthepro/sre-embedding-model/issues
Keywords: sre,site-reliability-engineering,embedding,sentence-transformers,semantic-search,nlp,kubernetes,observability,incident-management,minilm,fine-tuned,vector-search,rag
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: sentence-transformers>=2.2.0
Requires-Dist: numpy>=1.21.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: build; extra == "dev"
Dynamic: license-file

# sre-embedding-model

**Fine-tuned sentence embedding model for Site Reliability Engineering (SRE)**

[![PyPI version](https://badge.fury.io/py/sre-embedding-model.svg)](https://pypi.org/project/sre-embedding-model/)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)

---

## What is this?

A sentence embedding model fine-tuned on **636 SRE domain pairs** across **16 domains**.
It understands SRE vocabulary out-of-the-box — no setup, no internet, weights bundled inside the package.

**Base model:** `all-MiniLM-L6-v2` (Microsoft, Apache 2.0) — 22M parameters, 384-dim embeddings.

**Trained on:**
Kubernetes pod states & errors · Observability & metrics · Incident management & RCA ·
APM & distributed tracing · Splunk & log analysis · Java / Spring Boot · MySQL · Kafka ·
API Gateway · CI/CD · CMDB · Cloud platforms · Security

---

## Install

```bash
pip install sre-embedding-model
```

Model weights (~88 MB) are bundled — **no internet connection required** after install.

---

## Quick Start

```python
from sre_embedding_model import SREModel

model = SREModel()

# ── Similarity between two SRE texts ─────────────────────────────────────────
score = model.similarity("pod keeps crashing", "CrashLoopBackOff")
print(score)  # → 0.961

score = model.similarity("mean time to recover", "MTTR")
print(score)  # → 0.965

# ── Semantic search — rank docs by query ──────────────────────────────────────
runbooks = [
    "CrashLoopBackOff — container restart loop runbook",
    "OOMKilled — container memory limit exceeded",
    "Evicted — node resource pressure",
    "MySQL lock wait timeout — transaction blocked",
]
results = model.search("container is being killed due to memory", runbooks, top_k=3)
for doc, score in results:
    print(f"{score:.3f}  {doc}")
# → 0.924  OOMKilled — container memory limit exceeded
# → 0.871  CrashLoopBackOff — container restart loop runbook
# → 0.843  Evicted — node resource pressure

# ── Zero-shot classification ──────────────────────────────────────────────────
labels = ["Kubernetes error", "Database issue", "Kafka lag", "Deployment failure"]
results = model.classify("replica is not keeping up with the primary", labels)
print(results[0])  # → ("Database issue", 0.847)

# ── Encode to vectors (for vector DB / RAG) ───────────────────────────────────
vectors = model.encode(["MTTR", "SLO", "CrashLoopBackOff", "Kafka consumer lag"])
print(vectors.shape)  # → (4, 384)

# ── SRE relevance gate ────────────────────────────────────────────────────────
print(model.is_sre_related("pod is OOMKilled"))       # → True
print(model.is_sre_related("what is the weather?"))   # → False

# ── Rerank BM25/keyword results ───────────────────────────────────────────────
keyword_results = ["OOMKilled doc", "MTTR guide", "canary deployment playbook"]
reranked = model.rerank("container killed by kernel", keyword_results)

# ── Model info ────────────────────────────────────────────────────────────────
print(model.info())
# {
#   "embedding_dim": 384,
#   "max_seq_length": 256,
#   "base_model": "sentence-transformers/all-MiniLM-L6-v2",
#   "training_pairs": 636,
#   "domains": 16,
#   "license": "Apache-2.0"
# }
```

---

## Singleton — for long-running services

```python
from sre_embedding_model import get_model

# Loads once, reuses on every call — safe for SRE agent / FastAPI service
model = get_model()
score = model.similarity(alert_title, runbook_title)
```

---

## API Reference

| Method | Description |
|---|---|
| `SREModel()` | Load model (bundled weights) |
| `model.encode(texts)` | → `np.ndarray` shape `(N, 384)` |
| `model.similarity(a, b)` | → `float` cosine similarity |
| `model.similarity_batch(anchors, candidates)` | → `ndarray` matrix |
| `model.search(query, docs, top_k=5)` | → `[(doc, score)]` ranked |
| `model.classify(text, labels)` | → `[(label, score)]` ranked |
| `model.is_sre_related(text)` | → `bool` |
| `model.rerank(query, docs)` | → all docs re-ranked |
| `model.info()` | → metadata `dict` |
| `get_model()` | → singleton `SREModel` |

---

## SRE Domains Covered

| Domain | Examples |
|---|---|
| Kubernetes Pod States | CrashLoopBackOff, OOMKilled, ImagePullBackOff, Evicted, Pending |
| Kubernetes Resources | HPA, VPA, PVC, ConfigMap, Ingress, NetworkPolicy |
| Kubernetes Troubleshooting | kubectl describe, node pressure, resource limits |
| Observability | p99 latency, error rate, Prometheus, Grafana, alerting |
| Incident Management | MTTR, MTTD, RCA, postmortem, on-call, escalation |
| APM & Tracing | spans, traces, distributed tracing, Jaeger, OpenTelemetry |
| Splunk | SPL queries, HEC, indexes, sourcetypes, dashboards |
| Java / Spring Boot | NullPointerException, BeanCreationException, heap, GC |
| MySQL | deadlock, lock wait timeout, replication lag, slow query |
| Kafka | consumer lag, producer throughput, partition rebalancing |
| API Gateway | rate limiting, circuit breaker, upstream timeout |
| CI/CD | deployment strategies, canary, blue-green, rollback |
| Cloud Platform | EC2, EKS, ECS, auto-scaling, multi-AZ, RTO/RPO |
| Data Pipelines | Kafka streaming, ETL, dead letter queue |
| Security / SRE | mTLS, RBAC, secrets, zero-trust |
| Error Budget | SLO, SLA, burn rate, chaos engineering |

---

## Use Cases

- **Alert deduplication** — find semantically duplicate alerts
- **Runbook retrieval** — match incident description → correct runbook
- **NL→SRE term mapping** — "container keeps dying" → `CrashLoopBackOff`
- **RAG / vector DB** — encode SRE docs as dense vectors for retrieval-augmented generation
- **SRE agent** — semantic routing in LLM-powered SRE assistants
- **Incident classification** — classify incoming tickets by SRE domain

---

## Performance

| Metric | Base model | Fine-tuned |
|---|---|---|
| SRE similar pairs (in-distribution) | 3/18 pass | **18/18 pass** |
| SRE similar pairs (out-of-distribution) | 6/21 pass | **21/21 pass** |
| Mean cosine on SRE similar pairs | 0.312 | **0.903** |
| Val Spearman ρ | -0.263 | **+0.542** |

---

## Requirements

```
sentence-transformers >= 2.2.0
numpy >= 1.21.0
```

---

## License

**Apache License 2.0** — see [LICENSE](LICENSE)

Base model `all-MiniLM-L6-v2` © Microsoft Corporation, Apache 2.0.
Fine-tuning, training data, and package © 2026 Senthil Kumar Thanapal.

---

## Author

**Senthil Kumar Thanapal** · senthilthepro@hotmail.com
