Transformers
xlm-roberta
🇪🇺 Region: EU

Call post_init() in XLMRobertaLoRA for transformers v5

#64

Fixes #62. Heads up: I prepared this with AI assistance (Claude Code) and reviewed and tested it myself.

XLMRobertaLoRA.__init__ doesn't call self.post_init(), which transformers v5 requires (#60 added it to the classes in modeling_xlm_roberta.py, but not here). So loading jinaai/jina-embeddings-v3 on transformers>=5 fails with:

AttributeError: 'XLMRobertaLoRA' object has no attribute 'all_tied_weights_keys'

This adds self.post_init() at the end of XLMRobertaLoRA.__init__.

Testing (RTX PRO 6000; SentenceTransformer("jinaai/jina-embeddings-v3", trust_remote_code=True).encode(..., task="text-matching") on 4 sentences)

transformers current code this PR
4.57.6 works embeddings bit-identical to current code
5.17.0 AttributeError above embeddings bit-identical to 4.57.6
  • The load_trained_adapters=False path (fresh adapters on a pretrained XLMRobertaModel) gives a bit-identical state dict to the current code on 4.57.6 (seeded, 492/492 tensors equal), so post_init() doesn't re-initialize anything there.
  • vLLM's test_matryoshka HF-vs-vLLM comparison for jina-embeddings-v3 passes with this change on transformers 5.17.0 (it's currently skipped in vLLM because of this error).
Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment