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

Add GPT2 tokenizer setup and refactor code #56

Merged
merged 8 commits into from
Feb 5, 2025

Conversation

aliciafmachado
Copy link
Collaborator

@aliciafmachado aliciafmachado commented Jan 27, 2025

Main changes introduced are:

  1. Add support for using a pre-trained tokenizer from gpt-tokenizer library.
  2. Refactor token_gemb.ts file to make it simpler to extend it to other tokenizations.
  3. Add common functions among gpt2.ts and transformer_gtensor.ts to a common file.

Fixes Issues #54 & #52.

Refactoring the token embedding type and wrapping it with a class will be done in a follow-up CL.
There is also some work left on refactoring the tokenization of tasks so that we can reuse the tokens for next N tokens prediction.

Copy link
Collaborator

@iislucas iislucas left a comment

Choose a reason for hiding this comment

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

thanks for cleanup also! Just a couple of small minor improvements.

embedBatch,
expectedOutputSeqPrepFn,
} from '../tokens/token_gemb';

function tokenize_fn_test(input: string): number[] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I get what this function is for, can you add a comment to say a little about what it's intended to do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a function for testing. Added a comment and simplified it.

animated-transformer/src/lib/tokens/token_gemb.ts Outdated Show resolved Hide resolved
animated-transformer/src/lib/tokens/token_gemb.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@iislucas iislucas left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@aliciafmachado aliciafmachado merged commit 97f7bbd into PAIR-code:main Feb 5, 2025
1 check passed
@aliciafmachado aliciafmachado deleted the gpt-tokenizer branch February 5, 2025 12:24
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.

2 participants