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

# Run typed inference

> Turn reviews, financial reports, product photos, and support conversations into typed SQL results.

`infer(input, prompt, output_schema)` runs over a column and returns one [AI envelope](https://docs.chowder.ai/reference/column-functions/infer.md#ai-envelope) per row. The envelope's `output` field has the SQL type you request. These examples use the [demo data](https://docs.chowder.ai/guides/data-sources.md) and the customer-conversation dataset.

## Find product failures without a keyword list

Ask whether a review describes a product breaking. A token budget filters the reviews before the Boolean model runs:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    title,
    content,
    infer(
        content,
        'Does the reviewer describe a product breaking or failing?',
        BOOL -- Return a typed Boolean AI response
    ).output AS product_failed
FROM read_parquet('hf://buckets/chowderai/chowder-demo/parquet/data/amazon-reviews/*.parquet')
WHERE tokens(content) < 120 -- Keep model inputs short
AND product_failed
LIMIT 3;
```

This can match different descriptions of failure rather than requiring the exact word “broken.” The AI response is a prediction; inspect `content` alongside it.

## Find explanations in a financial report

Ask for business causes rather than matching a financial keyword. Keep the page content and full AI envelope so you can inspect the evidence and model diagnostics:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    page_number,
    content, -- Parsed PDF page in Markdown
    infer(
        content,
        'Does this page explain the business reasons behind declining revenue?',
        BOOL -- Return a typed Boolean AI response
    ) AS inference
FROM read_documents('hf://buckets/chowderai/chowder-demo/pdf/data/att-management-discussion-and-analysis-2020.pdf')
WHERE inference.output -- Keep pages where the AI response is true
LIMIT 3;
```

The recorded run returned pages 4, 5, and 6. Page 4 connects reduced travel to lower international roaming revenue and theater closures to lower content revenue. Page 5 distinguishes segment-level causes, including foreign exchange effects in Latin America. Page 6 describes the shift away from linear video and legacy services. Inspect the supporting text: the Boolean AI response remains a prediction.

## Extract financial figures as typed columns

Page 3 of AT\&T's 2020 management discussion contains the consolidated revenue table:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    page_number,
    infer(
        content,
        'Extract the company and its total operating revenue for 2020 in millions of US dollars.',
        STRUCT<
            company TEXT,
            revenue_2020_millions BIGINT
        >
    ).output AS financials -- Typed fields of the AI response
FROM read_documents('hf://buckets/chowderai/chowder-demo/pdf/data/att-management-discussion-and-analysis-2020.pdf')
WHERE page_number = 3;
```

The recorded AI response identifies AT\&T Inc. and `171760` million US dollars. The unit is explicit in both the prompt and field name; a typed integer is still a model prediction, not a verified financial calculation.

## Analyze a customer conversation

The source contains synthetic conversations; it is separate from the general demo bucket and carries CC BY-NC 4.0.

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    convo_id,
    infer(
        convo_transcript,
        'Analyze this customer support conversation.',
        STRUCT<
            resolution ENUM('resolved', 'unresolved', 'escalated'), -- Constrain the allowed labels
            sentiment ENUM('positive', 'neutral', 'negative'),
            summary TEXT,
            action_items ARRAY<TEXT>
        >
    ).output AS analysis
FROM read_parquet('hf://datasets/chowderai/cust-convo/data/*.parquet')
WHERE tokens(convo_transcript) < 2048 -- Bound the conversation input length
LIMIT 3;
```

Each output contains a resolution, sentiment, summary, and list of action items. The two source columns are `convo_id` and `convo_transcript`; the classifications are computed by the query.

## Classify into fixed labels

Use `ENUM` when each review gets exactly one label from a fixed set. The model can only return a listed label, and `confidence` scores the label it chose:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
WITH classified AS (
    SELECT
        title,
        infer(
            content,
            'Classify the sentiment of this review.',
            ENUM('positive', 'negative', 'mixed') -- Return exactly one label
        ) AS inference
    FROM read_parquet('hf://buckets/chowderai/chowder-demo/parquet/data/amazon-reviews/*.parquet')
    WHERE tokens(content) < 120 -- Keep model inputs short
    LIMIT 3
)
SELECT
    title,
    inference.output AS sentiment,
    inference.confidence AS sentiment_confidence
FROM classified;
```

| title | sentiment | sentiment\_confidence |
| - | - | - |
| I dream of sushi | positive | 0.9836424589157104 |
| Sistas "N the City | negative | 0.6731616258621216 |
| Great product | positive | 0.9980700612068176 |

The second review praises the humor but complains that the episodes are too short. The model labels it `negative` with a lower score, which makes it a good row to send for review.

## Tag with multiple labels

Use `ARRAY<VARCHAR>` when a review can have several labels. Each tag gets its own [confidence score](https://docs.chowder.ai/concepts/confidence.md), in the same order as the tags:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
WITH tagged AS (
    SELECT
        title,
        infer(
            content,
            'List short tags for the topics this review mentions.',
            ARRAY<VARCHAR> -- Return a list of tags
        ) AS inference
    FROM read_parquet('hf://buckets/chowderai/chowder-demo/parquet/data/amazon-reviews/*.parquet')
    WHERE tokens(content) < 120 -- Keep model inputs short
    LIMIT 3
)
SELECT
    title,
    inference.output AS tags,
    inference.confidence AS tag_confidence
FROM tagged;
```

| title | tags | tag\_confidence |
| - | - | - |
| I dream of sushi | \[&#xA;    "sushi",&#xA;    "expensive",&#xA;    "inspiration",&#xA;    "care",&#xA;    "beautifully shot",&#xA;    "musically scored"&#xA;] | \[&#xA;    0.712153434753418,&#xA;    0.7237390279769897,&#xA;    0.6353306770324707,&#xA;    0.5672604441642761,&#xA;    0.5820305943489075,&#xA;    0.7903035283088684&#xA;] |
| Sistas "N the City | \[&#xA;    "funny",&#xA;    "not for young children",&#xA;    "too short"&#xA;] | \[&#xA;    0.7743762135505676,&#xA;    0.7166072130203247,&#xA;    0.7613152861595154&#xA;] |
| Great product | \[&#xA;    "audio pharmacy",&#xA;    "driving",&#xA;    "antimicrobial chapters",&#xA;    "information presented"&#xA;] | \[&#xA;    0.7449674606323242,&#xA;    0.7683140635490417,&#xA;    0.813789963722229,&#xA;    0.8678295612335205&#xA;] |

The model chooses the tags. To limit tags to a fixed set of labels, use `ARRAY<ENUM(...)>`.

## Read visible product attributes

A product photo becomes an input to the same typed interface:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    source,
    infer(
        image,
        'Describe this cup: its main color, material, and whether it has a handle.',
        STRUCT<
            color TEXT,
            material TEXT,
            has_handle BOOL
        >
    ).output AS product -- Typed fields of the AI response
FROM read_images('hf://buckets/chowderai/chowder-demo/image/data/amazon-products/drinking-cup/*.jpg')
LIMIT 3;
```

The `drinking-cup` directory bounds this example to one product category. `LIMIT 3` bounds the returned examples without requiring an analysis of all 10,000 product images.

## Keep the envelope when inspecting errors

Project the full call before selecting its fields:

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    title,
    infer(
        content,
        'Summarize the review in one sentence.',
        TEXT
    ) AS analysis,
    analysis.output AS summary, -- Typed AI response inside the AI envelope
    analysis.error AS error, -- Inspect per-row model errors
    analysis.model_id AS model_id
FROM read_parquet('hf://buckets/chowderai/chowder-demo/parquet/data/amazon-reviews/*.parquet')
LIMIT 3;
```

Failed or null inputs retain their rows. Check `error` when `output` is null. `error` can also explain why confidence couldn't be computed for a valid `output`. For the text Boolean classifier, a null `output` can also mean that the model selected `unknown`; this does not itself indicate an inference error. Its `confidence` is the probability of the selected label, and `probabilities` contains the probabilities for `true`, `false`, and `unknown`. See [Boolean classification](https://docs.chowder.ai/reference/column-functions/infer.md#boolean-classification).

Token counts and timings are null when the model doesn't report them. A confidence score isn't a guarantee of correctness.

## How Chowder chooses a model

Chowder selects a task-specific model from the input and the output type you request. Text input with `BOOL` output uses Bitsy, a specialized Boolean classifier. Other text outputs and image inputs use a vision-capable generative model. See [Models](https://docs.chowder.ai/concepts/models.md) for the current defaults. The first model-backed query may download and load managed artifacts.

See [Caching](https://docs.chowder.ai/concepts/caching.md) for result reuse, cache validity, and cache controls.

## Run the same analysis on managed compute

Use the [Cloud quickstart](https://docs.chowder.ai/cloud/quickstart.md) to configure `CHOWDER_REMOTE=1` and call `chowder.sql()` directly, or opt in with `Engine(remote=True)`. Start with bounded inputs, then inspect usage before increasing the workload.


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