> ## 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.

# Smart Answers Supervised Training

export const schema = {
  "type": "object",
  "title": "Smart Answers Supervised Training",
  "description": "Trains a Smart Answers model on a supervised basis using pre-trained or custom embeddings and deploys it to the ML Model Service.",
  "required": ["id", "trainingCollection", "trainingFormat", "questionColName", "answerColName", "deployModelName", "modelReplicas", "modelBase", "type"],
  "properties": {
    "id": {
      "type": "string",
      "title": "Job ID",
      "description": "The ID for this job. Used in the API to reference this job. Allowed characters: a-z, A-Z, dash (-) and underscore (_).",
      "maxLength": 63,
      "pattern": "[a-zA-Z][_\\-a-zA-Z0-9]*[a-zA-Z0-9]?"
    },
    "sparkConfig": {
      "type": "array",
      "title": "Additional parameters",
      "description": "Provide additional key/value pairs to be injected into the training JSON map at runtime. Values will be inserted as-is, so use \" to surround string values.",
      "hints": ["advanced"],
      "items": {
        "type": "object",
        "required": ["key"],
        "properties": {
          "key": {
            "type": "string",
            "title": "Parameter Name"
          },
          "value": {
            "type": "string",
            "title": "Parameter Value"
          }
        }
      }
    },
    "writeOptions": {
      "type": "array",
      "title": "Write Options",
      "description": "Sets additional key-value options passed to the Spark writer when writing output to Solr or other sinks.",
      "hints": ["advanced"],
      "items": {
        "type": "object",
        "required": ["key"],
        "properties": {
          "key": {
            "type": "string",
            "title": "Parameter Name"
          },
          "value": {
            "type": "string",
            "title": "Parameter Value"
          }
        }
      }
    },
    "readOptions": {
      "type": "array",
      "title": "Read Options",
      "description": "Sets additional key-value options passed to the Spark reader when loading input from Solr or other sources.",
      "hints": ["advanced"],
      "items": {
        "type": "object",
        "required": ["key"],
        "properties": {
          "key": {
            "type": "string",
            "title": "Parameter Name"
          },
          "value": {
            "type": "string",
            "title": "Parameter Value"
          }
        }
      }
    },
    "useAutoML": {
      "type": "boolean",
      "title": "Perform auto hyperparameter tuning",
      "description": "When enabled, automatically tunes hyperparameters using AutoML. Note that transformer models are not used in AutoML mode.",
      "default": false
    },
    "trainingCollection": {
      "type": "string",
      "title": "Training data path",
      "description": "Specifies the Solr collection or cloud storage path where training data is stored.",
      "minLength": 1
    },
    "trainingFormat": {
      "type": "string",
      "title": "Training data format",
      "description": "Specifies the format of the training data, such as `solr` or `parquet`.",
      "default": "solr",
      "minLength": 1
    },
    "trainingDataFilterQuery": {
      "type": "string",
      "title": "Training Data Filter Query",
      "description": "Specifies a Solr query or SQL expression to filter training data. Use a Solr query when reading from a Solr collection.",
      "hints": ["code/sql", "advanced"]
    },
    "secretName": {
      "type": "string",
      "title": "Cloud storage secret name",
      "description": "Specifies the name of the Kubernetes secret used to access cloud storage.",
      "hints": ["advanced"],
      "minLength": 1
    },
    "questionColName": {
      "type": "string",
      "title": "Question Field",
      "description": "Specifies the field containing question text in the training data.",
      "minLength": 1
    },
    "answerColName": {
      "type": "string",
      "title": "Answer Field",
      "description": "Specifies the field containing answer text in the training data.",
      "minLength": 1
    },
    "weightColName": {
      "type": "string",
      "title": "Weight Field",
      "description": "Specifies the field used as a sample weight during training.",
      "minLength": 1
    },
    "deployModelName": {
      "type": "string",
      "title": "Model Deployment Name",
      "description": "Specifies the model name used for deployment. Must be a valid lowercased DNS subdomain with no underscores.",
      "maxLength": 30,
      "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$"
    },
    "testMode": {
      "type": "boolean",
      "title": "Test Mode",
      "description": "When enabled, exits training after the first iteration. Use this to verify configuration before a full training run.",
      "default": false,
      "hints": ["hidden"]
    },
    "modelReplicas": {
      "type": "integer",
      "title": "Model replicas",
      "description": "Sets the number of Seldon Core replicas to deploy for the trained model.",
      "default": 1
    },
    "modelBase": {
      "type": "string",
      "title": "Model base",
      "description": "Specifies the embedding type: choose `word_custom` or `bpe_custom` for custom embeddings, or a pre-trained embedding model.",
      "enum": ["word_custom", "bpe_custom", "word_en_300d_2M", "bpe_en_300d_10K", "bpe_en_300d_200K", "bpe_ja_300d_100K", "bpe_ko_300d_100K", "bpe_zh_300d_50K", "bpe_multi_300d_320K", "distilbert_en", "distilbert_multi", "biobert_v1.1"],
      "default": "word_en_300d_2M"
    },
    "trainingSampleFraction": {
      "type": "number",
      "title": "Training Data Sampling Fraction",
      "description": "Sets the proportion of data sampled from the full dataset. Use a value between `0` and `1`.",
      "hints": ["advanced"]
    },
    "seed": {
      "type": "integer",
      "title": "Seed",
      "description": "Sets the random seed for reproducible sampling.",
      "default": 12345,
      "hints": ["hidden"]
    },
    "minTokensNum": {
      "type": "integer",
      "title": "Minimum number of words in doc",
      "description": "Sets the minimum number of tokens a document must have. Documents with fewer tokens are dropped.",
      "default": 1,
      "hints": ["advanced"],
      "minimum": 1,
      "exclusiveMinimum": false
    },
    "maxTokensNum": {
      "type": "integer",
      "title": "Maximum number of words in doc",
      "description": "Sets the maximum number of tokens allowed. Documents exceeding this length are dropped.",
      "default": 5000,
      "hints": ["advanced"],
      "minimum": 1,
      "exclusiveMinimum": false
    },
    "lowerCases": {
      "type": "boolean",
      "title": "Lower case all words",
      "description": "When enabled, converts all words to lowercase during training so that case-variant terms are treated identically.",
      "default": false
    },
    "maxVocabSize": {
      "type": "integer",
      "title": "Maximum vocabulary size",
      "description": "Sets the maximum vocabulary size. Low-frequency words are trimmed to enforce this limit.",
      "hints": ["advanced"],
      "minimum": 1,
      "exclusiveMinimum": false
    },
    "w2vEpochs": {
      "type": "integer",
      "title": "Word2Vec training epochs",
      "description": "Sets the number of epochs for training custom Word2Vec embeddings.",
      "default": 15,
      "hints": ["advanced"]
    },
    "w2vTextsCollection": {
      "type": "string",
      "title": "Texts data path",
      "description": "Specifies the Solr collection or cloud storage path containing additional documents used to train Word2Vec embeddings."
    },
    "w2vTextColumns": {
      "type": "string",
      "title": "Texts collection fields",
      "description": "Specifies which fields in the text collection to use for Word2Vec training. Separate multiple fields with commas."
    },
    "textsFormat": {
      "type": "string",
      "title": "Texts format",
      "description": "Specifies the format of the additional text training data, such as `solr` or `parquet`."
    },
    "w2vVectorSize": {
      "type": "integer",
      "title": "Size of word vectors",
      "description": "Sets the dimensionality of Word2Vec word vectors. Suggested range is 100–300.",
      "default": 150,
      "hints": ["advanced"]
    },
    "w2vWindowSize": {
      "type": "integer",
      "title": "Word2Vec window size",
      "description": "Sets the context window size for Word2Vec training.",
      "default": 8,
      "hints": ["advanced"]
    },
    "valSize": {
      "type": "number",
      "title": "Validation sample size",
      "description": "Sets the proportion of unique questions used for validation. When greater than `1`, treated as an absolute count.",
      "default": 0.1,
      "minimum": 0.001,
      "exclusiveMinimum": false
    },
    "maxLen": {
      "type": "integer",
      "title": "Max length",
      "description": "Sets the maximum input length in tokens. Texts longer than this are truncated.",
      "hints": ["advanced"]
    },
    "embSPDP": {
      "type": "number",
      "title": "Dropout ratio",
      "description": "Sets the dropout fraction applied to the embedding layer during training. Use a value between `0` and `1`.",
      "default": 0.3
    },
    "trainBatch": {
      "type": "integer",
      "title": "Training batch size",
      "description": "Sets the training batch size. If blank, the batch size is set automatically based on input data size."
    },
    "infBatch": {
      "type": "integer",
      "title": "Inference batch size used in validation",
      "description": "Sets the batch size used for encoding during training.",
      "hints": ["advanced"]
    },
    "rnnNamesList": {
      "type": "string",
      "title": "RNN function list",
      "description": "Specifies the ordered list of RNN layer types to use, such as `[\"lstm\", \"gru\"]`."
    },
    "rnnUnitsList": {
      "type": "string",
      "title": "RNN function units list",
      "description": "Specifies the number of units for each RNN layer, corresponding to `rnnNamesList`."
    },
    "epochs": {
      "type": "integer",
      "title": "Number of epochs to be used in training"
    },
    "weightDecay": {
      "type": "number",
      "title": "Weight decay",
      "description": "Sets the L2 regularization penalty for the AdamW optimizer. Larger values provide stronger regularization."
    },
    "monitorPatience": {
      "type": "integer",
      "title": "Monitor patience",
      "description": "Sets the number of epochs without improvement after which training stops early."
    },
    "baseLR": {
      "type": "number",
      "title": "Base learning rate",
      "description": "Sets the base learning rate for training. Typical values range from `0.0001` to `0.003`."
    },
    "minLR": {
      "type": "number",
      "title": "Minimum learning rate",
      "description": "Sets the minimum learning rate used during training. Typical values range from `0.00001` to `0.00003`.",
      "hints": ["advanced"]
    },
    "numWarmUpEpochs": {
      "type": "integer",
      "title": "Number of warm-up epochs",
      "description": "Sets the number of warm-up epochs during which the learning rate ramps up from `minLR` to `baseLR`."
    },
    "numFlatEpochs": {
      "type": "integer",
      "title": "Number of flat epochs",
      "description": "Sets the number of epochs during which the learning rate is held at `baseLR`."
    },
    "extraTrainingArgs": {
      "type": "string",
      "title": "Extra training args for Python scripts",
      "description": "Specifies additional arguments passed to the Python training script.",
      "hints": ["hidden"]
    },
    "monitorMetric": {
      "type": "string",
      "title": "Monitor metric",
      "description": "Specifies the metric at K used to determine when to stop training early.",
      "default": "mrr@3"
    },
    "monitorMetricsList": {
      "type": "string",
      "title": "Metrics list",
      "description": "Specifies the list of evaluation metrics computed on validation data and logged at each epoch.",
      "default": "[\"map\", \"mrr\", \"recall\"]"
    },
    "kList": {
      "type": "string",
      "title": "Metrics@k list",
      "description": "Specifies the retrieval positions K at which metrics are computed.",
      "default": "[1,3,5]"
    },
    "numClusters": {
      "type": "integer",
      "title": "Number of clusters",
      "description": "Deprecated. Use Milvus for vector similarity search instead. Sets the number of clusters used during retrieval.",
      "default": 0,
      "hints": ["advanced"]
    },
    "topKClusters": {
      "type": "integer",
      "title": "Top k of clusters to return",
      "description": "Sets the number of nearest clusters the model searches at retrieval time. All answers in those clusters are returned as candidates.",
      "default": 10,
      "hints": ["advanced"]
    },
    "unidecode": {
      "type": "boolean",
      "title": "Apply unicode decoding",
      "description": "When enabled, uses the Unidecode library to convert Unicode input into ASCII transliterations. Only used for custom embeddings.",
      "default": true
    },
    "useMixedPrecision": {
      "type": "string",
      "title": "Use Mixed Precision",
      "description": "When enabled, trains the model using mixed precision. Requires a GPU node with mixed precision support.",
      "enum": ["auto", "true", "false"],
      "default": "auto",
      "hints": ["advanced"]
    },
    "useLabelingResolution": {
      "type": "boolean",
      "title": "Use Labeling Resolution",
      "description": "When enabled, identifies similar questions and answers using labeling resolution and graph connectivity. Does not work well with noisy data.",
      "default": false
    },
    "useLayerNorm": {
      "type": "boolean",
      "title": "Use Layer Norm",
      "description": "When enabled, applies layer normalization during pooling.",
      "default": false,
      "hints": ["advanced"]
    },
    "globalPoolType": {
      "type": "string",
      "title": "Global Pool Type",
      "description": "Specifies how token vectors are aggregated into a single content vector. Must be one of `avg`, `max`, or `self_attention`.",
      "enum": ["avg", "max", "self_attention"],
      "default": "self_attention",
      "hints": ["advanced"]
    },
    "embTrainable": {
      "type": "boolean",
      "title": "Fine-tune Token Embeddings",
      "description": "When enabled, fine-tunes token embeddings during model training alongside the classification layers.",
      "default": false,
      "hints": ["advanced"]
    },
    "eps": {
      "type": "number",
      "title": "Eps",
      "description": "Sets the epsilon value for the AdamW optimizer. Default is `1e-8` for RNN models and `1e-6` for transformer models.",
      "hints": ["advanced"]
    },
    "maxGradNorm": {
      "type": "number",
      "title": "Max Grad Norm",
      "description": "Sets the maximum gradient norm for gradient clipping. Default is not applied for RNN models and `1.0` for transformer models.",
      "hints": ["advanced"]
    },
    "useXbm": {
      "type": "string",
      "title": "Use Cross-batch memory",
      "description": "When enabled, stores encoded representations of previous batches in memory for improved negative example sampling. Works well for Transformer models. Leave this at `false` for other models.",
      "enum": ["auto", "true", "false"],
      "default": "auto",
      "hints": ["advanced"]
    },
    "xbmMemorySize": {
      "type": "integer",
      "title": "Cross-batch memory size",
      "description": "Sets the number of examples from previous batches stored in cross-batch memory.",
      "hints": ["advanced"]
    },
    "xbmEpochActivation": {
      "type": "integer",
      "title": "Cross-batch epoch activation",
      "description": "Sets the epoch after which cross-batch memory is activated.",
      "hints": ["advanced"]
    },
    "evalAnnIndex": {
      "type": "string",
      "title": "Eval ANN index",
      "description": "When enabled, uses approximate nearest neighbor search during evaluation to speed up retrieval for large datasets.",
      "enum": ["auto", "true", "false"],
      "default": "auto",
      "hints": ["advanced"]
    },
    "distance": {
      "type": "string",
      "title": "Distance",
      "description": "Specifies the distance or similarity function used during training and retrieval. Choose from `cosine_similarity`, `dot_product_similarity`, or `euclidean_distance`.",
      "enum": ["cosine_similarity", "dot_product_similarity", "euclidean_distance"],
      "default": "cosine_similarity",
      "hints": ["advanced"]
    },
    "type": {
      "type": "string",
      "title": "Spark Job Type",
      "enum": ["argo-qna-supervised"],
      "default": "argo-qna-supervised",
      "hints": ["readonly"]
    }
  },
  "additionalProperties": true,
  "category": "Other",
  "categoryPriority": 1,
  "propertyGroups": [{
    "label": "Input/Output Parameters",
    "properties": ["trainingCollection", "trainingFormat", "trainingDataFilterQuery", "seed", "trainingSampleFraction", "questionColName", "answerColName", "weightColName", "w2vTextsCollection", "w2vTextColumns", "textsFormat", "deployModelName", "modelReplicas", "secretName"]
  }, {
    "label": "Data Preprocessing",
    "properties": ["useLabelingResolution", "unidecode", "lowerCases", "minTokensNum", "maxTokensNum", "maxVocabSize"]
  }, {
    "label": "Custom Embeddings Initialization",
    "properties": ["w2vEpochs", "w2vVectorSize", "w2vWindowSize"]
  }, {
    "label": "Evaluation Parameters",
    "properties": ["valSize", "monitorMetric", "monitorPatience", "monitorMetricsList", "kList", "evalAnnIndex"]
  }, {
    "label": "General Encoder Parameters",
    "properties": ["embTrainable", "maxLen", "globalPoolType", "useLayerNorm", "numClusters", "topKClusters"]
  }, {
    "label": "RNN Encoder Parameters",
    "properties": ["embSPDP", "rnnNamesList", "rnnUnitsList"]
  }, {
    "label": "Training Parameters",
    "properties": ["epochs", "trainBatch", "infBatch", "baseLR", "numWarmUpEpochs", "numFlatEpochs", "minLR", "weightDecay", "distance", "eps", "maxGradNorm", "useMixedPrecision", "useXbm", "xbmMemorySize", "xbmEpochActivation"]
  }]
};

export const SchemaParamFields = ({schema}) => {
  const sanitize = str => {
    if (typeof str !== "string") return str;
    return str.replace(/^"(.*)"$/s, "$1").replace(/\\/g, "").replace(/"/g, "'");
  };
  const renderMd = str => {
    const s = sanitize(str);
    const text = (/[.!?]\)*$/).test(s) ? s : `${s}.`;
    return text.split(/(\*\*[^*]+\*\*|_[^_]+_|`[^`]+`)/g).map((part, i) => {
      if (part.startsWith("**")) return <strong key={i}>{part.slice(2, -2)}</strong>;
      if (part.startsWith("_")) return <em key={i}>{part.slice(1, -1)}</em>;
      if (part.startsWith("`")) return <code key={i}>{part.slice(1, -1)}</code>;
      return part;
    });
  };
  const {description, properties = {}, required: requiredProps = []} = schema;
  const visibleProps = useMemo(() => Object.entries(properties).filter(([, prop]) => !prop.hints?.includes("hidden")), [properties]);
  const renderProp = ([name, prop]) => {
    const isRequired = requiredProps.includes(name);
    const hasDefault = prop.default !== undefined;
    const rawDefault = prop.default;
    const hints = prop.hints || [];
    const isComplexDefault = hasDefault && (typeof rawDefault === "object" || typeof rawDefault === "string" && (rawDefault.length > 20 || rawDefault.includes('"')));
    const postBadges = [];
    if (prop.title) {
      postBadges.push(<><span className="text-stone-400 dark:text-stone-500">API property: </span>{name}</>);
    }
    const constraints = [];
    if (prop.minimum !== undefined && prop.maximum !== undefined) {
      constraints.push(`Range: ${prop.minimum} – ${prop.maximum}`);
    } else if (prop.minimum !== undefined) {
      constraints.push(`Min: ${prop.minimum}`);
    } else if (prop.maximum !== undefined) {
      constraints.push(`Max: ${prop.maximum}`);
    }
    if (prop.minLength !== undefined && prop.maxLength !== undefined) {
      constraints.push(`Length: ${prop.minLength} – ${prop.maxLength}`);
    } else if (prop.minLength !== undefined) {
      constraints.push(`Min length: ${prop.minLength}`);
    } else if (prop.maxLength !== undefined) {
      constraints.push(`Max length: ${prop.maxLength}`);
    }
    const fieldProps = {
      key: name,
      body: prop.title || name,
      type: prop.type,
      ...postBadges.length > 0 && ({
        post: postBadges
      }),
      ...isRequired && ({
        required: true
      }),
      ...!isComplexDefault && hasDefault ? {
        default: sanitize(String(rawDefault))
      } : {}
    };
    const isObject = prop.type === "object" && prop.properties;
    const isArrayOfObjects = prop.type === "array" && prop.items?.type === "object" && prop.items.properties;
    return <ParamField {...fieldProps}>
        {prop.description && <p>{renderMd(prop.description)}</p>}

        {prop.enum && <p>
            Allowed values: 
            {prop.enum.map((v, i) => <>{i > 0 && ", "}<code key={i}>{String(v)}</code></>)}
          </p>}

        {constraints.length > 0 && <p className="text-stone-500 dark:text-stone-400 text-sm">
            {constraints.join(" · ")}
          </p>}

        {isComplexDefault && <div className="flex">
            <p>
              <strong>Default:</strong>
            </p>
            <pre className="!my-0">
              <code>
                {JSON.stringify(rawDefault, null, 2)}
              </code>
            </pre>
          </div>}

        {isArrayOfObjects && <Expandable title="item properties">
            <SchemaParamFields schema={{
      properties: prop.items.properties,
      required: prop.items.required
    }} />
          </Expandable>}

        {isObject && <Expandable title="properties">
            <SchemaParamFields schema={{
      properties: prop.properties,
      required: prop.required
    }} />
          </Expandable>}
      </ParamField>;
  };
  return <div>
      {description && <p>{renderMd(description)}</p>}

      {visibleProps.map(renderProp)}
    </div>;
};

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/5/fusion/reference/config-ref/jobs/smart-answers-supervised-training

[mintlify link]: https://doc.lucidworks.com/docs/5/fusion/reference/config-ref/jobs/smart-answers-supervised-training

[old doc.lw link]: https://doc.lucidworks.com/fusion/5.9/8845

Train a [Smart Answers](/docs/5/fusion/getting-data-out/advanced-query-enhancement/smart-answers/overview) model on a supervised basis, with pre-trained or trained embeddings, and deploy the trained model to the ML Model Service.

See [Train a Smart Answers Supervised Model](/docs/5/fusion/getting-data-out/advanced-query-enhancement/smart-answers/overview#train-a-smart-answers-supervised-model) for configuration instructions.

<LwTemplate />

## Configuration properties

<SchemaParamFields schema={schema} />
