docs: add Vercel AI SDK integration with browser-ai/transformers-js package#1514
Closed
jakobhoeg wants to merge 129 commits intohuggingface:mainfrom
Closed
docs: add Vercel AI SDK integration with browser-ai/transformers-js package#1514jakobhoeg wants to merge 129 commits intohuggingface:mainfrom
jakobhoeg wants to merge 129 commits intohuggingface:mainfrom
Conversation
* ONNX Runtime improvements (experimental native webgpu; fix iOS) (huggingface#1231) * customize the wasm paths * update implementation * allow using 'webgpu' in nodejs binding * update version of onnxruntime-node * Upgrade onnxruntime-web to same version as onnxruntime-node * Update list of supported devices --------- Co-authored-by: Joshua Lochner <26504141+xenova@users.noreply.github.com> * customize the wasm paths (huggingface#1250) * customize the wasm paths * update implementation * [internal] Add is_decoder option to session retrieval for preferred output location * Update tests * Formatting * Bump ort versions * Bump onnxruntime-node version * Bump versions * Bump ORT versions * Bump versions * Only check webgpu fp16 for non-node environments * Fix * Assume node supports webgpu * Update ORT node support comment * Relax test strictness * Update conversion script versions * Downgrade onnxslim * cleanup * Update package-lock.json * Update onnxruntime versions * Update post-build script * Use built-in session release function * Call garbage collection after each tokenizer test * Do not double-throw error * Fix race-condition in build process with file removal * Update versions * Bump jinja version * [version] Update to 3.6.3 * Bump jinja version to support new features * [version] Update to 3.6.3 * Add support for LFM2 models (huggingface#1367) * Use prefix in lfm2 output location (huggingface#1369) * Update package-lock.json * Run `npm audit fix` * Add special tokens in text-generation pipeline if tokenizer requires (huggingface#1370) * Add special tokens in text-generation pipeline if tokenizer requires * Fix logits processors tests * Update bundles.test.js * Update comment * Formatting * Add support for ModernBERT Decoder (huggingface#1371) * Use from/to buffer instead of string Actually fixes huggingface#1343 * Add support for Voxtral (huggingface#1373) * Support longform voxtral processing (huggingface#1375) * [version] Update to 3.7.0 * Add support for Arcee (huggingface#1377) * Optimize tensor.slice() (huggingface#1381) * Optimize tensor.slice() The performance of executing `tensor.slice()` is super poor, especially for the 'logits' tensor with large dimensions. ``` const logits = outputs.logits.slice(null, -1, null);` ``` This is because currently implementation of the `slice` method manually iterates through each element and calculate indices which is a big time consuming if the tensor shape is large. For cases like `slice(null, -1, null)`, where the slicing operation is contiguous along certain dimensions, which can be optimized by bulk copy by using `TypeArray.subarray()` and `TypeArray.set()`. * nit * Add a few more tensor slice unit tests --------- Co-authored-by: Joshua Lochner <26504141+xenova@users.noreply.github.com> --------- Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Co-authored-by: Wanming Lin <wanming.lin@intel.com>
…ace#1468) * suppress console.error while creating InferenceSession * changed console suppress if not one of the misleading errors * set default logSeverityLevel and also match the ONNX_WEB.env.logLevel * indentation * small fix * some clean-up * Apply suggestions from code review Co-authored-by: Joshua Lochner <admin@xenova.com> * added LOG_LEVELS to the top of the file --------- Co-authored-by: Joshua Lochner <admin@xenova.com>
huggingface#1471) * added wasm cache * some refactoring of the hub.js and caching of the wasm factory * fixed comment * added string as cache return * fixes after review * Only return if match is found * Return response even if cache doesn't exist Don't throw error if we can't open cache or load file from cache, but we are able to make the request. --------- Co-authored-by: Joshua Lochner <26504141+xenova@users.noreply.github.com> Co-authored-by: Joshua Lochner <admin@xenova.com>
* added blob check before cahing wasm or mjs file * added propper handling for absolute/relative URLs * clean up * removed unneeded url check * use isValidUrl
* added esuild * fixed stream and stream/promises import * changes after review * Delete webpack.config.js * Bump esbuild version --------- Co-authored-by: Joshua Lochner <26504141+xenova@users.noreply.github.com>
…ngface#1498) * started refactoring * started refactoring * started refactoring * added model class files * added model class files * added model class files * all model classes in their own files * refactored PreTrainedModel * refactoring done, lets fix bugs * added model-registry * removed dev file * changed casing * refactored MODEL_TYPE_CONFIG * fixed tests * small refactoring * moved model loader to its own file * fixed ts errors * big structure refactoring * fixed build * renamed _base/pre-trained-model.js and _base/output.js * small casing changes * Update src/models/ernie4_5/modeling_ernie4_5.js Co-authored-by: Joshua Lochner <admin@xenova.com> * refactored models/utils.js * fixed double MODEL_FOR_ definitions with registerTaskMappings helper * auto/image_processing_auto.js export * auto/image_processing_auto.js export * Improve model mapping setup * Fix LlavaPreTrainedModel * Move llava_onevision to separate files * Add missing exports * Update jinja version * Fix default class mapping * Simplify registerTaskMappings * Update registry.js * Formatting in src/models * Formatting in src * Move model-specific ModelOutput to respective modeling files * Final cleanup * Cleanup model exports * Fix Tensor type re-export * Clean up registry exports * Cleanup * Simplify loadResourceFile * Use positional arguments for repo id and filename * Update global library exports * Remove ts-expect-error * Formatting * let -> const --------- Co-authored-by: Joshua Lochner <admin@xenova.com> Co-authored-by: Joshua Lochner <26504141+xenova@users.noreply.github.com>
* Remove legacy tokenizer tests * Update utils.test.js * Update unit tests * Refactor tokenizers.js * Update streamers.js * Update imports * Initial tokenization migration * Remove unnecessary index.js files * Do not export PretrainedMixin * Refactor models.js/tokenizers.js * Update imports * Update more imports * Update folder structure and imports * Delete tokenization_code_xlm_roberta.js * Fix import path * Fix typos * Update import path
* Remove legacy tokenizer tests * Update utils.test.js * Update unit tests * Refactor tokenizers.js * Update streamers.js * Update imports * Initial tokenization migration * Remove unnecessary index.js files * Do not export PretrainedMixin * Refactor models.js/tokenizers.js * Update imports * Update more imports * Update folder structure and imports * Delete tokenization_code_xlm_roberta.js * Add support for FalconH1
* Setup test case * Update audio-classification.js * Update text-to-audio pipeline: implementation and types * Implement tensor repeat and tile operations * Optimize randn implementation * Update automatic-speech-recognition.js * Update question-answering.js * Update image-classification.js * Update image-to-image.js * Update text-classification.js * Update depth-estimation.js * Update background-removal.js * Update image-segmentation JSDoc * Fix DQA JSDoc * Remove unused type * Update ObjectDetectionPipeline types * Update Text2TextGenerationPipeline types (and subclasses) * Update TokenClassificationPipeline types * Update image-to-text.js * Remove useless constructors * Update zero-shot pipeline types * Update image-segmentation.js * Create pipeline tests for type checking * Update tsconfig.json * Update onnx.js * Use defined types * Support passing speaker embeddings tensor directly
* switched to pnpm workspaces * updated github actions * added comments * Update tensor.js * Formatting * Update tsconfig.json * Update tsconfig.json * fixed circular reference error in pipelines/zero-shot-audio-classification.js * Post-tsconfig updates * Move transformers.js docs to package folder * Move additional tests * JSDoc update * Version bumps * Update incorrect test * Update test_modeling_musicgen.js * Update test_modeling_musicgen.js * Update test_modeling_musicgen.js * fixed broken symlink * fixes after review * Remove old conversion scripts Users should use onnxruntime-genai or optimum directly * Update .prettierrc * Formatting * Update readme/docs * Move build scripts to parent folder * Remove unused tests * Remove old compare function * Fix JSDoc * Update generate.js * Update inline descriptions * Bump versions * Update node imports * Add module header to FileCache.js * JSDoc updates * Update tensor.js * Move prettier config to package.json key * Update FileCache.js * Remove unused import * Remove non-existent file include * Prefer non-default exports * Update doc module exports * Update docs generation script * merged tsconfigs and added contributing.md * Update path_to_docs * Formatting * Formatting * Formatting * Update prettier usage * Remove <code> tags from headers * Swap docs-preview and docs-build commands * ONNXRUNTIME_NODE_INSTALL=skip for doc-builder * Update buildAll.mjs * Update index --------- Co-authored-by: Joshua Lochner <26504141+xenova@users.noreply.github.com>
Collaborator
|
Hi @jakobhoeg, Thanks for the PR! In general I think its great to add the Vercel AI SDK to the docs. We can then take another look at the exact wording and page structure, OK? |
Author
|
Sounds like a plan! I'll update and use v4 as the base branch. |
7157ae2 to
a856d55
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes adding documentation for using Transformers.js with the Vercel AI SDK via the @browser-ai/transformers-js community model provider. This is an idea/suggestion for the core docs, happy to adjust or remove if you feel like it doesn't fit.
Closes #1389
Summary
(docs/source/guides/vercel-ai-sdk.md)covering usage of Transformers.js as a Vercel AI SDK model provider via @browser-ai/transformers-js npm package. Text generation, embeddings, vision, transcription, tool calling, Web Workers, download progress, useChat transport, and browser fallback.(docs/source/tutorials/next-ai-sdk.md)for building a Next.js AI chatbot from scratch with WebGPU, tool calling, and human-in-the-loop approval.