Text Generation
Transformers.js
ONNX
llama
webgpu
q4f16
gptq
tool-calling
experimental
conversational
Instructions to use webbrain-one/webbrain-compass-tiny-v2.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use webbrain-one/webbrain-compass-tiny-v2.1 with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'webbrain-one/webbrain-compass-tiny-v2.1');
Download runtime/vendor/onnxruntime-common/tensor-utils-impl.js from webbrain-one/webbrain-compass-tiny-v2.1: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/webbrain-one/webbrain-compass-tiny-v2.1/resolve/main/runtime/vendor/onnxruntime-common/tensor-utils-impl.js
- Command line
-
hf download hf://webbrain-one/webbrain-compass-tiny-v2.1/runtime/vendor/onnxruntime-common/tensor-utils-impl.js
-
curl -L -o tensor-utils-impl.js https://huggingface.co/webbrain-one/webbrain-compass-tiny-v2.1/resolve/main/runtime/vendor/onnxruntime-common/tensor-utils-impl.js
1.92 kB
| // Copyright (c) Microsoft Corporation. All rights reserved. | |
| // Licensed under the MIT License. | |
| import { Tensor } from './tensor-impl.js'; | |
| /** | |
| * calculate size from dims. | |
| * | |
| * @param dims the dims array. May be an illegal input. | |
| */ | |
| export const calculateSize = (dims) => { | |
| let size = 1; | |
| for (let i = 0; i < dims.length; i++) { | |
| const dim = dims[i]; | |
| if (typeof dim !== 'number' || !Number.isSafeInteger(dim)) { | |
| throw new TypeError(`dims[${i}] must be an integer, got: ${dim}`); | |
| } | |
| if (dim < 0) { | |
| throw new RangeError(`dims[${i}] must be a non-negative integer, got: ${dim}`); | |
| } | |
| size *= dim; | |
| } | |
| return size; | |
| }; | |
| /** | |
| * implementation of Tensor.reshape() | |
| */ | |
| export const tensorReshape = (tensor, dims) => { | |
| switch (tensor.location) { | |
| case 'cpu': | |
| return new Tensor(tensor.type, tensor.data, dims); | |
| case 'cpu-pinned': | |
| return new Tensor({ | |
| location: 'cpu-pinned', | |
| data: tensor.data, | |
| type: tensor.type, | |
| dims, | |
| }); | |
| case 'texture': | |
| return new Tensor({ | |
| location: 'texture', | |
| texture: tensor.texture, | |
| type: tensor.type, | |
| dims, | |
| }); | |
| case 'gpu-buffer': | |
| return new Tensor({ | |
| location: 'gpu-buffer', | |
| gpuBuffer: tensor.gpuBuffer, | |
| type: tensor.type, | |
| dims, | |
| }); | |
| case 'ml-tensor': | |
| return new Tensor({ | |
| location: 'ml-tensor', | |
| mlTensor: tensor.mlTensor, | |
| type: tensor.type, | |
| dims, | |
| }); | |
| default: | |
| throw new Error(`tensorReshape: tensor location ${tensor.location} is not supported`); | |
| } | |
| }; | |
| //# sourceMappingURL=tensor-utils-impl.js.map |