Skip to content

Inference with different LoRA adapters in the same batch - Embedding models #2088

Closed Answered by BenjaminBossan
DogitoErgoSum asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the code. I could not reproduce the issue, for me it worked just fine. I also tried 2 different adapters and it still worked. Here is the self-contained code. Could you check if it passes for you as well?

from transformers import AutoTokenizer, AutoModel
from peft import LoraConfig, PeftModel, get_peft_model

tokenizer = AutoTokenizer.from_pretrained('intfloat/multilingual-e5-large-instruct')
queries = ["hello", "world"]
batch_dict = tokenizer(queries, max_length=512, padding=True, truncation=True, return_tensors='pt')

# first create a dummy LoRA adapter
model = AutoModel.from_pretrained('intfloat/multilingual-e5-large-instruct')
conf = LoraConfig(target_modules=["key", "query", 

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
8 replies
@DogitoErgoSum
Comment options

@BenjaminBossan
Comment options

@DogitoErgoSum
Comment options

@BenjaminBossan
Comment options

Answer selected by DogitoErgoSum
@DogitoErgoSum
Comment options

Comment options

You must be logged in to vote
1 reply
@BenjaminBossan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants