Skip to main content
Docs/API Reference
Reference

API Reference

Client-side semantic matching engine API for browser-based reconciliation.

Overview

STET uses a fully client-side semantic matching engine. All processing happens in your browser using WebGPU or WebAssembly—no data is sent to any server.

Note

The engine uses Hugging Face Transformers.js with the all-MiniLM-L6-v2 model for semantic similarity matching.

Client Engine API

Initialize

Create and initialize the semantic matching engine:

initialize.ts
import { createClientSemanticEngine } from '@/lib/client-semantic';

const engine = createClientSemanticEngine();

// Initialize with model download
await engine.initialize((progress) => {
    console.log(`Loading: ${progress.percent}%`);
});

console.log('Backend:', engine.getBackend()); // 'webgpu' or 'wasm'

Match

Run semantic matching between source and target texts:

match.ts
const result = await engine.match({
    sourceTexts: ['AWS Invoice January', 'Office Supplies Q1'],
    targetTexts: ['Amazon Web Services Jan 2024', 'Staples Office Equipment'],
    threshold: 0.7  // minimum similarity score
}, (progress) => {
    console.log(`Processed: ${progress.completed}/${progress.total}`);
});

// Result contains matches above threshold
result.matches.forEach(m => {
    console.log(`${m.source_text} ↔ ${m.target_text} (${m.similarity})`);
});

Types

MatchingInput

types.ts
interface MatchingInput {
    sourceTexts: string[];
    targetTexts: string[];
    threshold?: number;  // default: 0.7
}

MatchingOutput

types.ts
interface MatchingOutput {
    matches: Array<{
        source_index: number;
        target_index: number;
        source_text: string;
        target_text: string;
        similarity: number;
    }>;
    processingTimeMs: number;
    auditRecord: AuditRecord;
}

Progress

types.ts
interface Progress {
    completed: number;
    total: number;
    percent: number;
}