[go: nahoru, domu]

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

[Question] React.js serve sentence bert in browser keep reporting models not found. #328

Open
bianyuanop opened this issue Sep 24, 2023 · 3 comments · May be fixed by #545
Open

[Question] React.js serve sentence bert in browser keep reporting models not found. #328

bianyuanop opened this issue Sep 24, 2023 · 3 comments · May be fixed by #545
Labels
question Further information is requested

Comments

@bianyuanop
Copy link

my codes:

export const useInitTransformers = () => {
  const init = async () => {
    // @ts-ignore
    env.allowLocalModels = false;
    extractor = await pipeline(
      "feature-extraction",
      "Xenova/all-mpnet-base-v2",
    );
  };
  return { init };
};

I'm building a frontend with React that can serve sentence bert directly in browser, but no idea why even i add the line
env.allowLocalModels = false
before pipeline loading the model. In the production environment, it's still trying to access model locally /models/..., but which will never exists in this usecase.

Is there any way i can bypass this check and directly pull the model from remote?

image

@bianyuanop bianyuanop added the question Further information is requested label Sep 24, 2023
@xenova
Copy link
Owner
xenova commented Sep 26, 2023

env.allowLocalModels = false should handle this. Could you provide more information about your environment? (OS, browser, build tools, etc.)

@bianyuanop
Copy link
Author
bianyuanop commented Sep 28, 2023

Actually we successfully make it work by removing this line, i.e using the default one,
https://github.com/Nexai-app/nexi-v1/blob/main/src/nexai_assets/functions/ml.ts#L52

Still no clue why specify a model doesn't work.

OS: ubuntu 22.04
browswer: chrome 117.0.5938.92
build tools: webpack + rollup

@xenova xenova linked a pull request Jan 27, 2024 that will close this issue
18 tasks
@luweigen
Copy link
luweigen commented Feb 3, 2024

If you didn't initially set env.allowLocalModels = false, the data read from localhost/models/ will be saved to the browser cache, continuously leading to JSON parsing errors, even if you subsequently set env.allowLocalModels = false. You must manually clear the cache.
transformers js cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants