|
30 | 30 | import java.io.InputStream;
|
31 | 31 | import java.nio.file.Files;
|
32 | 32 | import java.nio.file.Path;
|
| 33 | +import java.nio.file.Paths; |
33 | 34 | import java.util.Arrays;
|
34 | 35 | import java.util.List;
|
35 | 36 | import java.util.Locale;
|
@@ -686,7 +687,6 @@ static PaddingStrategy fromValue(String value) {
|
686 | 687 | /** The builder for creating huggingface tokenizer. */
|
687 | 688 | public static final class Builder {
|
688 | 689 |
|
689 |
| - private Path tokenizerPath; |
690 | 690 | private NDManager manager;
|
691 | 691 | private Map<String, String> options;
|
692 | 692 |
|
@@ -724,7 +724,7 @@ public Builder optTokenizerName(String tokenizerName) {
|
724 | 724 | * @return this builder
|
725 | 725 | */
|
726 | 726 | public Builder optTokenizerPath(Path tokenizerPath) {
|
727 |
| - this.tokenizerPath = tokenizerPath; |
| 727 | + options.putIfAbsent("tokenizerPath", tokenizerPath.toString()); |
728 | 728 | return this;
|
729 | 729 | }
|
730 | 730 |
|
@@ -894,9 +894,11 @@ public HuggingFaceTokenizer build() throws IOException {
|
894 | 894 | if (tokenizerName != null) {
|
895 | 895 | return managed(HuggingFaceTokenizer.newInstance(tokenizerName, options));
|
896 | 896 | }
|
897 |
| - if (tokenizerPath == null) { |
| 897 | + String path = options.get("tokenizerPath"); |
| 898 | + if (path == null) { |
898 | 899 | throw new IllegalArgumentException("Missing tokenizer path.");
|
899 | 900 | }
|
| 901 | + Path tokenizerPath = Paths.get(path); |
900 | 902 | if (Files.isDirectory(tokenizerPath)) {
|
901 | 903 | Path tokenizerFile = tokenizerPath.resolve("tokenizer.json");
|
902 | 904 | if (Files.exists(tokenizerFile)) {
|
|
0 commit comments