Skip to main content

Tag Generation

InferTags Query

Overview

The InferTags query is designed to automatically assign relevant tags to a list of items using a specified model backend and tagging configuration. This functionality is crucial for enhancing searchability and categorization within databases or platforms dealing with a wide range of items, especially in e-commerce or content management systems.

Query Structure

The query requires three main arguments:

  • items: An array of ItemInput objects, where each object contains the name and description of the item.
  • modelBackendName: A string specifying the backend model to be used for inferring tags.
  • promptConfig: An object containing configurations for the tagging process, including rules for tag generation and examples of pre-tagged items.
GraphQL Query
query TagItems(
$items: [TagItemInput!]!
$modelBackendName: String!
$promptConfig: PromptConfigInput
) {
inferTags(
items: $items
modelBackendName: $modelBackendName
promptConfig: $promptConfig
) {
labelId
labelValue
predictionId
taggedItem {
item {
description
name
}
tags
}
}
}

Variables Example

{
"items": [
{
"name": "Vintage Leather Jacket",
"description": "A classic vintage leather jacket in brown. Perfect for autumn weather."
},
{
"name": "High-Top Sneakers",
"description": "Unisex high-top sneakers in black. Durable canvas construction with rubber sole."
}
],
"modelBackendName": "data-steward",
"promptConfig": {
"generateTags": true,
"itemNoun": "fashion item",
"itemsNoun": "fashion items",
"maxTags": 5,
"rules": [
"Tag items based on the unique features of the product that help facilitate product search."
],
"tagNoun": "tag",
"tagsNoun": "tags",
"taggedItems": [
{
"item": {
"name": "Retro Canvas Backpack",
"description": "Durable canvas backpack with leather straps and a vintage design."
},
"tags": ["canvas", "leather", "vintage", "backpack"]
},
{
"item": {
"name": "Classic Wool Sweater",
"description": "Soft wool sweater in a classic fit. Available in multiple colors."
},
"tags": ["wool", "soft", "classic", "sweater"]
}
]
}
}

Response Example

{
"data": {
"inferTags": [
{
"labelId": 17,
"labelValue": "vintage, leather, jacket",
"predictionId": 7,
"taggedItem": {
"item": {
"description": "A classic vintage leather jacket in brown. Perfect for autumn weather.",
"name": "Vintage Leather Jacket"
},
"tags": ["vintage", "leather", "jacket"]
}
},
{
"labelId": 18,
"labelValue": "canvas, high-top, sneakers",
"predictionId": 8,
"taggedItem": {
"item": {
"description": "Unisex high-top sneakers in black. Durable canvas construction with rubber sole.",
"name": "High-Top Sneakers"
},
"tags": ["canvas", "high-top", "sneakers"]
}
}
]
}
}

Key Points

  • The promptConfig object allows for detailed configuration of the tagging process, including the specification of rules for automatic tag generation and the provision of example items with pre-assigned tags to guide the model.
  • The rules within promptConfig are expressed in natural language and are intended to direct the model on how to analyze the item descriptions and names for tag generation.
  • The taggedItems within promptConfig serve as examples for the model, showcasing how items should be tagged based on their characteristics. This is particularly useful for training the model or refining its accuracy.
  • The response structure mirrors the input with the addition of tags for each item, illustrating the model's output based on the provided configurations and items.

This documentation is intended to provide a clear understanding of how to use the InferTags query, including the structure, required variables, and expected responses, to facilitate efficient tag generation and item categorization.