huggingface / transformers.js

State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
https://huggingface.co/docs/transformers.js
Apache License 2.0
11.84k stars 745 forks source link

Cannot download the model from huggingface #432

Open wujohns opened 11 months ago

wujohns commented 11 months ago

Because of the network reason, when using transfomer.js we cannot download the model successful How to set the network proxy for the model download

xenova commented 11 months ago

Hi there 👋 You can update the remote host and path template used:

import { env } from '@xenova/transformers';
env.remoteHost = 'https://example.com/'; // defaults to 'https://huggingface.co/'
env.remotePathTemplate = '{model}/'; // defaults to '{model}/resolve/{revision}/'

// continue normally

For remotePathTemplate, {model} will be replaced by the model_id (e.g., Xenova/bert-base-cased) and {revision} will be replaced with the revision used (defaults to 'main').

Using the above example, when requesting Xenova/bert-base-cased, the request will be made to https://example.com/Xenova/bert-base-cased/