-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Add support for BertForSequenceClassification reranking #13858
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I was just looking into adding more Bert models in fact. :)
We should add ModernBERT. |
@CISC I fixed the linting issues. |
Hmmm, this broke rerank-tiny (JinaBert): Traceback (most recent call last):
File "/home/ggml/work/llama.cpp/build-ci-release/../convert_hf_to_gguf.py", line 6446, in <module>
main()
File "/home/ggml/work/llama.cpp/build-ci-release/../convert_hf_to_gguf.py", line 6440, in main
model_instance.write()
File "/home/ggml/work/llama.cpp/build-ci-release/../convert_hf_to_gguf.py", line 403, in write
self.prepare_tensors()
File "/home/ggml/work/llama.cpp/build-ci-release/../convert_hf_to_gguf.py", line 277, in prepare_tensors
for new_name, data_torch in (self.modify_tensors(data_torch, name, bid)):
File "/home/ggml/work/llama.cpp/build-ci-release/../convert_hf_to_gguf.py", line 4755, in modify_tensors
return super().modify_tensors(data_torch, name, bid)
File "/home/ggml/work/llama.cpp/build-ci-release/../convert_hf_to_gguf.py", line 3755, in modify_tensors
return [(self.map_tensor_name(name), data_torch)]
File "/home/ggml/work/llama.cpp/build-ci-release/../convert_hf_to_gguf.py", line 236, in map_tensor_name
raise ValueError(f"Can not map tensor {name!r}")
ValueError: Can not map tensor 'classifier.out_proj.weight' |
@huydt84 Can you make another PR that fixes this? We need a way to identify this type of model, it looks like num_labels might be a way? IE, just |
@CISC Let me check that. |
Actually, nvm, I'm adding Roberta reranker, so it's convenient to add the fix there (it has 2 labels, so requires special handling anyway). |
This PR includes:
convert_hf_to_gguf
to handle BertForSequenceClassification modelllm_graph_context::build_pooling
work with BertForSequenceClassification, which uses single layer classification head (nn.Linear
)