Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix Reward Calculation in example/2022-12-10-textrl-elon-musk.ipynb #27

Copy link
Copy link
@Alanhsiu

Description

@Alanhsiu
Issue body actions

In the notebook example/2022-12-10-textrl-elon-musk.ipynb, the reward calculation in the MyRLEnv class should be updated for correct scoring. Specifically, the function get_reward needs modification.

Current Code:

class MyRLEnv(TextRLEnv):
    def get_reward(self, input_item, predicted_list, finish):
        reward = 0
        if finish or len(predicted_list) >= self.env_max_length:
            predicted_text = tokenizer.convert_tokens_to_string(predicted_list[0])
            # sentiment classifier
            reward = sentiment(input_item[0] + predicted_text)[0][0]['score'] * 10
        return reward

The current code concatenates input_item[0] with the predicted text to calculate the sentiment score. However, input_item should be referenced differently to ensure proper reward calculation.

reward = sentiment(input_item['input'] + predicted_text)[0][0]['score'] * 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.