Class ScaleAnswer

java.lang.Object
dev.langchain4j.model.decision.response.ScaleAnswer
All Implemented Interfaces:
DecisionAnswer

@Experimental public final class ScaleAnswer extends Object implements DecisionAnswer
The answer to a ScaleQuestion: the mean level, the probability of each level and, if the model reports one, a confidence.
Since:
1.21.0
  • Method Details

    • mean

      public double mean()
      The probability-weighted mean of the level indexes, from 0 (the lowest level) to n - 1 (the highest level). It can fall between two levels: with levels "Calm", "Frustrated" and "Angry", a mean of 1.4 means "between frustrated and angry, closer to frustrated".
    • probabilities

      public List<Double> probabilities()
      The probability of each level, indexed like ScaleQuestion.levels(). Empty if the model does not report probabilities.
    • confidence

      public Double confidence()
      How confident the model is in mean(), from 0 to 1, or null if the model does not report a confidence.

      The formula is defined by each model and differs between models, so a threshold tuned for one model does not carry over to another.

    • builder

      public static ScaleAnswer.Builder builder()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object