Skip to main content
Version: 2024.1

Hugging Face Zero Shot Text Classification

This action can be executed on data object level lets you automatically send predefined template to a configurable Hugging Face endpoint to classify the data object. There are different variants to configure the classification. For more information about the Hugging Face Zero Shot Text Classification, please visit Hugging Face Zero Shot Text Classification.

Classification Variants

Apply classification on a select or multiselect field

Configuration Options

This variant of the action can be used to classify the data object based on the values of a select or multiselect field. The configuration options for this variant are as follows:

 template: "{{ subject.name }} is a {{ subject.type }} of {{ subject.color|join(', ') }} color."
select_attribute_field: brand
replace_existing_selection: true
minimum_confidence: 0.8
best_match_only: true
model_endpoint: 'https://api-inference.huggingface.co/models/facebook/bart-large-mnli'

Detailed Configuration Options

  • template: Required string. A Twig template string that defines the input to be sent to the AI model. All attributes of the data object can be used in the template using the subject variable.
  • select_attribute_field: Required string. The name of the select or multiselect field to be used for classification.
  • replace_existing_selection: Type: Boolean. Default: false. If true, existing selection will be replaced with the new ones. This only applies to multiselect fields.
  • minimum_confidence: Type: Float. Default: 0.8. The minimum confidence for a selection to be added to the data object.
  • best_match_only: Type: Boolean. Default: true. If true, only the best match will be used otherwise the minimum confidence will be used and all selection with a confidence higher than the minimum confidence will be used. This only applies to multiselect fields.
  • model_endpoint: Type: String. Endpoint url of the Hugging Face model to use.
  • label_limit: Type: Integer. Default: 10. The maximum number of labels that can be passed to the classification model. Currently, the Hugging Face model only supports up to 10 labels.

Apply classification on the pimcore tags

Configuration Options

This variant of the action can be used to classify the data object based on the pimcore tags. The configuration options for this variant are as follows:

 template: "{{ subject.name }} is a {{ subject.type }} of {{ subject.color|join(', ') }} color."
replace_existing_tags: true
tag_root_node: 0
tag_only_leaf_nodes: true
minimum_confidence: 0.8
best_match_only: true
model_endpoint: 'https://api-inference.huggingface.co/models/facebook/bart-large-mnli'

Detailed Configuration Options

  • template: Required string. A Twig template string that defines the input to be sent to the AI model. All attributes of the data object can be used in the template using the subject variable.
  • replace_existing_tag: Type: Boolean. Default: false. If true, existing tags will be replaced with the new ones.
  • minimum_confidence: Type: Float. Default: 0.8. The minimum confidence for a tag to be added to the data object.
  • tag_root_node: Type: Integer. Default: 0. The root node of the tag to be used for classification.
  • tag_only_leaf_nodes: Type: Boolean. Default: true. If true, only the leaf nodes of the tag will be used for classification.
  • best_match_only: Type: Boolean. Default: true. If true, only the best match will be used otherwise the minimum confidence will be used and all selection with a confidence higher than the minimum confidence will be used. This only applies to multiselect fields.
  • model_endpoint: Type: String. Endpoint url of the Hugging Face model to use.
  • tag_limit: Type: Integer. Default: 10. The maximum number of tags that can be passed to the classification model. Currently, the Hugging Face model only supports up to 10 tags.