Skip to content

Instantly share code, notes, and snippets.

@kivlor
Created September 29, 2023 09:31
Show Gist options
  • Save kivlor/1598484f621c6dadd5fcf0126fc46dd6 to your computer and use it in GitHub Desktop.
Save kivlor/1598484f621c6dadd5fcf0126fc46dd6 to your computer and use it in GitHub Desktop.
deno + transformers.js
import {
env,
pipeline,
} from "https://cdn.jsdelivr.net/npm/@xenova/transformers";
env.backends.onnx.wasm.numThreads = 1;
const classifier = await pipeline(
"text-classification",
"Xenova/distilbert-base-uncased-finetuned-sst-2-english",
);
const input = [
"I love Transformers.js",
"I hate Transformers.js",
"I don't mind Transformers.js",
];
const result = await classifier(input);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment