transformers.js
transformers.js copied to clipboard
Cross-Origin Storage API Extension
This should not be merged yet.
Instead its an experimantal implementation of the Cross-Origin Storage API that the Google Chrome Team is working on: https://github.com/explainers-by-googlers/cross-origin-storage
To test is you need to install the Cross-Origin Storage API extension in your browser: https://github.com/web-ai-community/cross-origin-storage-extension?tab=readme-ov-file
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.
I've released a little library that I think can be super neatly integrated in Transformers.js for also storing the Wasm files dynamically in Cross-Origin Storage.
import { NPMSHA256HashFetcher } from './index.js';
const fetcher = new NPMSHA256HashFetcher();
const resources = [
"@huggingface/transformers/dist/ort-wasm-simd-threaded.jsep.wasm",
/* All other resources from npm… */
];
const results = await fetcher.getHexHashForResource(resources);
And there you have the evergreen SHA-256 hashes, so whenever the Wasm on npm changes, the hashes will automatically be adjusted, so you can store the files in Cross-Origin Storage conveniently.
It's obviously a standalone library, but there's a GUI if you want to play with it: