Function Types

Enrich Functions

Add context from knowledge bases using semantic search

Enrich functions perform semantic search against collections to add contextual information to your data. They're useful for looking up reference data, adding context from knowledge bases, or matching against existing records.

When to Use

Use an Enrich function when you need to:

  • Look up vendor information from a master list
  • Match extracted data against existing records
  • Add context from a knowledge base or documentation
  • Find similar items in a collection
  • Validate data against reference sources

Prerequisites

Before creating an Enrich function, you need:

  1. A Collection with your reference data
  2. Items added to the collection with searchable content

See the Collections API for creating and populating collections.

Configuration Fields

Required Fields

FieldTypeDescription
functionNamestringUnique identifier for the function
typestringMust be "enrich"
configobjectEnrichment configuration

Optional Fields

FieldTypeDefaultDescription
displayNamestring-Human-readable display name
tagsstring[]-Tags for organization

Enrich Config

The config object contains:

FieldTypeDescription
collectionNamestringName of the collection to search
Additional config options vary based on enrichment type

Example

Vendor Lookup

Enrich invoice data with vendor information from a master vendor list:

{
  "functionName": "vendor-enricher",
  "type": "enrich",
  "displayName": "Vendor Information Lookup",
  "config": {
    "collectionName": "vendor-master-list"
  },
  "tags": ["vendor", "lookup"]
}

Product Matching

Match extracted product names against a product catalog:

{
  "functionName": "product-matcher",
  "type": "enrich",
  "displayName": "Product Catalog Matcher",
  "config": {
    "collectionName": "product-catalog"
  },
  "tags": ["products", "matching"]
}

Workflow Pattern

Enrich functions typically follow Transform functions:

Document


┌───────────┐
│ Transform │  Extract raw data
└───────────┘


┌───────────┐
│  Enrich   │  Add context from collection
└───────────┘


Enriched Output

Example Flow

  1. Transform extracts vendor name "Acme Corp" from invoice
  2. Enrich searches vendor collection for "Acme Corp"
  3. Output includes matched vendor ID, address, payment terms

Setting Up Collections

Before using Enrich functions, create and populate a collection:

# Create collection
curl -X POST https://api.bem.ai/v2/collections \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "name": "vendor-master-list",
    "description": "Master list of approved vendors"
  }'

# Add items
curl -X POST https://api.bem.ai/v2/collections/vendor-master-list/items \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "items": [
      {
        "content": "Acme Corporation - Primary supplier for office supplies",
        "metadata": {
          "vendorId": "V001",
          "paymentTerms": "Net 30"
        }
      }
    ]
  }'

On this page