Foundation Models Text Classification API, REST: TextClassification.FewShotClassify

RPC method for binary and multi-class classification.

You can provide up to 20 classes for few-shot text classification
with optional examples.

HTTP request

POST https://llm.api.cloud.yandex.net/foundationModels/v1/fewShotTextClassification
        

Body parameters

{
          "modelUri": "string",
          "taskDescription": "string",
          "labels": [
            "string"
          ],
          "text": "string",
          "samples": [
            {
              "text": "string",
              "label": "string"
            }
          ]
        }
        

Request for the service to classify text.
For examples of usage, see step-by-step guides.

Field

Description

modelUri

string

The URI of the classifier model.

taskDescription

string

Text description of the classification task.

labels[]

string

List of available labels for the classification result.
Give meaningful names to label classes: this is essential for correct classification results.
For example, use chemistry and physics rather than chm and phs for class names.

text

string

Text for classification.

samples[]

ClassificationSample

Optional set of text samples with expected labels that may be used as an additional hint for the classifier.

ClassificationSample

Description of a sample for the classification task.

Field

Description

text

string

Text sample.

label

string

Expected label for a given text.

Response

HTTP Code: 200 - OK

{
          "predictions": [
            {
              "label": "string",
              "confidence": "string"
            }
          ],
          "modelVersion": "string",
          "inputTokens": "string"
        }
        

Response containing classifier predictions.

Field

Description

predictions[]

ClassificationLabel

The classification results with the `confidence`` values
for the probability of classifying the request text into each class.

modelVersion

string

The model version changes with each new releases.

inputTokens

string (int64)

Number of input tokens

ClassificationLabel

A pair of text labels and their corresponding confidence values.

Field

Description

label

string

A class name label.

confidence

string

The probability of classifying text into a specific class.

Previous