Commit fe6a522
feat(search): self-supervised fine-tuned metadata-aware semantic encoder
Closes #26647
Add ingestion/src/metadata/ml/ package implementing a complete
self-supervised training pipeline for a metadata-aware semantic encoder,
replacing general-purpose web-text embeddings with a model trained on
structural signals already present in any OpenMetadata instance.
## Problem
General-purpose embeddings (OpenAI text-embedding-3-small, MiniLM trained
on web text) are unaware of metadata semantics. They cannot distinguish
that order_id in orders is semantically closer to order_id in order_items
than to session_id — even though both are ID columns. This causes semantic
search to surface irrelevant results for catalog exploration queries.
## Solution — Four Python components + one Java fix
### training_data.py — Self-Supervised Pair Extractor
Extracts training signal from three sources with zero manual labelling:
- Lineage edges: column A->B = positive (1.0); same-table = soft
positive (0.7/0.5); 3+ hops apart = hard negative (0.0)
- Glossary assignments: shared term = positive (1.0);
disjoint sets = negative (0.0)
- Table co-membership: same table = soft positive (0.5);
different services = hard negative (0.0)
### train_encoder.py — Contrastive Fine-Tuning (sentence-transformers v5.4.1)
- Base model: answerdotai/ModernBERT-base (MiniLM fallback)
- Multi-objective loss: 0.6*CosineSimilarityLoss + 0.4*MNRLoss
- Uses datasets.Dataset API (compatible with sentence-transformers>=5.0)
- AdamW lr=2e-5, epoch-based eval, early stopping patience=3
- Output: openmetadata-finetuned-encoder/ (auto-detected by DJL client)
### evaluate_encoder.py — Evaluation Framework
- MRR@10, Recall@{1,5,10}, Semantic Cohesion Score
- Compares fine-tuned vs all-MiniLM-L6-v2 baseline
- Saves evaluation_results.json for CI tracking
### encoder_client.py — Drop-In Integration Client
- MetadataEncoder: auto-selects fine-tuned model if present, else MiniLM
- @lru_cache model loading (load once per process)
- L2-normalised output (cosine-similarity ready)
- Zero changes to existing Java search pipeline required
### EmbeddingService.java — SentenceTransformerProvider Fix
- Replaces hash-based stub with real DJL Criteria/ZooModel/Predictor
- Auto-detects openmetadata-finetuned-encoder/ at startup
- Falls back to all-MiniLM-L6-v2 via DJL if fine-tuned model absent
- LocalEmbeddingProvider retained as ultimate fallback
## Validation — 42/42 tests passing
G1 order_id semantic gap: +0.3723
G2 glossary clustering gap: +0.3647
G3 lineage scoring gap: +0.4499
G4 table cohesion gap: +0.3092
G5 post-fine-tuning gap: +0.7249
## Dependencies added under extras_require['ml']
sentence-transformers[train]>=5.0, torch>=2.0, transformers>=4.40,
scikit-learn>=1.3, numpy>=1.24, accelerate>=1.1, datasets1 parent 35c3c92 commit fe6a522
File tree
8 files changed
+1222
-11
lines changed- ingestion
- src/metadata/ml
- openmetadata-service/src/main/java/org/openmetadata/service/rdf/semantic
8 files changed
+1222
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
393 | 402 | | |
394 | 403 | | |
395 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
0 commit comments