跳到正文
Vercel Blog· Bruce Liu·· 2 天前精选AI 评分75

Vercel AI Gateway 支持提取模型并首发接入 ScaleDown Extract-1

AI Gateway now supports extraction models

AI 导读

Vercel AI Gateway 宣布支持提取模型,首发上线 ScaleDown Extract-1,可从文本、图像和 PDF 中抽取指定字段并返回结构化数据。

推荐理由

原文提供了代码调用示例与置信度打分机制,开发者可以直接评估其在发票与合同结构化解析中的接入成本。

正文 · 原文

Extraction models are now on AI Gateway. They find specific details in the content you provide, such as an invoice number or contact names, and return them as separate fields your code can use.

ScaleDown Extract-1 is the first available extraction model. It extracts text values or lists of text values from text, images, and PDFs. You can use it to process invoices, contracts, and other records.

Extraction is currently available through the AI SDK only. With [email protected] or later, use experimental_extract and the model ID scaledown/extract-1:

import { experimental_extract as extract } from 'ai';

const result = await extract({

model: 'scaledown/extract-1',

state: 'Invoice INV-2041 from Acme Corp. Contacts: Ana, Bo.',

fields: {

invoiceNumber: { type: 'text', instructions: 'The invoice number' },

contacts: { type: 'list', items: 'text', instructions: 'Contact names' },

},

});

console.log(result.answers.invoiceNumber.value); // 'INV-2041'

console.log(result.answers.contacts.value); // ['Ana', 'Bo']

Extract an invoice number and contact names from text.

Each key in fields has an entry in result.answers. If a field is not found, its value is null. Extract-1 returns confidence scores from 0 to 1 for matches, including individual list items, so you can flag uncertain results for review. For text input, it can also return character offsets showing where a match appears.

To extract from a PDF or image, pass it as a file part in state:

import { readFile } from 'node:fs/promises';

import { experimental_extract as extract } from 'ai';

const result = await extract({

model: 'scaledown/extract-1',

state: [

{

type: 'file',

data: await readFile('./invoice.pdf'),

mediaType: 'application/pdf',

},

],

fields: {

vendor: { type: 'text', instructions: 'The company that issued the invoice' },

total: { type: 'text', instructions: 'The total amount due' },

lineItems: { type: 'list', items: 'text', instructions: 'The line items' },

},

});

console.log(result.answers);

Extract the vendor, total, and line items from a PDF.

Extraction requests appear in AI Gateway logs and spend tracking. See the extraction quickstart for setup and authentication.

来源:Vercel Blog · vercel.com

EVAOO 主站实战落地 · AI Agent 与研发提效

看完情报?回到 EVAOO 主站直接上手工具与完整 SOP

返回 EVAOO 主站