-
-
Notifications
You must be signed in to change notification settings - Fork 95
feat(ai): inference API #501
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
feat(ai): inference API #501
Conversation
86bff1c to
d0e9461
Compare
|
🔕 This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
bot reply |
- Exposing an user friendly interface to consume the `onnx` backend
- using `InferenceAPI` to perform `text-to-audio`. - encoding `wave` audio tensors from the rust land
Documenting the "magic numbers" of the `text-to-audio` exmaple, [original paper](https://arxiv.org/pdf/2306.07691)
- Adding `fromStorage` method to InferenceAPI, its allows model loadingfrom Supabase Storage with public/private bucket support.
d0e9461 to
f21cd9d
Compare
f21cd9d to
bbcda7a
Compare
|
🔕 This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
bot reply |
|
🔕 This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
What kind of change does this PR introduce?
feature
What is the current behavior?
Since PR #436, is possible to use
onnxinference by calling theglobalThis[Symbol.for('onnxruntime')]What is the new behavior?
Coming from Issue #479, the Inference API is an user friendly interface that allows developers easily run their own models using the power of the low level
onnx rust backend.It's based on two core componenents
RawSessionandRawTensorRawSession: A low levelSupabase.ai.Sessionthat can execute any.onnxmodel. It's recommended for use cases where need more control of the pre/pos-processing steps like text-to-audio example, as well when need to executelinear regression,tabular classificationand self-made models.RawTensor: A low level data representation of the model input/output. Inference API's Tensors are fully compatible with Transformers.js Tensors. It means that developers can still be using the high-lavel abstractions thattransformers.jsprovides, like:.sum(),.normalize(),.min().Examples:
Simple utilization:
Loading a
RawSession:Executing a
RawSessionwithRawTensor:Generating embeddings from scratch:
This example demonstrates how Inference API can be used to complex scenarios while taking advantage of Transformers.js high-level functions
Self-made models
This example ilustrate how users can train their own model and execute it direclty from
edge-runtimeThe model was trained to expect the following object payload
[ { "Model_Year": 2021, "Engine_Size": 2.9, "Cylinders": 6, "Fuel_Consumption_in_City": 13.9, "Fuel_Consumption_in_City_Hwy": 10.3, "Fuel_Consumption_comb": 12.3, "Smog_Level": 3, }, { "Model_Year": 2023, "Engine_Size": 2.4, "Cylinders": 4, "Fuel_Consumption_in_City": 9.9, "Fuel_Consumption_in_City_Hwy": 7.0, "Fuel_Consumption_comb": 8.6, "Smog_Level": 3, } ]Then the model inference can done inside a common
Edge FunctionTODO:
tryEncodeAudio(), check out the text-to-audio exampleTensor Image support, forimage generation