---
title: "Answer questions about extracted data | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/csharp/extraction/decide-document/"
md_url: "https://www.nutrient.io/guides/dotnet/csharp/extraction/decide-document.md"
last_updated: "2026-11-20T00:00:00.000Z"
description: "Get yes/no, multiple-choice, and ordinal answers about JSON data, such as whether an invoice meets an approval policy, using Nutrient .NET SDK."
---

# Answer questions about extracted data

Use `Vision.Decide` to answer yes/no, multiple-choice, and ordered-scale questions about JSON data your application already has. For example, evaluate an extracted invoice against an approval policy or choose its expense category.

The decision model runs locally and returns an answer and calibrated probabilities for each question. It doesn't open or parse a document. Calibration adjusts model scores into probabilities; it doesn't guarantee that an answer is correct. Review consequential decisions before acting on them.

[Download sample](https://www.nutrient.io/downloads/samples/csharp/decide-document.zip)

## Prerequisites

-.NET 10 or later and Nutrient.SDK 1.0.1 or later.

- A license covering the decision model feature, or an applicable trial.

- Internet access on first use to download model resources, a writable resource cache, and enough memory to load the model. Prepare the cache before offline use.

No API key, external model server, or input document is required for this example.

## Prepare the state

Import the SDK namespace and build the shared state as a JSON string. Every question receives the same state. This example supplies an invoice and an approval limit rather than asking the model to infer a policy:

```csharp

using Nutrient;

string stateJson = """
    {
      "invoice": {
        "vendor": "Acme Consulting LLC",
        "total": 1204.50,
        "currency": "USD",
        "description": "Software and subscriptions renewal"
      },
      "approvalLimit": 1500.00
    }
    """;

```

State can be a JSON object, array, or string value. For numeric rules that your application can compute exactly, prefer ordinary C# comparisons. This example illustrates the decision API's input format; it isn't a replacement for arithmetic validation.

## Define the questions

Each question needs a unique `id`, a `type`, and nonempty `instructions`. The API uses these type names:

| Type     | Purpose                               | Options                                                                                                               |
| -------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `noul`   | Yes/no judgment                       | Omit for true/false wording, or supply exactly two options in true/false order.                                       |
| `choice` | Choose a category                     | Two to 26 options, each with a nonempty `key` and an optional description.                                            |
| `score`  | Choose a position on an ordered scale | Two to 26 options ordered from low to high, each with a description. Keys are optional and aren't shown to the model. |

This example asks one question of each type:

```csharp

string questionsJson = """
    [
      {
        "id": "exceeds_limit",
        "type": "noul",
        "instructions": "Does the invoice total exceed the approvalLimit in the state?",
        "options": [
          { "key": "true", "description": "The total exceeds the approval limit." },
          { "key": "false", "description": "The total does not exceed the approval limit." }
        ]
      },
      {
        "id": "category",
        "type": "choice",
        "instructions": "Which expense category best matches the invoice description?",
        "options": [
          { "key": "travel", "description": "Travel and lodging" },
          { "key": "software", "description": "Software and subscriptions" },
          { "key": "office", "description": "Office supplies and equipment" }
        ]
      },
      {
        "id": "description_detail",
        "type": "score",
        "instructions": "How detailed is the invoice description? Use the scale from least to most detailed.",
        "options": [
          { "description": "Vague: does not identify the goods or services." },
          { "description": "General: identifies the kind of goods or services." },
          { "description": "Detailed: identifies specific products, quantities, or service dates." }
        ]
      }
    ]
    """;

```

Questions are evaluated independently. An answer to one question isn't added to the state for the next question.

## Get the decisions

Call the static `Vision.Decide` method and save its JSON response. There is no `Document.Open` or `Vision.Set` call:

```csharp

try
{
    string resultJson = Vision.Decide(stateJson, questionsJson);
    File.WriteAllText("output.json", resultJson);
    Console.WriteLine("Decisions written to output.json");
}
catch (NutrientException e)
{
    Console.Error.WriteLine($"Decision failed: {e.Message}");
    Environment.Exit(1);
}
catch (IOException e)
{
    Console.Error.WriteLine($"Could not write output.json: {e.Message}");
    Environment.Exit(1);
}

```

The SDK reads option scores from the model rather than generating a free-form response. Don't expect an explanation or a text completion in the result.

## Read the output

The response has two top-level objects:

- `answers` contains one entry per question ID, such as `answers.category`.

- `usage` contains `promptTokens` and `outputTokens`. The latter counts one output token per answered question, not generated prose.

Each answer contains:

| Field           | Meaning                                                                                                                                                                                                                                   |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`          | The question type.                                                                                                                                                                                                                        |
| `chosenIndex`   | Zero-based index of the selected option.                                                                                                                                                                                                  |
| `chosenKey`     | The selected option's key when supplied. This sample supplies `"true"`/`"false"` keys for yes/no and category keys for `choice`. Keyless `score` options return `null` in 1.0.1; add keys to those options, or use `chosenIndex` instead. |
| `confidence`    | Calibrated probability of the selected option.                                                                                                                                                                                            |
| `probabilities` | Probabilities for all options in their original order.                                                                                                                                                                                    |

When `noul` options are omitted, 1.0.1 reports the model's option letter, `"A"` or `"B"`, as `chosenKey` rather than `"true"` or `"false"`. Interpret `chosenIndex` zero as true and one as false.

For `description_detail`, interpret `chosenIndex` as a position on your three-option scale. It isn't a continuous numeric score. Use the probability distribution to identify uncertain decisions and route them for review.

## Images and request limits

To include an image in the state, embed an object with `"type": "image"` and a `source` containing an image data URI: `data:<mime>;base64,<bytes>`. The SDK finds these objects throughout the state and passes their image bytes to the model. Invalid embedded images fail validation.

In 1.0.1, the decision model uses a 32K-token context window. Keep the rendered state and question within the limit; oversized requests fail rather than being silently truncated. The limit applies to model tokens, not the JSON string's character count.

## Handle failures

Catch `NutrientException` for SDK failures, including malformed questions, invalid images, requests exceeding the context window, unavailable model resources, or a missing license entitlement. Empty or whitespace-only instructions are rejected before loading the model.

The SDK also fails when decision-model calibration is unavailable instead of returning uncalibrated probabilities. Don't treat these failures as a negative answer to the question.

For selecting a document category from an opened file, refer to the [document classification guide](https://www.nutrient.io/guides/dotnet/csharp/extraction/classify-document.md). For finding document boundaries in a merged PDF, refer to the [document splitting guide](https://www.nutrient.io/guides/dotnet/csharp/extraction/split-document.md).
---

## Related pages

- [Nutrient.NET SDK extraction guides](/guides/dotnet/csharp/extraction.md)
- [Applying OCR to a PDF page](/guides/dotnet/csharp/extraction/apply-ocr-to-pdf-page.md)
- [Applying OCR to a PDF document](/guides/dotnet/csharp/extraction/apply-ocr-to-pdf.md)
- [Classifying documents](/guides/dotnet/csharp/extraction/classify-document.md)
- [Generating image descriptions using Claude](/guides/dotnet/csharp/extraction/describe-image-with-claude.md)
- [Describe images with a custom local AI endpoint in C#](/guides/dotnet/csharp/extraction/describe-image-with-custom-local-ai.md)
- [Generating image descriptions using local AI](/guides/dotnet/csharp/extraction/describe-image-with-local-ai.md)
- [Generating image descriptions using OpenAI](/guides/dotnet/csharp/extraction/describe-image-with-openai.md)
- [Detecting document language](/guides/dotnet/csharp/extraction/detect-document-language.md)
- [Extracting data from images using ICR](/guides/dotnet/csharp/extraction/extract-data-from-image-icr.md)
- [Extracting data from images using OCR](/guides/dotnet/csharp/extraction/extract-data-from-image-ocr.md)
- [Extracting data from images using vision language models](/guides/dotnet/csharp/extraction/extract-data-from-image-vlm.md)
- [Extract image data with a custom local vision endpoint in C#](/guides/dotnet/csharp/extraction/extract-data-from-image-with-custom-local-vlm.md)
- [Extracting data from specific pages](/guides/dotnet/csharp/extraction/extract-data-from-specific-pages.md)
- [Extracting form fields from images](/guides/dotnet/csharp/extraction/extract-form-fields-from-image.md)
- [Extracting structured data from documents](/guides/dotnet/csharp/extraction/extract-structured-data.md)
- [Generate extraction schemas with a custom local vision endpoint in C#](/guides/dotnet/csharp/extraction/generate-extraction-schema-with-custom-local-vlm.md)
- [Generating extraction schemas](/guides/dotnet/csharp/extraction/generate-extraction-schema.md)
- [Extracting JSON data from a PDF document](/guides/dotnet/csharp/extraction/json-data-extraction.md)
- [Label form fields with a custom local vision endpoint in C#](/guides/dotnet/csharp/extraction/label-form-fields-with-custom-local-vlm.md)
- [Labeling form fields with a vision language model](/guides/dotnet/csharp/extraction/label-form-fields-with-vlm.md)
- [Parsing a document into structured content](/guides/dotnet/csharp/extraction/parse-document.md)
- [Extracting text from PDF documents](/guides/dotnet/csharp/extraction/pdf-to-text.md)
- [Reading barcodes with vision extraction](/guides/dotnet/csharp/extraction/read-barcodes-with-vision.md)
- [Extracting text from multilingual images](/guides/dotnet/csharp/extraction/read-text-from-image-multi-language.md)
- [Extracting text from images](/guides/dotnet/csharp/extraction/read-text-from-image.md)
- [Searching document text](/guides/dotnet/csharp/extraction/search-document-text.md)
- [Speeding up first ICR operation by predownloading models](/guides/dotnet/csharp/extraction/speed-up-first-icr-by-downloading-requirements.md)
- [Split documents](/guides/dotnet/csharp/extraction/split-document.md)

