Function Review

Hand off to an LLM

Analyzes function performance and estimate human review requirements. Calculates sample sizes needed to achieve target accuracy with statistical confidence, finds optimal confidence thresholds within a configurable range, and estimates review effort. Supports custom threshold ranges for focused analysis (e.g., analyze only 0.7-0.9 range).

POST
/v2/functions/review
x-api-key<token>

Authenticate using API Key in request header

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "https://api.bem.ai/v2/functions/review" \  -H "Content-Type: application/json" \  -d '{    "functionName": "invoice-transformer",    "marginOfError": 0.05  }'
{
  "functionName": "invoice-transformer",
  "functionVersionNum": 3,
  "estimate": {
    "totalTransformations": 1000,
    "labeledTransformations": 200,
    "unlabeledTransformations": 800,
    "missingEvaluations": 50,
    "confidenceDistribution": {
      "high": 500,
      "medium": 350,
      "low": 150
    },
    "thresholdMatrix": [
      {
        "threshold": 0.8,
        "tp": 85,
        "fp": 12,
        "fn": 15,
        "tn": 88,
        "accuracyAboveThreshold": {
          "95": {
            "ciLower": 0.8456,
            "mid": 0.875,
            "ciUpper": 0.9044,
            "currentSample": 120,
            "sampleNeeded": 30
          }
        }
      }
    ]
  },
  "metrics": {
    "fieldMetrics": [
      {
        "fieldPath": "/invoice/number",
        "metrics": {
          "accuracy": 0.95,
          "precision": 0.98,
          "recall": 0.92,
          "f1Score": 0.95,
          "tp": 92,
          "fp": 2,
          "tn": 0,
          "fn": 8
        }
      },
      {
        "fieldPath": "/invoice/amount",
        "metrics": {
          "accuracy": 0.88,
          "precision": 0.9,
          "recall": 0.85,
          "f1Score": 0.87,
          "tp": 85,
          "fp": 9,
          "tn": 0,
          "fn": 15
        }
      }
    ],
    "precisionRecallAuc": 0.8542,
    "aggregateMetrics": {
      "accuracy": 0.7407,
      "precision": 0.9524,
      "recall": 0.7692,
      "f1Score": 0.8511,
      "tp": 40,
      "fp": 2,
      "tn": 0,
      "fn": 12
    }
  }
}
{
  "message": "string",
  "code": 0,
  "details": {}
}
{
  "message": "string",
  "code": 0,
  "details": {}
}

See also