UNPKG

@huggingface/inference

Version:

Typescript client for the Hugging Face Inference Providers and Inference Endpoints

16 lines (15 loc) 845 B
import { resolveProvider } from "../../lib/getInferenceProviderMapping.js"; import { getProviderHelper } from "../../lib/getProviderHelper.js"; import { innerRequest } from "../../utils/request.js"; /** * This task is super useful to try out classification with zero code, you simply pass a sentence/paragraph and the possible labels for that sentence, and you get a result. Recommended model: facebook/bart-large-mnli. */ export async function zeroShotClassification(args, options) { const provider = await resolveProvider(args.provider, args.model, args.endpointUrl); const providerHelper = getProviderHelper(provider, "zero-shot-classification"); const { data: res } = await innerRequest(args, providerHelper, { ...options, task: "zero-shot-classification", }); return providerHelper.getResponse(res); }