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

[tokenizer] Fixes tokenizer bug #2843

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ public HuggingFaceTokenizer build() throws IOException {
return managed(HuggingFaceTokenizer.newInstance(vocab, merges, options));
}
throw new IOException("tokenizer.json file not found.");
} else if (Files.exists(tokenizerPath)) {
} else if (!Files.exists(tokenizerPath)) {
throw new IOException("Tokenizer file not exits: " + tokenizerPath);
}
return managed(HuggingFaceTokenizer.newInstance(tokenizerPath, options));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public void testTokenizer() throws IOException {
Assert.assertEquals(encodings.length, 2);
Assert.assertEquals(encodings[0].getIds(), ids);
}

Assert.assertThrows(
() -> {
Path file = Paths.get("build/tokenizer/non-exists.json");
HuggingFaceTokenizer.builder().optTokenizerPath(file).build();
});
}

@Test
Expand Down
Loading