Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] πŸš€πŸš€πŸš€ Transformers.js V3 πŸš€πŸš€πŸš€ #545

Draft
wants to merge 117 commits into
base: main
Choose a base branch
from

Conversation

xenova
Copy link
Owner

@xenova xenova commented Jan 27, 2024

In preparation for Transformers.js v3, I'm compiling a list of issues/features which will be fixed/included in the release.

How to use WebGPU

First, install the development branch

npm install xenova/transformers.js#v3

Then specify the device parameter when loading the model. Here's example code to get started. Please note that this is still a WORK IN PROGRESS, so the following usage may change before release.

import { pipeline } from '@xenova/transformers';

// Create feature extraction pipeline
const extractor = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2', {
    device: 'webgpu',
    dtype: 'fp32', // or 'fp16'
});

// Generate embeddings
const sentences = ['That is a happy person', 'That is a very happy person'];
const output = await extractor(sentences, { pooling: 'mean', normalize: true });
console.log(output.tolist());

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@xenova xenova marked this pull request as draft January 27, 2024 18:02
@Huguet57
Copy link

Hey! This is great. Is this already in alpha?

ORT modifies the object in-place, which means you can't pass different session objects to multiple sessions
@young-developer
Copy link

young-developer commented Apr 11, 2024

@xenova There is new version 1.17.3 of onnxruntime-web. I tested with wav2vec and there is new error so looks like a progress πŸ˜„

@xenova
Copy link
Owner Author

xenova commented Apr 21, 2024

Segment Anything Encoder now works with WebGPU: up to 8x faster! (online demo)

sam-webgpu.mp4

* Support exporting variants

* Add support for box inputs

* Add box processor unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment