-
Notifications
You must be signed in to change notification settings - Fork 105
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
Match token value with array and tuple #183
base: main
Are you sure you want to change the base?
Conversation
* Add match cases for token value * Add BartTokenizer to known tokenizers
Thank you for the contribution @shavit! I tested it and However this is a curious issue, because when pulling from a URL
I could be missing something, but since JSON doesn't support tuples, wouldn't we expect the value entries in the config to be arrays instead of tuples? I'm a bit confused why this worked previously. @pcuenca @FL33TW00D |
Right, I agree. The config likely decodes to a dictionary with any byte values, and the token value casts in a dynamic lookup. I'll do a few more checks. |
I think you are right @greenrazer! I don't think this could ever work with actual tokenizer files. |
True, but the JSON array was decoded into The problem comes from the token order, which is not index-first.
|
adb64db
to
fcbb09e
Compare
case let (i, t) as (UInt, String): return (i, t) | ||
case let (t, i) as (String, UInt): return (i, t) |
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 we know if both versions exist in the wild?
@@ -118,4 +118,14 @@ class HubTests: XCTestCase { | |||
let vocab_dict = config.dictionary["vocab"] as! [String: Int] | |||
XCTAssertNotEqual(vocab_dict.count, 2) | |||
} | |||
|
|||
func testConfigTokenValueDifferentOrder() { |
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.
Thanks for the test! Could we please add another one that loads a tokenizer such as facebook/bart-large-mnli
? We don't need anything fancy: just show that the tokenizer loads and that it can encode a string.
/Close #182