Class LogprobsResult

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

public abstract class LogprobsResult extends JsonSerializable
The log probabilities of the tokens generated by the model. This is useful for understanding the model's confidence in its predictions and for debugging. For example, you can use log probabilities to identify when the model is making a less confident prediction or to explore alternative responses that the model considered. A low log probability can also indicate that the model is "hallucinating" or generating factually incorrect information.
  • Constructor Details

    • LogprobsResult

      public LogprobsResult()
  • Method Details

    • chosenCandidates

      public abstract Optional<List<LogprobsResultCandidate>> chosenCandidates()
      A list of the chosen candidate tokens at each decoding step. The length of this list is equal to the total number of decoding steps. Note that the chosen candidate might not be in `top_candidates`.
    • topCandidates

      public abstract Optional<List<LogprobsResultTopCandidates>> topCandidates()
      A list of the top candidate tokens at each decoding step. The length of this list is equal to the total number of decoding steps.
    • builder

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

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

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