Skip to content

Commit

Permalink
Refactor sentiment calculation in reward.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Feb 26, 2024
1 parent 46ca4fd commit 9f655fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion neurons/validators/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ async def forward(self):
- Rewarding the miners
- Updating the scores
"""

return await forward(self)


Expand Down
4 changes: 3 additions & 1 deletion prompting/validator/reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def reward(query: int, response: str) -> float:

blob = textblob.TextBlob(response)
sentiment_sum = reduce(lambda x, y: x + y, [sentence.sentiment.polarity for sentence in blob.sentences])
return sentiment_sum / len(blob.sentences)
sentiment_avg = sentiment_sum / len(blob.sentences)
sentiment_normalized = (sentiment_avg + 1) / 2
return sentiment_normalized


def get_rewards(
Expand Down

0 comments on commit 9f655fc

Please sign in to comment.