> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Classification use case

> The classification use case lets you use embedding models to compute similarity scores between the incoming text and the labels. It returns the labels ranked in order of most similar to least similar. 

The classification use case is compatible with all Lucidworks hosted pre-trained and custom embedding models. The default behavior of embedding models is to always have a score returned.
 
 The `topK` and `similarityCutoff` parameters can be used to achieve behaviors where only the following are returned:

 * The single most applicable label

 * Labels with similarities that exceed a threshold
 
 * A set number of items

 * A set number if it exceeds the threshold






## OpenAPI

````yaml /api-reference/saas/machine-learning-platform-predict.json post /ai/prediction/classification/{MODEL_ID}
openapi: 3.0.1
info:
  title: Lucidworks AI Prediction API
  version: v0
  description: >-
    The Lucidworks AI Prediction API is used to send synchronous API calls that
    run predictions from pre-trained models or custom models.


    The Use Case API returns a list of all supported models.


    The `prediction` endpoints require an authentication token with scope
    `machinelearning.predict`.
  contact:
    name: Lucidworks
    url: https://lucidworks.com/
    email: support@lucidworks.com
  termsOfService: https://lucidworks.com/legal/developer-license-agreement/
  license:
    name: Lucidworks
    url: https://lucidworks.com/legal/developer-license-agreement/
servers:
  - url: https://APPLICATION_ID.applications.lucidworks.com
    description: Production
security: []
tags:
  - name: Get predictions
    description: Submit prediction tasks to Lucidworks AI.
paths:
  /ai/prediction/classification/{MODEL_ID}:
    parameters:
      - schema:
          type: string
        name: MODEL_ID
        in: path
        required: true
        description: Unique identifier for the model.
        example: bge-large
    post:
      tags:
        - Get predictions
      summary: Classification use case
      description: >+
        The classification use case lets you use embedding models to compute
        similarity scores between the incoming text and the labels. It returns
        the labels ranked in order of most similar to least similar. 


        The classification use case is compatible with all Lucidworks hosted
        pre-trained and custom embedding models. The default behavior of
        embedding models is to always have a score returned.
         
         The `topK` and `similarityCutoff` parameters can be used to achieve behaviors where only the following are returned:

         * The single most applicable label

         * Labels with similarities that exceed a threshold
         
         * A set number of items

         * A set number if it exceeds the threshold


      operationId: post-ai-prediction-classification-modelId
      parameters:
        - in: header
          name: Authorization
          schema:
            type: string
          required: true
          description: >-
            Bearer token used for authentication. Format: `Authorization: Bearer
            ACCESS_TOKEN`.
          example: Bearer abc123def456
        - schema:
            type: string
            example: application/json
          in: header
          name: Content-Type
          description: application/json
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClassificationRequest'
            example:
              batch:
                - text: Not all those who wander are lost.
              useCaseConfig:
                labels:
                  - Harry Potter
                  - Lord of the Rings
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassificationResponse'
              example:
                predictions:
                  - tokensUsed:
                      inputTokens: 10
                      labelsTokens: 26
                    labels:
                      Lord of the Rings: 0.40380859375
                      Harry Potter: 0.3681640625
                    response: 'Lord of the Rings: 0.40, Harry Potter: 0.37'
components:
  schemas:
    ClassificationRequest:
      title: ClassificationRequest
      type: object
      x-examples: {}
      properties:
        batch:
          type: array
          description: >-
            The batch of key:value pairs used as inputs in the prediction. Up to
            32 inputs per request are allowed.
          maxItems: 32
          items:
            type: object
            properties:
              text:
                type: string
                description: The content the model analyzes.
                example: Not all those who wander are lost.
        useCaseConfig:
          $ref: '#/components/schemas/UseCaseConfigClassification'
    ClassificationResponse:
      type: object
      x-examples: {}
      items:
        type: object
        properties:
          predictions:
            type: array
            items:
              type: object
              properties:
                tokensUsed:
                  type: object
                  properties:
                    inputTokens:
                      type: integer
                      example: 11
                      description: >-
                        The number of tokens created from the text input into
                        the model.
                    labelTokens:
                      type: integer
                      description: >-
                        The number of tokens created from the labels entered in
                        the request.
                      example: 14
                labels:
                  type: string
                  description: |
                    This is a list of strings that classify information.

                    For example:

                     "labels": {
                           "Lord of the Rings": 0.7287280559539795,
                            "Harry Potter": 0.7193666100502014
                        }
    UseCaseConfigClassification:
      title: UseCaseConfigClassification
      type: object
      required:
        - labels
      properties:
        labels:
          type: array
          description: |-
            This is a list of strings that classify information. 

            For example, 

            "labels": ["Harry Potter", "Lord of the Rings"]
          items:
            type: string
        topK:
          type: integer
          description: >-
            The data structure that identifies the most frequent items in a set
            of data.


            This is the number of top-scored labels to return.
          example: 10
        similarityCutoff:
          type: number
          example: 1
          description: >-
            This decimal field is the similarity score cutoff to filter out less
            similar fields.
          format: float

````