Class LogprobsResultCandidate

java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.LogprobsResultCandidate

public abstract class LogprobsResultCandidate extends JsonSerializable
A single token and its associated log probability.
  • Constructor Details

    • LogprobsResultCandidate

      public LogprobsResultCandidate()
  • Method Details

    • logProbability

      public abstract Optional<Float> logProbability()
      The log probability of this token. A higher value indicates that the model was more confident in this token. The log probability can be used to assess the relative likelihood of different tokens and to identify when the model is uncertain.
    • token

      public abstract Optional<String> token()
      The token's string representation.
    • tokenId

      public abstract Optional<Integer> tokenId()
      The token's numerical ID. While the `token` field provides the string representation of the token, the `token_id` is the numerical representation that the model uses internally. This can be useful for developers who want to build custom logic based on the model's vocabulary.
    • builder

      public static LogprobsResultCandidate.Builder builder()
      Instantiates a builder for LogprobsResultCandidate.
    • toBuilder

      public abstract LogprobsResultCandidate.Builder toBuilder()
      Creates a builder with the same values as this instance.
    • fromJson

      public static LogprobsResultCandidate fromJson(String jsonString)
      Deserializes a JSON string to a LogprobsResultCandidate object.