Spaces:
Runtime error
Runtime error
update
Browse files
src/similarity_model/feature_similarity.py
CHANGED
|
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
|
|
| 11 |
MODEL_NAME = "all-MiniLM-L6-v2"
|
| 12 |
SIMILARITY_WEIGHT = 0.70
|
| 13 |
COVERAGE_WEIGHT = 0.30
|
| 14 |
-
DEFAULT_THRESHOLD = 0.
|
| 15 |
|
| 16 |
@lru_cache(maxsize=1)
|
| 17 |
def load_feature_model():
|
|
|
|
| 11 |
MODEL_NAME = "all-MiniLM-L6-v2"
|
| 12 |
SIMILARITY_WEIGHT = 0.70
|
| 13 |
COVERAGE_WEIGHT = 0.30
|
| 14 |
+
DEFAULT_THRESHOLD = 0.65
|
| 15 |
|
| 16 |
@lru_cache(maxsize=1)
|
| 17 |
def load_feature_model():
|
src/similarity_model/hybrid_ranker.py
CHANGED
|
@@ -109,7 +109,7 @@ def compute_hybrid_score(
|
|
| 109 |
# No feature overlap → rely on semantics only
|
| 110 |
# ==========================================
|
| 111 |
if feature_score == 0 or coverage == 0:
|
| 112 |
-
return round(clamp(0.
|
| 113 |
|
| 114 |
# ==========================================
|
| 115 |
# Normal scoring with dynamic weights
|
|
@@ -135,22 +135,12 @@ def compute_originality(
|
|
| 135 |
"""
|
| 136 |
Originality Score (0-100)
|
| 137 |
|
| 138 |
-
-
|
| 139 |
-
- More similarity -> lower originality
|
| 140 |
"""
|
| 141 |
|
| 142 |
hybrid_score = clamp(hybrid_score)
|
| 143 |
|
| 144 |
-
|
| 145 |
-
unique_query_features / total_query_features
|
| 146 |
-
if total_query_features > 0
|
| 147 |
-
else 0.0
|
| 148 |
-
)
|
| 149 |
-
|
| 150 |
-
originality = (
|
| 151 |
-
0.70 * uniqueness_ratio +
|
| 152 |
-
0.30 * (1.0 - hybrid_score)
|
| 153 |
-
)
|
| 154 |
|
| 155 |
return round(
|
| 156 |
max(0.0, min(100.0, originality * 100)),
|
|
|
|
| 109 |
# No feature overlap → rely on semantics only
|
| 110 |
# ==========================================
|
| 111 |
if feature_score == 0 or coverage == 0:
|
| 112 |
+
return round(clamp(0.60 * semantic_score), 4)
|
| 113 |
|
| 114 |
# ==========================================
|
| 115 |
# Normal scoring with dynamic weights
|
|
|
|
| 135 |
"""
|
| 136 |
Originality Score (0-100)
|
| 137 |
|
| 138 |
+
- Driven primarily by inverse of hybrid similarity.
|
|
|
|
| 139 |
"""
|
| 140 |
|
| 141 |
hybrid_score = clamp(hybrid_score)
|
| 142 |
|
| 143 |
+
originality = 1.0 - hybrid_score
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
return round(
|
| 146 |
max(0.0, min(100.0, originality * 100)),
|