mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-08-01 15:26:44 +08:00
Update normalized_scorer.py
Signed-off-by: Pr0Wh1teGivee <calvin_zhu0210@outlook.com> Signed-off-by: weichen <calvin_zhu0210@outlook.com>
This commit is contained in:
parent
b04f678659
commit
ed2a808252
@ -27,7 +27,8 @@ class ScoreDim:
|
|||||||
|
|
||||||
class NormalizedScorer:
|
class NormalizedScorer:
|
||||||
"""
|
"""
|
||||||
Normalize unbounded N-dimensional values into a composite score using the Sigmoid function.
|
Normalize unbounded N-dimensional values into a composite score using the Sigmoid
|
||||||
|
function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, dim_list: list[ScoreDim]) -> None:
|
def __init__(self, dim_list: list[ScoreDim]) -> None:
|
||||||
@ -48,7 +49,9 @@ class NormalizedScorer:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _inv_sigmoid_normalize(value, median, norm_scale):
|
def _inv_sigmoid_normalize(value, median, norm_scale):
|
||||||
"""Inverse Sigmoid: Used for dimensions where a larger value yields a lower score."""
|
"""Inverse Sigmoid: Used for dimensions where a larger value yields a lower
|
||||||
|
score.
|
||||||
|
"""
|
||||||
# Equivalent to sigmoid(-x), but more numerically stable.
|
# Equivalent to sigmoid(-x), but more numerically stable.
|
||||||
return 1 / (1 + math.exp(norm_scale * (value - median)))
|
return 1 / (1 + math.exp(norm_scale * (value - median)))
|
||||||
|
|
||||||
@ -74,12 +77,7 @@ class NormalizedScorer:
|
|||||||
score = self._sigmoid_normalize(
|
score = self._sigmoid_normalize(
|
||||||
dim_value, dim_info.median, dim_info.norm_scale
|
dim_value, dim_info.median, dim_info.norm_scale
|
||||||
)
|
)
|
||||||
logger.debug(
|
logger.debug("%s(%s) : %.10f", dim_info.name, dim_info.reverse, score)
|
||||||
"%s(%s) : %.10f",
|
|
||||||
dim_info.name,
|
|
||||||
dim_info.reverse,
|
|
||||||
score
|
|
||||||
)
|
|
||||||
|
|
||||||
# Weighted summation.
|
# Weighted summation.
|
||||||
final_score += score * dim_info.weight
|
final_score += score * dim_info.weight
|
||||||
@ -88,7 +86,8 @@ class NormalizedScorer:
|
|||||||
|
|
||||||
class TimeAndLengthScorer(NormalizedScorer):
|
class TimeAndLengthScorer(NormalizedScorer):
|
||||||
"""
|
"""
|
||||||
Scorer for time and length dimensions; defaults to forward scoring with equal weights (0.5 each).
|
Scorer for time and length dimensions; defaults to forward scoring with equal
|
||||||
|
weights (0.5 each).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user