feat(metrics): add SemanticResult type
This commit is contained in:
@@ -10,6 +10,7 @@ from veritext.metrics.results import (
|
|||||||
ReadabilityResult,
|
ReadabilityResult,
|
||||||
RougeResult,
|
RougeResult,
|
||||||
RougeScore,
|
RougeScore,
|
||||||
|
SemanticResult,
|
||||||
)
|
)
|
||||||
from veritext.metrics.rouge import Rouge
|
from veritext.metrics.rouge import Rouge
|
||||||
|
|
||||||
@@ -26,4 +27,5 @@ __all__ = [
|
|||||||
"Rouge",
|
"Rouge",
|
||||||
"RougeResult",
|
"RougeResult",
|
||||||
"RougeScore",
|
"RougeScore",
|
||||||
|
"SemanticResult",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -91,3 +91,20 @@ class ReadabilityResult(BaseModel):
|
|||||||
def score(self) -> float:
|
def score(self) -> float:
|
||||||
"""Return Flesch reading ease as the primary score."""
|
"""Return Flesch reading ease as the primary score."""
|
||||||
return self.flesch_reading_ease
|
return self.flesch_reading_ease
|
||||||
|
|
||||||
|
|
||||||
|
class SemanticResult(BaseModel):
|
||||||
|
"""Result of semantic similarity computation."""
|
||||||
|
|
||||||
|
model_config = ConfigDict(frozen=True)
|
||||||
|
|
||||||
|
similarity: float
|
||||||
|
"""Cosine similarity score (0.0 to 1.0)."""
|
||||||
|
|
||||||
|
model: str
|
||||||
|
"""Name of the embedding model used."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def score(self) -> float:
|
||||||
|
"""Return the primary score for this result."""
|
||||||
|
return self.similarity
|
||||||
|
|||||||
Reference in New Issue
Block a user