Support for encoder-only models in the F2LLM framework #29
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.
Summary of Changes
This PR introduces support for encoder-only models in the F2LLM framework and includes testing for compatibility with different flash attention versions. The changes enable the system to work with both encoder-only models (like BERT) and decoder-only models (like Qwen), automatically detecting the model type and applying appropriate configurations.
Related Issue
#10
Key Features Added
Encoder-Only Model Support: Added functionality to detect and properly handle encoder-only models (BERT, ELECTRA, MPNet) vs. decoder-only models.
Flexible Embedding Extraction: Implemented different embedding extraction methods based on model type:
Flash Attention Compatibility: Updated flash attention version requirements and implementation selection logic.
Tokenizer Script Update: Modified data tokenization process to support both BERT and Qwen tokenizers with a new
--tokenizerparameter.Technical Changes
detect_model_type()function to automatically identify model architectureextract_cls_embeddings(),extract_mean_pooling_embeddings(), andextract_last_token_embeddings()tokenize_data.pyto support multiple tokenizer types via command line argumentTesting