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

Support for the phi-1.5 model in transformers.js #492

Closed
2 tasks done
bil-ash opened this issue Jan 2, 2024 · 3 comments · Fixed by #493
Closed
2 tasks done

Support for the phi-1.5 model in transformers.js #492

bil-ash opened this issue Jan 2, 2024 · 3 comments · Fixed by #493
Labels
new model Request a new model

Comments

@bil-ash
Copy link

bil-ash commented Jan 2, 2024

Model description

Please add support for the microsoft/phi-1.5 model to transformers.js. The model is really powerful when considering the size and should also fit in the 2gb model size limit. It is alo supported by optimum.

Prerequisites

  • The model is supported in Transformers (i.e., listed here)
  • The model can be exported to ONNX with Optimum (i.e., listed here)

Additional information

No response

Your contribution

none

@bil-ash bil-ash added the new model Request a new model label Jan 2, 2024
@thekevinscott
Copy link

thekevinscott commented Jan 11, 2024

I'm trying to run this model via this URL.

In Chrome Version 120.0.6099.216 (Official Build) (arm64) I see the following for the sample code:

An error occurred during model execution: "RangeError: offset is out of bounds".

Models are being loaded off of Hugging Face. I'm on an M3 Max.

Screenshot 2024-01-11 at 10 05 13 AM

Code:

import { pipeline, env } from "@xenova/transformers";
env.allowLocalModels = false;

// Create a text-generation pipeline
const generator = await pipeline('text-generation', 'Xenova/phi-1_5_dev');

// Construct prompt
const prompt = `\`\`\`py
import math
def print_prime(n):
    """
    Print all primes between 1 and n
    """`;

// Generate text
const result = await generator(prompt, {
  max_new_tokens: 100,
});
console.log(result[0].generated_text);

Other models, e.g. Xenova/gpt2 work fine and produce output.

Also tested in Firefox, same error.

@xenova
Copy link
Collaborator

xenova commented Jan 11, 2024

Hi there 👋 This is indeed a known issue (see #499), and will hopefully be fixed when we upgrade the onnxruntime-web version. It occurs for models >1B params. Running in node.js works correctly though.

@thekevinscott
Copy link

Ah gotcha, thanks @xenova ! I'll follow along there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new model Request a new model
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants