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 tokenize_batch method #14

Merged
merged 1 commit into from
Nov 28, 2023
Merged

Add tokenize_batch method #14

merged 1 commit into from
Nov 28, 2023

Conversation

michael-p
Copy link
Contributor

The Python bindings provide this method as a convenience function. I think this is useful for users of the Rust library as well, so I implemented it there. This means we have to take on a dependency on ndarray, but I think this is justified given how widely used this crate is in the ML ecosystem.

@michael-p michael-p requested a review from djc November 28, 2023 10:47
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
djc

This comment was marked as resolved.

regex = "1.10.2"

[dev-dependencies]
criterion = "0.5.1"

[[bench]]
name = "bench"
required-features = ["openai-vocabulary-file"]
required-features = ["ndarray", "openai-vocabulary-file"]
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid this and only guard the tokenize_batch_small benchmark on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the benchmark which requires the (now optional) ndarray feature to a second benchmark harness.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this better than just guarding the single benchmark?

Copy link
Contributor Author

@michael-p michael-p Nov 28, 2023

Choose a reason for hiding this comment

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

I'm not sure guarding a single benchmark is even possible in Criterion without much effort. I didn't find anything in the documentation, and tried several combinations while defining the criterion_group!(...) and criterion_main!(...) but it looks like there is no easy way to feature-gate individual benchmarks (except probably duplicating both criterion_group!(...) and criterion_main!(...)).

In addition, it's maybe a bit more discoverable. I tend to just run cargo bench on projects I'm not familiar with (instead of cargo bench --all-features) and would hence miss those benchmarks. By having two benchmark .rs files I might realize that there are actually more benchmarks I can run.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
regex = "1.10.2"

[dev-dependencies]
criterion = "0.5.1"

[[bench]]
name = "bench"
required-features = ["openai-vocabulary-file"]
required-features = ["ndarray", "openai-vocabulary-file"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this better than just guarding the single benchmark?

@michael-p michael-p merged commit e85644f into main Nov 28, 2023
7 checks passed
@michael-p michael-p deleted the tokenize-batch branch December 6, 2023 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants