Package ai.picovoice.picollm
Class PicoLLMGenerateParams.Builder
- java.lang.Object
-
- ai.picovoice.picollm.PicoLLMGenerateParams.Builder
-
- Enclosing class:
- PicoLLMGenerateParams
public static class PicoLLMGenerateParams.Builder extends java.lang.ObjectBuilder class for creating a `PicoLLMGenerateParams` instance.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PicoLLMGenerateParamsbuild()Constructs a newPicoLLMGenerateParamsobject.PicoLLMGenerateParams.BuildersetCompletionTokenLimit(java.lang.Integer completionTokenLimit)Sets the maximum number of tokens allowed in the completion.PicoLLMGenerateParams.BuildersetFrequencyPenalty(float frequencyPenalty)Sets the frequency penalty.PicoLLMGenerateParams.BuildersetNumTopChoices(int numTopChoices)Sets the number of top choices.PicoLLMGenerateParams.BuildersetPresencePenalty(float presencePenalty)Sets the presence penalty.PicoLLMGenerateParams.BuildersetSeed(java.lang.Integer seed)Sets the seed value for the internal random number generator.PicoLLMGenerateParams.BuildersetStopPhrases(java.lang.String[] stopPhrases)Sets the phrases that trigger early completion termination.PicoLLMGenerateParams.BuildersetStreamCallback(PicoLLMStreamCallback streamCallback)Sets the completion stream callback.PicoLLMGenerateParams.BuildersetTemperature(float temperature)Sets the temperature parameter.PicoLLMGenerateParams.BuildersetTopP(float topP)Sets the top-p parameter.
-
-
-
Method Detail
-
setCompletionTokenLimit
public PicoLLMGenerateParams.Builder setCompletionTokenLimit(java.lang.Integer completionTokenLimit)
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
public PicoLLMGenerateParams.Builder setStopPhrases(java.lang.String[] stopPhrases)
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
public PicoLLMGenerateParams.Builder setSeed(java.lang.Integer seed)
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
public PicoLLMGenerateParams.Builder setPresencePenalty(float presencePenalty)
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
public PicoLLMGenerateParams.Builder setFrequencyPenalty(float frequencyPenalty)
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
public PicoLLMGenerateParams.Builder setTemperature(float temperature)
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
public PicoLLMGenerateParams.Builder setTopP(float topP)
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
public PicoLLMGenerateParams.Builder setNumTopChoices(int numTopChoices)
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
public PicoLLMGenerateParams.Builder setStreamCallback(PicoLLMStreamCallback streamCallback)
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
public PicoLLMGenerateParams build()
Constructs a newPicoLLMGenerateParamsobject.- Returns:
- A new
PicoLLMGenerateParamsobject with the parameters set in the builder.
-
-