Instructions to use jinaai/xlm-roberta-flash-implementation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jinaai/xlm-roberta-flash-implementation with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("jinaai/xlm-roberta-flash-implementation", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Call post_init() in XLMRobertaLoRA for transformers v5
#64
by AbhayShukla19 - opened
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=Falsepath (fresh adapters on a pretrainedXLMRobertaModel) gives a bit-identical state dict to the current code on 4.57.6 (seeded, 492/492 tensors equal), sopost_init()doesn't re-initialize anything there. - vLLM's
test_matryoshkaHF-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).