Novelty Detection¶
novelentitymatcher.novelty.entity_matcher
¶
Primary orchestration API for classification plus novel-class detection.
This module promotes NovelEntityMatcher to the main public entry point for
novelty-aware matching. It wraps a fitted Matcher together with the
multi-signal NoveltyDetector and optional LLMClassProposer.
Classes¶
NovelEntityMatchResult(id, score, is_match, is_novel, novel_score=None, match_method='accepted_known', alternatives=list(), signals=dict(), predicted_id=None, metadata=dict())
dataclass
¶
Operational result for a single novelty-aware match decision.
NovelEntityMatcher(entities=None, *, matcher=None, model='potion-32m', mode='zero-shot', acceptance_threshold=None, detection_config=None, llm_provider=None, llm_model=None, llm_api_keys=None, output_dir='./proposals', auto_save=True, match_threshold=None, novelty_strategy='confidence', confidence_threshold=0.3, knn_k=5, knn_distance_threshold=0.6, min_cluster_size=5, use_novelty_detector=True, review_storage_path='./proposals/review_records.json')
¶
Bases: DiscoveryBase
Primary public API for novelty-aware matching.
The class orchestrates three stages: 1. Retrieve rich matcher metadata with top-k candidates and embeddings. 2. Score novelty using ANN-backed multi-signal detection. 3. Optionally propose new class names for novel batches.
Source code in src/novelentitymatcher/novelty/entity_matcher.py
Functions¶
novelentitymatcher.novelty.core.detector
¶
Core novelty detector with strategy orchestration.
This is the main entry point for novelty detection, using a strategy pattern to support multiple detection algorithms.
Classes¶
NoveltyDetector(config)
¶
Simplified novelty detector using registered strategies.
This detector manages strategy initialization and orchestration, delegating signal combination and metadata building to specialized components.
Responsibilities: - Strategy initialization and lifecycle - Strategy orchestration - Delegates signal combining to SignalCombiner - Delegates metadata creation to MetadataBuilder
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DetectionConfig
|
Detection configuration |
required |
Source code in src/novelentitymatcher/novelty/core/detector.py
Attributes¶
is_initialized
property
¶
Check if detector has been initialized with reference data.
Functions¶
detect_novel_samples(texts, confidences, embeddings, predicted_classes, reference_embeddings=None, reference_labels=None, **kwargs)
¶
Detect novel samples using configured strategies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
list[str]
|
Input texts |
required |
confidences
|
ndarray
|
Prediction confidence scores |
required |
embeddings
|
ndarray
|
Text embeddings |
required |
predicted_classes
|
list[str]
|
Predicted class for each sample |
required |
reference_embeddings
|
ndarray | None
|
Embeddings of known samples |
None
|
reference_labels
|
list[str] | None
|
Class labels for known samples |
None
|
**kwargs
|
Additional strategy-specific parameters |
{}
|
Returns:
| Type | Description |
|---|---|
NovelSampleReport
|
NovelSampleReport with detection results |
Source code in src/novelentitymatcher/novelty/core/detector.py
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
reset()
¶
Reset the detector, clearing all initialized strategies.
This allows the detector to be re-used with different reference data.
Source code in src/novelentitymatcher/novelty/core/detector.py
get_strategy(strategy_id)
¶
Get an initialized strategy by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strategy_id
|
str
|
Strategy identifier |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Strategy instance if initialized |
Raises:
| Type | Description |
|---|---|
ValueError
|
If strategy not found or not initialized |
Source code in src/novelentitymatcher/novelty/core/detector.py
list_initialized_strategies()
¶
List all initialized strategies.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of strategy IDs |