Table of Contents

Class LogprobsResult

Namespace
Google.GenAI.Types
Assembly
Google.GenAI.dll

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.

public record LogprobsResult : IEquatable<LogprobsResult>
Inheritance
LogprobsResult
Implements
Inherited Members

Properties

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.

[JsonPropertyName("chosenCandidates")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<LogprobsResultCandidate>? ChosenCandidates { get; set; }

Property Value

List<LogprobsResultCandidate>

LogProbabilitySum

Sum of log probabilities for all tokens. This field is not supported in Vertex AI.

[JsonPropertyName("logProbabilitySum")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? LogProbabilitySum { get; set; }

Property Value

double?

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.

[JsonPropertyName("topCandidates")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<LogprobsResultTopCandidates>? TopCandidates { get; set; }

Property Value

List<LogprobsResultTopCandidates>

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a LogprobsResult object.

public static LogprobsResult? FromJson(string jsonString, JsonSerializerOptions? options = null)

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

LogprobsResult

The deserialized LogprobsResult object, or null if deserialization fails.