public class HuggingFaceTokenizer extends Object implements dev.langchain4j.model.Tokenizer
HuggingFaceTokenizer under the hood.
tokenizer.json to instantiate.
An example.| Constructor and Description |
|---|
HuggingFaceTokenizer()
Creates an instance of a
HuggingFaceTokenizer using a built-in tokenizer.json file. |
HuggingFaceTokenizer(Path pathToTokenizer)
Creates an instance of a
HuggingFaceTokenizer using a provided tokenizer.json file. |
HuggingFaceTokenizer(Path pathToTokenizer,
Map<String,String> options)
Creates an instance of a
HuggingFaceTokenizer using a provided tokenizer.json file
and a map of DJL's tokenizer options. |
HuggingFaceTokenizer(String pathToTokenizer)
Creates an instance of a
HuggingFaceTokenizer using a provided tokenizer.json file. |
HuggingFaceTokenizer(String pathToTokenizer,
Map<String,String> options)
Creates an instance of a
HuggingFaceTokenizer using a provided tokenizer.json file
and a map of DJL's tokenizer options. |
| Modifier and Type | Method and Description |
|---|---|
int |
estimateTokenCountInMessage(dev.langchain4j.data.message.ChatMessage message) |
int |
estimateTokenCountInMessages(Iterable<dev.langchain4j.data.message.ChatMessage> messages) |
int |
estimateTokenCountInText(String text) |
int |
estimateTokenCountInToolExecutionRequests(Iterable<dev.langchain4j.agent.tool.ToolExecutionRequest> toolExecutionRequests) |
int |
estimateTokenCountInToolSpecifications(Iterable<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications) |
public HuggingFaceTokenizer()
HuggingFaceTokenizer using a built-in tokenizer.json file.public HuggingFaceTokenizer(Path pathToTokenizer)
HuggingFaceTokenizer using a provided tokenizer.json file.pathToTokenizer - The path to the tokenizer file (e.g., "/path/to/tokenizer.json")public HuggingFaceTokenizer(Path pathToTokenizer, Map<String,String> options)
HuggingFaceTokenizer using a provided tokenizer.json file
and a map of DJL's tokenizer options.pathToTokenizer - The path to the tokenizer file (e.g., "/path/to/tokenizer.json")options - The DJL's tokenizer optionspublic HuggingFaceTokenizer(String pathToTokenizer)
HuggingFaceTokenizer using a provided tokenizer.json file.pathToTokenizer - The path to the tokenizer file (e.g., "/path/to/tokenizer.json")public HuggingFaceTokenizer(String pathToTokenizer, Map<String,String> options)
HuggingFaceTokenizer using a provided tokenizer.json file
and a map of DJL's tokenizer options.pathToTokenizer - The path to the tokenizer file (e.g., "/path/to/tokenizer.json")options - The DJL's tokenizer optionspublic int estimateTokenCountInText(String text)
estimateTokenCountInText in interface dev.langchain4j.model.Tokenizerpublic int estimateTokenCountInMessage(dev.langchain4j.data.message.ChatMessage message)
estimateTokenCountInMessage in interface dev.langchain4j.model.Tokenizerpublic int estimateTokenCountInMessages(Iterable<dev.langchain4j.data.message.ChatMessage> messages)
estimateTokenCountInMessages in interface dev.langchain4j.model.Tokenizerpublic int estimateTokenCountInToolSpecifications(Iterable<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications)
estimateTokenCountInToolSpecifications in interface dev.langchain4j.model.Tokenizerpublic int estimateTokenCountInToolExecutionRequests(Iterable<dev.langchain4j.agent.tool.ToolExecutionRequest> toolExecutionRequests)
estimateTokenCountInToolExecutionRequests in interface dev.langchain4j.model.TokenizerCopyright © 2024. All rights reserved.