Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: ChatGPT - There is a possibility that the generation is not working properly. #3088

Closed
brcps12 opened this issue Mar 10, 2023 · 3 comments 路 Fixed by #3166
Closed

[BUG]: ChatGPT - There is a possibility that the generation is not working properly. #3088

brcps12 opened this issue Mar 10, 2023 · 3 comments 路 Fixed by #3166
Labels
bug Something isn't working

Comments

@brcps12
Copy link

brcps12 commented Mar 10, 2023

馃悰 Describe the bug

generate_kwargs is not properly passed to PPOTrainer. So, generating sentences might be incorrect. (At leat in my case)

experience_maker = NaiveExperienceMaker(actor, critic, reward_model, initial_model, kl_coef)
replay_buffer = NaiveReplayBuffer(train_batch_size, buffer_limit, buffer_cpu_offload)
super().__init__(strategy, experience_maker, replay_buffer, experience_batch_size, max_epochs, tokenizer,
sample_replay_buffer, dataloader_pin_memory, callbacks, **generate_kwargs)
self.actor = actor
self.critic = critic
self.actor_loss_fn = PolicyLoss(eps_clip)
self.critic_loss_fn = ValueLoss(value_clip)
self.actor_optim = actor_optim
self.critic_optim = critic_optim
self._set_default_generate_kwargs(generate_kwargs, actor)

Like Huggingface GPT2 Model, prepare_inputs_fn and update_model_kwargs_fn should be passed to generate. But in that code, these functions are not applied because _set_default_generate_kwargs() is called after super().__init__()

So, I think the order of call should be changed.

Environment

No response

@brcps12 brcps12 added the bug Something isn't working label Mar 10, 2023
@ver217
Copy link
Member

ver217 commented Mar 17, 2023

Hi, _set_default_generate_kwargs() will modify generate_kwargs inplace, so this is OK. But I agree the order is bad and we will update this.

Thanks for your suggestion!

@brcps12
Copy link
Author

brcps12 commented Mar 17, 2023

But when super().__init__() is calling, all keyword arguments are unpacked and passed to the super class. So, I think modifying the arguments will not propagate to super class.

Like this:

class Parent:
    def __init__(self, **kwargs):
        self.kwargs = kwargs

class Child(Parent):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        kwargs['this_had_to_be_contained'] = 1

instance = Child(param1=0, param2=1)

# Print "{'param1': 0, 'param2': 1}"
print(instance.kwargs)

@ver217
Copy link
Member

ver217 commented Mar 17, 2023

Can you create a PR to solve this problem? All contribution is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants