Class LlmClassifier
java.lang.Object
com.google.adk.classifiers.LlmClassifier
- All Implemented Interfaces:
Classifier
Answers typed questions with any
BaseLlm through structured output. The model is asked
for a probability for every option and constrained to a JSON schema built from the questions, so
it can only answer with the given labels. The probabilities are the model's stated values rather
than token log-probabilities, so check their calibration with evals before relying on a
threshold.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic LlmClassifier.Builderbuilder()io.reactivex.rxjava3.core.Single<ClassifierResponse> classify(ClassifierRequest request) Asks the model every question ofrequestin one structured-output call.Optional<com.google.genai.types.GenerateContentConfig> Returns the generation settings that every model call starts from, if set.name()Returns the name of the model that answers the questions.
-
Method Details
-
builder
-
name
Returns the name of the model that answers the questions.- Specified by:
namein interfaceClassifier
-
generateContentConfig
Returns the generation settings that every model call starts from, if set. -
classify
Asks the model every question ofrequestin one structured-output call. Choice and score probabilities are clamped at 0 and normalized to sum to 1; a binary probability must lie in [0, 1]. The returnedSinglefails withIllegalStateExceptionif the model returns no response, reports an error, runs out of output tokens, or answers without a usable probability for every question and option.- Specified by:
classifyin interfaceClassifier
-