Repository navigation
OPENNLP-1988: Read the vocabulary of a WordPiece tokenizer.json in opennlp-dl - #1319
Conversation
e6696eb to
f64ff31
Compare
f64ff31 to
491ee4c
Compare
|
unstacked after the #1277 merge, so this shows only the tokenizer.json change. A tokenizer.json is recognized by model.type and only WordPiece is accepted; added_tokens are read; normalizer.lowercase must agree with lowerCase or the file is rejected; the other tokenizer settings are not read. Eval build: https://ci-builds.apache.org/job/OpenNLP/job/eval-tests-configurable/89/ |
|
Eval build was successful |
|
This was a ticket for helping follow-ups stacked tix with remaining regex removal. It can hold off. |
491ee4c to
83ea203
Compare
83ea203 to
0591a40
Compare
|
Thanks for the review - Dropped the message constants and the static on the vocabulary readers. They are package-private now, since the constructor calls them and their return type is package-private. Exceptions are plain strings and JsonScan errors are no longer rewrapped; JsonScan names the offset of a bad value instead. The other static methods predate this PR, I can do those in a follow-up. I'm applying the same logic to the other open PRs. |
rzo1
left a comment
There was a problem hiding this comment.
Thx, the review comments are addressed. Please rebase onto main before merging (small conflict in JsonScan).
0591a40 to
d8f7303
Compare
|
Rebased and g2g |
|
@krickert Could you rebase this onto main? Main renamed I would have pushed the rebase myself, but GitHub rejects pushes from maintainers to the |
|
Sorry I thought I transferred all the branches from my fork - I'll rebase now |
Accept Hugging Face tokenizer.json files as WordPiece vocabularies in opennlp-dl. Read model.vocab and include added_tokens with their declared IDs. Reject token or ID conflicts, malformed entries, unsupported model types and subword prefixes other than ##. Reject a normalizer.lowercase setting that differs from the constructor's lowerCase argument. Other tokenizer settings are not imported. Error messages name the member and offset of a value of the wrong type. Add tests for vocabulary loading, invalid input and a leading byte order mark, using fixtures created for the tests. Document the vocabulary rules in the document categorizer chapter and link to them from the name finder and embedder sections. Assisted-by: Claude Code 2.1.281 Co-authored-by: Kristian Rickert <kristian@apache.org> Co-authored-by: Claude <noreply@anthropic.com> Reviewed-by: Kristian Rickert <kristian@apache.org> Signed-off-by: Kristian Rickert <kristian@apache.org>
d8f7303 to
10654c9
Compare
Accepts a Hugging Face tokenizer.json as the vocabulary file of the deep learning components. Part 3b of the regex removal series.
model.type. Only WordPiece is accepted; BPE, Unigram and other types are rejected by name, as is acontinuing_subword_prefixother than##.model.vocabsupplies the tokens. An entry ofadded_tokensmissing frommodel.vocabis added with its id. A token or id conflict is rejected naming both, and a malformed entry is rejected atadded_tokens[i].normalizer.lowercaseis read, and the constructors reject a file with a setting that disagrees withlowerCase, naming the file and both values. The other tokenizer settings are not read.Tests use a hand-written tokenizer.json fixture with encodings computed by hand, rejected Unigram, BPE, prefix and conflict files, and a byte order mark before a tokenizer.json read from disk. No Hugging Face material is copied. The vocabulary rules are documented once in the document categorizer chapter; the name finder chapter and the embedder section point to it.
OPENNLP-1988