-
Notifications
You must be signed in to change notification settings - Fork 357
/
Copy pathzeroShotClassification.ts
25 lines (23 loc) · 1.05 KB
/
zeroShotClassification.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import type { ZeroShotClassificationInput, ZeroShotClassificationOutput } from "@huggingface/tasks";
import { getProviderHelper } from "../../lib/getProviderHelper";
import type { BaseArgs, Options } from "../../types";
import { innerRequest } from "../../utils/request";
export type ZeroShotClassificationArgs = BaseArgs & ZeroShotClassificationInput;
/**
* 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: ZeroShotClassificationArgs,
options?: Options
): Promise<ZeroShotClassificationOutput> {
const providerHelper = getProviderHelper(args.provider ?? "hf-inference", "zero-shot-classification");
const { data: res } = await innerRequest<ZeroShotClassificationOutput[number] | ZeroShotClassificationOutput>(
args,
providerHelper,
{
...options,
task: "zero-shot-classification",
}
);
return providerHelper.getResponse(res);
}