Skip to content

schema

RewardDimension

Bases: BaseModel

Base class for reward dimensions containing common attributes.

Attributes:

Name Type Description
name str

Identifier name for the reward dimension

reason str

Explanation of how the reward value was determined

Source code in rm_gallery/core/reward/schema.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
class RewardDimension(BaseModel):
    """
    Base class for reward dimensions containing common attributes.

    Attributes:
        name (str): Identifier name for the reward dimension
        reason (str): Explanation of how the reward value was determined
    """

    name: str = Field(default=..., description="name")
    # weight: float = Field(default=..., description="weight")
    reason: str = Field(default=..., description="reason")

RewardDimensionWithRank

Bases: RewardDimension

ListWise/Pointwise reward dimension with ranking values.

Attributes:

Name Type Description
rank List[float]

Collection of ranking scores for different positions

Methods:

Name Description
__getitem__

Returns a scored reward dimension for a specific rank position

Source code in rm_gallery/core/reward/schema.py
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
class RewardDimensionWithRank(RewardDimension):
    """
    ListWise/Pointwise reward dimension with ranking values.

    Attributes:
        rank (List[float]): Collection of ranking scores for different positions

    Methods:
        __getitem__: Returns a scored reward dimension for a specific rank position
    """

    rank: List[float] = Field(default_factory=list, description="rank")

    def __getitem__(self, index: int) -> RewardDimensionWithScore:
        """
        Access a specific position's reward information.

        :param index: Position in the ranking list to retrieve
        :type index: int
        :returns: Reward information with score for the specified position
        :rtype: RewardDimensionWithScore
        """
        return RewardDimensionWithScore(
            name=self.name,
            # weight=self.weight,
            reason=self.reason,
            score=self.rank[index],
        )

__getitem__(index)

Access a specific position's reward information.

:param index: Position in the ranking list to retrieve :type index: int :returns: Reward information with score for the specified position :rtype: RewardDimensionWithScore

Source code in rm_gallery/core/reward/schema.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def __getitem__(self, index: int) -> RewardDimensionWithScore:
    """
    Access a specific position's reward information.

    :param index: Position in the ranking list to retrieve
    :type index: int
    :returns: Reward information with score for the specified position
    :rtype: RewardDimensionWithScore
    """
    return RewardDimensionWithScore(
        name=self.name,
        # weight=self.weight,
        reason=self.reason,
        score=self.rank[index],
    )

RewardDimensionWithScore

Bases: RewardDimension

Pointwise/Stepwise reward dimension with a numerical score.

Attributes:

Name Type Description
score float

Numerical value representing the reward magnitude

Source code in rm_gallery/core/reward/schema.py
20
21
22
23
24
25
26
27
28
class RewardDimensionWithScore(RewardDimension):
    """
    Pointwise/Stepwise reward dimension with a numerical score.

    Attributes:
        score (float): Numerical value representing the reward magnitude
    """

    score: float = Field(default=..., description="score")

RewardResult

Bases: BaseModel, Generic[T]

Container for reward calculation results with generic type support.

Attributes:

Name Type Description
name str

Identifier of the reward module that generated this result

details List[T]

Collection of detailed reward information items

extra_data dict

Additional metadata or context information

Source code in rm_gallery/core/reward/schema.py
65
66
67
68
69
70
71
72
73
74
75
76
77
class RewardResult(BaseModel, Generic[T]):
    """
    Container for reward calculation results with generic type support.

    Attributes:
        name (str): Identifier of the reward module that generated this result
        details (List[T]): Collection of detailed reward information items
        extra_data (dict): Additional metadata or context information
    """

    name: str = Field(default=..., description="reward module name")
    details: List[T] = Field(default_factory=list, description="reward details")
    extra_data: dict = Field(default_factory=dict, description="extra data")