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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canary greedy and temperature decoding #8885

Closed
wants to merge 5 commits into from
Closed

Conversation

pzelasko
Copy link
Collaborator

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

Collection: [Note which collection this PR will affect]

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

Jenkins CI

To run Jenkins, a NeMo User with write access must comment jenkins on the PR.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

Signed-off-by: Piotr Żelasko <petezor@gmail.com>
Signed-off-by: Piotr Żelasko <petezor@gmail.com>
Signed-off-by: Piotr Żelasko <petezor@gmail.com>
Signed-off-by: Piotr Żelasko <petezor@gmail.com>
@@ -103,30 +107,44 @@
self.preserve_alignments = self.cfg.get('preserve_alignments', None)
self.compute_langs = self.cfg.get('compute_langs', False)
self.compute_hypothesis_token_set = self.cfg.get('compute_hypothesis_token_set', False)
self.transformer_decoder = transformer_decoder
self.log_softmax_module = log_softmax_module
self.tokenizer = tokenizer

Check warning

Code scanning / CodeQL

Overwriting attribute in super-class or sub-class Warning

Assignment overwrites attribute tokenizer, which was previously defined in subclass
MultiTaskDecoding
.
):
super().__init__()
self.embedding = embedding
self.decoder = decoder
self.log_softmax = log_softmax
self.log_softmax.mlp.log_softmax = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need make it work for any log_softmax modules, we can't assume that all those modules have log_softmax.mlp.log_softmax

Signed-off-by: Piotr Żelasko <petezor@gmail.com>
Comment on lines +137 to +148
self.greedy_search = GreedySequenceGenerator(
embedding=transformer_decoder.embedding,
decoder=transformer_decoder.decoder,
log_softmax=log_softmax_module,
max_sequence_length=transformer_decoder.max_sequence_length,
bos=tokenizer.bos_id,
pad=tokenizer.pad_id,
eos=tokenizer.eos_id,
max_delta_length=max_generation_delta,
temperature=self.temperature,
n_samples=n_samples,
)

Check failure

Code scanning / CodeQL

Wrong name for an argument in a class instantiation Error

Keyword argument 'log_softmax' is not a supported parameter name of
GreedySequenceGenerator.__init__
.
):
super().__init__()
self.embedding = embedding
self.decoder = decoder
self.log_softmax = log_softmax
self.classifier = classifier.set_log_softmax_enabled(False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add a check to see if the classifier has the set_log_softmax_enabled() function, and if not, we default to not using temperature sampling and print out a warning?

@@ -107,8 +112,8 @@ def _one_step_forward(
decoder_mems_list = self.decoder.forward(
decoder_hidden_states, decoder_input_mask, decoder_mems_list, return_mems=True
)
log_probs = self.log_softmax.forward(hidden_states=decoder_mems_list[-1][:, -1:])
return log_probs, decoder_mems_list
logits = self.classifier.forward(hidden_states=decoder_mems_list[-1][:, -1:], temperature=self.temperature)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we add a check to see if the forward function has temperature arg?

samples = list(tgt.view(orig_batch_size, self.n_samples, -1))
tgt = tgt[:: self.n_samples]

return tgt, samples
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we're adding an additional output samples, do we also need to update the __call__ function where the _forward function is called?

Copy link
Contributor

github-actions bot commented May 1, 2024

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

@github-actions github-actions bot added the stale label May 1, 2024
Copy link
Contributor

This PR was closed because it has been inactive for 7 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants