-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[Feature]: Add classification Task with AutoModelForSequenceClassification and BertForSequenceClassification #10939
Comments
From my understanding, this isn't even available in |
Thank you for pointing this out. I haven’t tested whether the BERT model is available via the Score API on my local That said, the core of my Feature Request is not about the current implementation status of the Score API but rather about adding BERT models to the Classification task. I’d appreciate hearing opinions on this topic as well. |
We don't distinguish between sequence classification and cross-encoding in terms of model architecture. As long as the model architecture is compatible, you can use the same model for regular sequence classification. |
Thank you for your guidance. I realize that my understanding was incomplete, and I had assumed that this Score API could only be used for tasks where two sentences are input simultaneously into the model to evaluate similarity or relevance. I thought it couldn't be used for the task I want to perform, which involves processing an entire input sequence to predict specific class labels. On the other hand, for text classification, it might be more convenient to support direct inference within the main script, such as using something like I apologize if my question is based on a misunderstanding. |
You are correct that Score API is only for cross-encoder models. On the other hand, you can use |
I wasn't aware of the I'll try using this feature to perform text classification with the BERT model and the DistilBERT model. If it works well, I'll share some sample code and close this issue. I'm really excited about this! |
I tried it, but unfortunately, it didn't work. This result was occured using llm = LLM(model="path/to/model/dir/my_fine_tuned_tohokuBERT", tensor_parallel_size=1)
ValueError: Model architectures ['BertForSequenceClassification'] are not supported for now. Supported architectures: dict_keys(['AquilaModel', 'AquilaForCausalLM', 'ArcticForCausalLM', 'BaiChuanForCausalLM', 'BaichuanForCausalLM', 'BloomForCausalLM', 'CohereForCausalLM', 'DbrxForCausalLM', 'DeciLMForCausalLM', 'DeepseekForCausalLM', 'DeepseekV2ForCausalLM', 'ExaoneForCausalLM', 'FalconForCausalLM', 'GemmaForCausalLM', 'Gemma2ForCausalLM', 'GPT2LMHeadModel', 'GPTBigCodeForCausalLM', 'GPTJForCausalLM', 'GPTNeoXForCausalLM', 'GraniteForCausalLM', 'GraniteMoeForCausalLM', 'InternLMForCausalLM', 'InternLM2ForCausalLM', 'InternLM2VEForCausalLM', 'JAISLMHeadModel', 'JambaForCausalLM', 'LlamaForCausalLM', 'LLaMAForCausalLM', 'MambaForCausalLM', 'FalconMambaForCausalLM', 'MiniCPMForCausalLM', 'MiniCPM3ForCausalLM', 'MistralForCausalLM', 'MixtralForCausalLM', 'QuantMixtralForCausalLM', 'MptForCausalLM', 'MPTForCausalLM', 'NemotronForCausalLM', 'OlmoForCausalLM', 'OlmoeForCausalLM', 'OPTForCausalLM', 'OrionForCausalLM', 'PersimmonForCausalLM', 'PhiForCausalLM', 'Phi3ForCausalLM', 'Phi3SmallForCausalLM', 'PhiMoEForCausalLM', 'Qwen2ForCausalLM', 'Qwen2MoeForCausalLM', 'RWForCausalLM', 'StableLMEpochForCausalLM', 'StableLmForCausalLM', 'Starcoder2ForCausalLM', 'SolarForCausalLM', 'XverseForCausalLM', 'BartModel', 'BartForConditionalGeneration', 'Florence2ForConditionalGeneration', 'BertModel', 'RobertaModel', 'XLMRobertaModel', 'Gemma2Model', 'LlamaModel', 'MistralModel', 'Qwen2Model', 'Qwen2ForRewardModel', 'Qwen2ForSequenceClassification', 'LlavaNextForConditionalGeneration', 'Phi3VForCausalLM', 'Qwen2VLForConditionalGeneration', 'Blip2ForConditionalGeneration', 'ChameleonForConditionalGeneration', 'ChatGLMModel', 'ChatGLMForConditionalGeneration', 'FuyuForCausalLM', 'H2OVLChatModel', 'InternVLChatModel', 'Idefics3ForConditionalGeneration', 'LlavaForConditionalGeneration', 'LlavaNextVideoForConditionalGeneration', 'LlavaOnevisionForConditionalGeneration', 'MiniCPMV', 'MolmoForCausalLM', 'NVLM_D', 'PaliGemmaForConditionalGeneration', 'PixtralForConditionalGeneration', 'QWenLMHeadModel', 'Qwen2AudioForConditionalGeneration', 'UltravoxModel', 'MllamaForConditionalGeneration', 'EAGLEModel', 'MedusaModel', 'MLPSpeculatorPreTrainedModel']) llm = LLM(model="cl-tohoku/bert-base-japanese-v3", tensor_parallel_size=1)
ValueError: Model architectures ['BertForPreTraining'] are not supported for now. Supported architectures: ....... |
Even if you use |
Finally, I understand the meaning of the advice you initially gave me. Thank you so much for your thorough support. Once I confirm that the changes in the main branch are included in the next release version, I'll give it a try! |
Sorry that I wasn't being clear before! |
🚀 The feature, motivation and pitch
Latest Version:
v0.6.4.post1
Summary:
I would like to request support for using BERT and DistilBERT models for classification tasks. As of
v0.6.4.post1
,BertForSequenceClassification
is only available for Sentence Pair Scoring tasks via the Score API.Detail:
With a recent Pull Request, #9704
Qwen2ForSequenceClassification
became available for text classification tasks. This is a fantastic improvement!However, in text multi-classification tasks, models other than Qwen2 are often preferred due to the following reasons:
BERT and DistilBERT, which have been extensively researched and fine-tuned for a wide range of languages, often achieve better classification accuracy and faster inference times. These models are frequently integrated into applications as local LLMs, making them an excellent fit for vLLM's role as a high-speed inference accelerator.
Currently, if we try to execute code for text classification using BERT or DistilBERT models in the same manner as the sample code for Qwen2, the following error is raised:
Adding support for
AutoModelForSequenceClassification
,BertForSequenceClassification
, and similar models would greatly enhance the utility of vLLM for a broader range of text classification tasks.Alternatives
No response
Additional context
No response
Before submitting a new issue...
The text was updated successfully, but these errors were encountered: