Package ai.picovoice.picollm
Class PicoLLMGenerateParams.Builder
java.lang.Object
ai.picovoice.picollm.PicoLLMGenerateParams.Builder
- Enclosing class:
- PicoLLMGenerateParams
Builder class for creating a `PicoLLMGenerateParams` instance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Constructs a newPicoLLMGenerateParamsobject.setCompletionTokenLimit(Integer completionTokenLimit) Sets the maximum number of tokens allowed in the completion.setFrequencyPenalty(float frequencyPenalty) Sets the frequency penalty.setNumTopChoices(int numTopChoices) Sets the number of top choices.setPresencePenalty(float presencePenalty) Sets the presence penalty.Sets the seed value for the internal random number generator.setStopPhrases(String[] stopPhrases) Sets the phrases that trigger early completion termination.setStreamCallback(PicoLLMStreamCallback streamCallback) Sets the completion stream callback.setTemperature(float temperature) Sets the temperature parameter.setTopP(float topP) Sets the top-p parameter.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
setCompletionTokenLimit
Sets the maximum number of tokens allowed in the completion.- Parameters:
completionTokenLimit- The maximum number of tokens allowed in the completion. If the generation process stops due to reaching this limit, the endpoint output argument will indicate a completion token limit reached condition.If not set, there will be no limit imposed.- Returns:
Builderinstance.
-
setStopPhrases
Sets the phrases that trigger early completion termination.- Parameters:
stopPhrases- Phrases that trigger early completion termination. The generation process stops when it encounters any of these phrases in the completion. The already generated completion, including the encountered stop phrase, will be returned. Set tonullto turn off this feature.- Returns:
Builderinstance.
-
setSeed
Sets the seed value for the internal random number generator.- Parameters:
seed- The seed value for the internal random number generator. Seeding enforces deterministic outputs. If not set, randomized outputs will be generated for a given prompt.- Returns:
Builderinstance.
-
setPresencePenalty
Sets the presence penalty.- Parameters:
presencePenalty- The presence penalty. It penalizes logits already appearing in the partial completion if set to a positive value. If set to 0.0, it has no effect.- Returns:
Builderinstance.
-
setFrequencyPenalty
Sets the frequency penalty.- Parameters:
frequencyPenalty- The frequency penalty. If set to a positive floating-point value, it penalizes logits proportional to the frequency of their appearance in the partial completion. If set to 0.0, it has no effect.- Returns:
Builderinstance.
-
setTemperature
Sets the temperature parameter.- Parameters:
temperature- The temperature parameter. A higher temperature smoothens the sampler's output, increasing the randomness. In contrast, a lower temperature creates a narrower distribution and reduces variability. Setting it to 0 selects the maximum logit during sampling.- Returns:
Builderinstance.
-
setTopP
Sets the top-p parameter.- Parameters:
topP- The top-p parameter. A positive floating-point number within (0, 1]. It restricts the sampler's choices to high-probability logits that form the top_p portion of the probability mass. Hence, it avoids randomly selecting unlikely logits. A value of 1.0 enables the sampler to pick any token with non-zero probability, turning off the feature.- Returns:
Builderinstance.
-
setNumTopChoices
Sets the number of top choices.- Parameters:
numTopChoices- The number of top choices. If set to a positive value, picoLLM returns the list of the highest probability tokens for any generated token. Set to 0 to turn off the feature. The maximum number of top choices is determined by pv_picollm_max_top_choices().- Returns:
Builderinstance.
-
setStreamCallback
Sets the completion stream callback.- Parameters:
streamCallback- The stream callback. If not set to null, picoLLM executes this callback every time a new piece of completion string becomes available.- Returns:
Builderinstance.
-
build
Constructs a newPicoLLMGenerateParamsobject.- Returns:
- A new
PicoLLMGenerateParamsobject with the parameters set in the builder.
-