Class PicoLLMGenerateParams.Builder

  • Enclosing class:
    PicoLLMGenerateParams

    public static class PicoLLMGenerateParams.Builder
    extends java.lang.Object
    Builder class for creating a `PicoLLMGenerateParams` instance.
    • Constructor Detail

      • Builder

        public Builder()
    • 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:
        Builder instance.
      • 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 to null to turn off this feature.
        Returns:
        Builder instance.
      • 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:
        Builder instance.
      • 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:
        Builder instance.
      • 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:
        Builder instance.
      • 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:
        Builder instance.
      • 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:
        Builder instance.
      • 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:
        Builder instance.
      • 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:
        Builder instance.
      • build

        public PicoLLMGenerateParams build()
        Constructs a new PicoLLMGenerateParams object.
        Returns:
        A new PicoLLMGenerateParams object with the parameters set in the builder.