Views
No views yet
npm i @huggingface/transformers1import { pipeline } from '@huggingface/transformers';
2
3// Create feature extraction pipeline
4const extractor = await pipeline('feature-extraction', 'Xenova/nucleotide-transformer-500m-human-ref', {
5 dtype: "fp32" // Options: "fp32", "fp16", "q8", "q4"
6});
7
8// Perform feature extraction
9const sequences = ["ATTCCGATTCCGATTCCG", "ATTTCTCTCTCTCTCTGAGATCGATCGATCGAT"];
10const output = await extractor(sequences, { pooling: 'mean' });
11console.log(output);
12// Tensor {
13// dims: [ 2, 1280 ],
14// type: 'float32',
15// data: Float32Array(2560) [ -0.4544594883918762, 0.33294573426246643, ... ],
16// size: 2560
17// }output Tensor to a nested JavaScript array using .tolist():1console.log(output.tolist());
2// [
3// [ -0.4544594883918762, 0.33294573426246643, -0.06337763369083405, ... ],
4// [ 0.05060688406229019, -0.21165050566196442, -0.32883304357528687, ... ]
5// ]onnx).