Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions prompting/rewards/ordinal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ def name(self) -> str:
def __init__(self, **kwargs):
super().__init__()
#TODO: Expand to allow for more than 3 classes (Must also adjust dataset/review.py)
self.sentiments = [
"casual",
"basic",
"silly",
"random",
"thoughtful",
"serious",
"rushed",
self.sentiments = [
"positive",
"neutral",
"negative",
]
#NOTE: These sentimens are not the same as the sentiments defined in the dataset/review.py file. These are the subtopic


def reward(self, reference: str, completions: List[str]) -> BatchRewardOutput:
"""Compute difference scores given a completion and reference pair."""
Expand All @@ -34,7 +28,8 @@ def reward(self, reference: str, completions: List[str]) -> BatchRewardOutput:

# Check if exactly one answer can be found in the completion
if sum(option in completion for option in classes) == 1:
reward = abs(classes.index(reference) - classes.index(completion))
answer = [option for option in classes if option in completion][0]
reward = abs(classes.index(reference) - classes.index(answer))
else:
reward = 0
timings.append(time.time() - t0)
Expand All @@ -47,4 +42,4 @@ def reward(self, reference: str, completions: List[str]) -> BatchRewardOutput:
"type": "math",
},
)
return output
return output