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

# infer_aspect_sentiment

> Extract aspect-based sentiments from texts using OpenAI. Identifies entities mentioned in texts with clear positive or negative expressed polarity. Returns three parallel columns of equal length containing the extracted entities, their associated sentiments, and the reasons for the sentiment. Optionally, when aspect_categories is provided and four output columns are specified, returns a fourth column with the category classification for each extracted entity. 

For GPT-6 models, configure `reasoning_effort` in the corresponding API parameters
object. Luna defaults to `none`; Sol defaults to `medium`. Explicit reasoning levels
are preserved, except `minimal` becomes `low` for either model and Sol uses `low`
when `none` is requested. Temperature and sampling settings are ignored when
reasoning is enabled.

## Usage

The following examples show how the step can be used in a recipe.

> **Examples**
>
> **Example 1**
>
> Extract aspect sentiments from a text column
>
> ```stan theme={null}
> infer_aspect_sentiment(ds.texts, {
>     "integration": "open-ai-1",
>     "model": "openai/gpt-4.1",
> }) -> (ds.entities, ds.sentiments, ds.reasons)
> ```
>
> **Example 2**
>
> Extract aspect sentiments with category classification
>
> ```stan theme={null}
> infer_aspect_sentiment(ds.texts, {
>     "integration": "open-ai-1",
>     "model": "openai/gpt-4.1",
>     "aspect_categories": ["food", "service", "pricing", "cleanliness"],
> }) -> (ds.entities, ds.sentiments, ds.reasons, ds.categories)
> ```
>
> **Signature**
>
> General syntax for using the step in a recipe. Shows the inputs and outputs the step is expected to receive and will produce respectively. For futher details see sections below.
>
> ```stan theme={null}
> infer_aspect_sentiment(texts: category|text, {
>     "param": value,
>     ...
> }) -> (*sentiments: column)
> ```

## 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"`).

> **Inputs**
>
> **texts** `column[category|text]` *required*
>
> Column containing the texts to extract aspect sentiments from.

> **Outputs**
>
> \***sentiments** `column`
>
> Output columns for aspect sentiment results. If three column names are provided, returns
> entities, sentiments, and reasons. If four column names are provided and aspect\_categories
> is set, additionally returns the category classification for each entity.

## 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.
>
> **model** `string` (default: openai/gpt-4.1)
>
> AI Model.
> AI model used for aspect-based sentiment extraction. Each text is processed individually
> to identify entities and their associated sentiments.
>
> Values must be one of the following:
>
> `openai/gpt-4.1` `openai/gpt-6-luna` `openai/gpt-5` `openai/gpt-6.1-sol` `openai/gpt-5.1` `openai/gpt-5.2`
>
> **instructions** `string`
>
> Additional Instructions.
> Additional instructions to guide the sentiment extraction process. Use this to provide
> domain-specific guidance or to focus on particular types of entities.
>
> **aspect\_categories** `array[string]`
>
> Aspect Categories.
> Optional list of aspect categories to focus on during extraction. When provided, the model
> will classify each extracted entity into one of these categories. For example:
> \["food", "service", "pricing", "cleanliness", "wait times"].
>
> > **Array items**
> >
> > **Item** `string`
> >
> > Each item in array.
>
> **deduplicate** `[boolean, array[string]]` (default: \['entities', 'reasons'])
>
> Deduplicate Results.
> Whether to deduplicate extracted entities and/or reasons. Can be false (no deduplication),
> true (deduplicate reasons only), or a list specifying which fields to deduplicate
> (e.g., \["entities", "reasons"]).
>
> > **Array items**
> >
> > **Item** `string`
> >
> > Each item in array.
> >
> > Values must be one of the following:
> >
> > * `entities`
> > * `reasons`
>
> **dedupe\_model** `string` (default: openai/gpt-4.1)
>
> Deduplication Model.
> AI model used for deduplication when deduplicate is enabled.
>
> Values must be one of the following:
>
> `openai/gpt-4.1` `openai/gpt-6-luna` `openai/gpt-5` `openai/gpt-6.1-sol` `openai/gpt-5.1` `openai/gpt-5.2`
>
> **dedupe\_batch\_size** `integer` (default: 2000)
>
> Deduplication Batch Size.
> Maximum number of entities per deduplication LLM call. Increase for larger datasets,
> decrease if hitting context limits.
>
> Values must be in the following range:
>
> ```javascript theme={null}
> 100 ≤ dedupe_batch_size ≤ 10000
> ```
>
> **dedupe\_instructions** `string`
>
> Deduplication Instructions.
> Additional instructions to guide the deduplication clustering process. Use this to
> specify domain-specific clustering rules, e.g., "Keep ride-related complaints separate
> from food-related complaints" or "Treat pricing complaints for different items as distinct".
>
> **consolidate** `boolean` (default: true)
>
> Consolidate Clusters.
> Whether to run an extra merge pass to consolidate similar clusters. This helps reduce
> near-duplicate clusters even within a single batch.
>
> **dedupe\_params** `object` (default: \{})
>
> Deduplication Model Parameters.
> Additional parameters for the deduplication model, such as reasoning\_effort for
> reasoning models. For example: `{"reasoning_effort": "medium"}` can help with complex
> deduplication tasks.
>
> **params** `object`
>
> API Parameters.
> Additional parameters for the extraction call, such as `{"reasoning_effort": "high"}`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.