localm / src /worker /load-model-core.js
mihailik's picture
Lighter model.
1bb1792
raw
history blame contribute delete
728 Bytes
// @ts-check
import { pipeline } from '@huggingface/transformers';
/**
* @param {{
* modelName: string,
* device: import('@huggingface/transformers').DeviceType,
* onProgress?: import('@huggingface/transformers').ProgressCallback
* }} _
*/
export async function loadModelCore({
modelName,
device,
onProgress
}) {
// Create a text-generation pipeline. Depending on the model this may
// perform downloads of model weights; the library should report progress
// via its own callbacks if available.
const pipe = await pipeline(
'text-generation',
modelName,
{
device,
progress_callback: (progress) => {
if (onProgress) onProgress(progress);
}
});
return pipe;
}