-
Notifications
You must be signed in to change notification settings - Fork 818
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 display capabilities to tokenizers objects #1542
Conversation
ArthurZucker
commented
Jun 3, 2024
•
edited
Loading
edited
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
…add-display fix git suggestion nit __repr__ should use Debug? small updates Simple lazygit test
Trying to build this, we need to use numpy with PyO3 version 0.22. I think that our choices are to either:
It's probably easier to fork Edit: see #1574 which implements using 0.21 of pyo3 smd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -63,6 +63,7 @@ fancy-regex = { version = "0.13", optional = true} | |||
getrandom = { version = "0.2.10" } | |||
esaxx-rs = { version = "0.1.10", default-features = false, features=[]} | |||
monostate = "0.1.12" | |||
pyo3_special_method_derive_0_21 = {path = "../../pyo3-special-method-derive/pyo3_special_method_derive_0_21"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not forget to remove
tokenizers/src/pre_tokenizers/mod.rs
Outdated
BertPreTokenizer(BertPreTokenizer), | ||
ByteLevel(ByteLevel), | ||
Delimiter(CharDelimiterSplit), | ||
Metaspace(Metaspace), | ||
Whitespace(Whitespace), | ||
#[format(fmt = "{}")] | ||
Sequence(Sequence), | ||
Split(Split), | ||
Punctuation(Punctuation), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MIght want to add #[format(fmt = "{}")]
for all of them
#[format] | ||
pub(crate) decoder: PyDecoderWrapper, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visibility here forces us to add format
#[format(skip)] | ||
pub inner: PyObject, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not implemented yet so skipping for now
#[format(fmt = "{}")] | ||
pub(crate) enum PyDecoderWrapper { | ||
Custom(Arc<RwLock<CustomDecoder>>), | ||
Wrapped(Arc<RwLock<DecoderWrapper>>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will directly display Arc<RwLock<CustomDecoder>>
pub struct PyTokenizer { | ||
tokenizer: Tokenizer, | ||
pub tokenizer: Tokenizer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a requirement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite worried that we have to litter the rust crate with python specific code.
Rust code is rust code, it should care about python bindings.
Isn't there a way to use Debug
formatting or something similar ?
@@ -791,7 +862,7 @@ where | |||
EncodeInput::Single(s1) => (s1, None), | |||
EncodeInput::Dual(s1, s2) => (s1, Some(s2)), | |||
}; | |||
|
|||
println!("thread id: {:?}", current_thread_index()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops
@@ -880,6 +951,7 @@ where | |||
word_idx: Option<u32>, | |||
offsets_type: OffsetType, | |||
) -> Result<Encoding> { | |||
println!("do tokenizer {:?}", current_thread_index()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops