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

Merge Search & State into new "Generator" type #39

Merged
merged 7 commits into from
Jan 29, 2024

Conversation

RyanUnderhill
Copy link
Member

  // Original version
  auto search = params.CreateSearch();
  auto state = model->CreateState(search->GetSequenceLengths(), params);

  while (!search->IsDone()) {
    search->SetLogits(state->Run(search->GetSequenceLength(), search->GetNextTokens()));
    search->SelectTop();
  }
  // Generator version
  auto generator = model->CreateGenerator();

  while (!generator->IsDone()) {
    generator->ComputeLogits();
    generator->AppendNextToken_Top();
  }

# input_tokens = tokenizer.encode(text, return_tensors='np')
input_tokens = tokenizer.encode(text)
input_tokens = tokenizer.encode(text, return_tensors='np')
# input_tokens = tokenizer.encode(text)

params=og.SearchParams(model)
Copy link
Member

Choose a reason for hiding this comment

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

could you please also change SearchParams to GeneratorParams?


# search.Apply_MinLength(1)
# search.Apply_RepetitionPenalty(1.0)

search.SampleTopP(0.7, 0.6)
generator.AppendNextToken_TopP(0.7, 0.6)
Copy link
Member

@yufenglee yufenglee Jan 26, 2024

Choose a reason for hiding this comment

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

Append doesn't look like a good name to me. generator actually generate next token. How about GenerateNextToken

Copy link
Member

Choose a reason for hiding this comment

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

And can we make TopP a parameter instead of part of the name?

Copy link
Member Author

Choose a reason for hiding this comment

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

I named it that since you first compute the logits, then append the next token based on the logits.
I initially had AddNextToken but 'Add' was less correct than 'Append' since it's appending tokens, not adding them.
Did you have a better name?

Copy link
Member

Choose a reason for hiding this comment

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

It is a process of generate next token. Add or Append doesn't reflect the action, i think.

Comment on lines 37 to 38
# search.Apply_MinLength(1)
# search.Apply_RepetitionPenalty(1.0)
Copy link
Member

Choose a reason for hiding this comment

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

could you please update this also

src/generators.h Outdated Show resolved Hide resolved
@RyanUnderhill RyanUnderhill merged commit 06c294a into main Jan 29, 2024
9 checks passed
@RyanUnderhill RyanUnderhill deleted the ryanunderhill/merge_state_search branch January 29, 2024 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants