remove hardcoded file names and allow arbitrary models to be used - #51
Draft
BobdenOs wants to merge 3 commits into
Draft
remove hardcoded file names and allow arbitrary models to be used#51BobdenOs wants to merge 3 commits into
BobdenOs wants to merge 3 commits into
Conversation
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.
Refactor: Replace Custom Tokenizer with HuggingFace Tokenizers and Support Dynamic Model File Discovery
This PR refactors the vector embedding pipeline to remove hardcoded file names, replace the hand-rolled WordPiece tokenizer with
@huggingface/tokenizers, and switch the default model toperplexity-ai/pplx-embed-v1-0.6b.Key Changes
model-utils.js@huggingface/tokenizersimport;loadModelAndVocabnow creates a properTokenizerinstance instead of manually parsing a vocabulary map.preTokenize,wordPieceTokenize,validateTokenIds).fetchModelFiles(): dynamically discovers the required model files by first downloadingonnx/model.onnx, then parsing the ONNX protobuf binary to detect any external data file references, and returning the full list of files to download (includingtokenizer.json/tokenizer_config.json).downloadModelIfNeededandforceRedownloadModelnow preserve directory structure (use full relative paths instead ofpath.basename).downloadModelIfNeededare now parallelized viaPromise.all.downloadFilenow creates intermediate directories automatically.embedding.jsXenova/all-MiniLM-L6-v2toperplexity-ai/pplx-embed-v1-0.6b.FILESconstant; file list is now fetched dynamically viafetchModelFiles().wordPieceTokenizerwithtokenizeWithChunks, which delegates to the HuggingFaceTokenizerinstance.vocabvariable replaced withtokenizer.initializeModelAndVocabnow accepts thefileslist as a parameter.InferenceSession.jsInferenceSession.create()now accepts a file path string in addition toUint8Array, enabling the session to load the model directly from disk rather than reading it into memory first.package.json@huggingface/tokenizers: ^0.1.3as a dependency.Category: Refactor 🔧
Added relevant entry to the change log?
🔄 Regenerate and Update Summary
PR Bot Information
Version:
1.29.26anthropic--claude-4.6-sonnetd8a8ac30-97df-11f1-834d-db338db31e22pull_request.opened