Coder Social home page Coder Social logo

Comments (8)

DawChihLiou avatar DawChihLiou commented on May 22, 2024 1

@wonderwhy-er thanks so much for reporting. Could you attach your embeddings or show me how did you generate them so I can reproduce the error? Thanks!

from voy.

wonderwhy-er avatar wonderwhy-er commented on May 22, 2024 1

Ouh its my bad, it seems to work.
I was using TensorFlow JS universal sentence encoder
https://github.com/tensorflow/tfjs-models/blob/master/universal-sentence-encoder/README.md

And for whatever reasons in some cases it returns [number[]] instead of number[] for encoding
I did Array.flat() on it and then it all worked!

from voy.

DawChihLiou avatar DawChihLiou commented on May 22, 2024 1

Amazing! Have fun:)

from voy.

DawChihLiou avatar DawChihLiou commented on May 22, 2024

Hey @GarciaLnk, thanks for your suggestion! I'll explore the options. At the meantime, you can directly import the .wasm file to start using it without a bundler. For example:

// cjs
const voy = require("voy-search/voy_search_bg.wasm");

// or esm
const voy = await import("voy-search/voy_search_bg.wasm");

from voy.

GarciaLnk avatar GarciaLnk commented on May 22, 2024

AFAIK to import a WASM module as a native ES module you need a bundler that has proper support for it, which is the root of the issue (see: https://rustwasm.github.io/docs/wasm-bindgen/reference/deployment.html#bundlers).

from voy.

wonderwhy-er avatar wonderwhy-er commented on May 22, 2024

Wanted to test it quickly by loading from CDN trough unpkg
https://www.unpkg.com/browse/[email protected]/

So I could add script tag to a html page like this:
<script src="https://www.unpkg.com/[email protected]/voy_search.js" type="module"></script>

That results in an error:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/wasm". Strict MIME type checking is enforced for module scripts per HTML spec.

As far as I understand direct importing of wasm modules is not supported yet

I did manage to make it work with this code

import * as voy from 'https://www.unpkg.com/[email protected]/voy_search_bg.js';
WebAssembly.instantiateStreaming(fetch("https://www.unpkg.com/[email protected]/voy_search_bg.wasm"), {
    "./voy_search_bg.js": voy,
    },
}).then((module) => {
    voy.__wbg_set_wasm(module.instance.exports);
});

Sadly later trying to load my embeddings got an err:
image

from voy.

MentalGear avatar MentalGear commented on May 22, 2024

Hey @wonderwhy-er I'm also looking to get voy work in the browser, potentially with up to 1GB or records. Would you be able to share your wasm solution?

from voy.

wonderwhy-er avatar wonderwhy-er commented on May 22, 2024

@MentalGear sorry missed your question, I since then switched to using other things
My code was kinda like this https://jsfiddle.net/wonderwhy_er/k4bwLf2e/31/
But it does not work in jsfiddle and I do not have original code I had working anymore

from voy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.