Skip to main content

Usage

The following example shows how the step can be used in a recipe.

Examples

Generate topics for a given text column
infer_topics(ds.texts, {
    "integration": "open-ai-1",
    "n_topics": 10,
    "n_subtopics": 5,
    "inference_model": "openai/gpt-4.1",
    "assignment_model": "openai/gpt-4.1-mini",
}) ->(ds.topic, ds.subtopic)

Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally columns (ds.first_name), datasets (ds or ds[["first_name", "last_name"]]) or models (referenced by name e.g. "churn-clf").
texts
column[category|text]
required
Column containing the texts to infer topics from.
topic
column[category]
required
Inferred topic for each text.
subtopic
column[category]
required
Inferred subtopic for each text.

Configuration

The following parameters can be used to configure the behaviour of the step by including them in a json object as the last “input” to the step, i.e. step(..., {"param": "value", ...}) -> (output).

Parameters

integration
string
required
Associated integration.
n_topics
integer
default:"10"
Number of Topics. Maximum approximate number of topics to infer.Values must be in the following range:
2n_topics20
n_subtopics
integer
default:"5"
Number of Subtopics. Maximum approximate number of subtopics to infer per topic.Values must be in the following range:
2n_subtopics10
n_samples
integer
default:"500"
Number of Samples. Maximum number of text samples to use for topic extraction. More texts consume more tokens and increase cost.Values must be in the following range:
1n_samples10000
multitopic
boolean
default:"false"
Multi-topic Assignment. Whether to allow assigning multiple topics to each text. If enabled, the output columns will contain lists of topics/subtopics instead of single values.
inference_model
string
Inference AI Model. AI model used to infer topic hierarchy. This model will receive all sample texts, so potentially a large context, and needs to be reasonably capable to generate a well-structured topic hierarchy (no repeated or similar topics etc.).Values must be one of the following:openai/gpt-4.1 openai/gpt-4.1-mini openai/gpt-4.1-nano openai/gpt-5 openai/gpt-5-mini openai/gpt-5-nano openai/gpt-5.1 openai/gpt-5.2
assignment_model
string
Assignment AI Model. AI model used to assign topic and subtopics to each text (row). This model will receive individual texts along with the inferred topic hierarchy, so it can be a smaller model focused on classification.Values must be one of the following:openai/gpt-4.1 openai/gpt-4.1-mini openai/gpt-4.1-nano openai/gpt-5 openai/gpt-5-mini openai/gpt-5-nano openai/gpt-5.1 openai/gpt-5.2
inference_params
object
Inference Parameters. Additional parameters passed to the responses API for the inference call.
assignment_params
object
Assignment Parameters. Additional parameters passed to the responses API for the assignment call.