lightonai / pylate

Late Interaction Models Training & Retrieval
https://lightonai.github.io/pylate/
MIT License
175 stars 7 forks source link

Loading SentenceTransformer Model and `_load_sbert_model` in ColBERT class #64

Closed BenoitHardier closed 1 month ago

BenoitHardier commented 1 month ago

Hey, thanks for your work. I am trying to finetuned a model based on OrdalieTech/Solon-embeddings-base-0.1. like that:

 model = models.ColBERT(model_name_or_path="OrdalieTech/Solon-embeddings-base-0.1")

Unfortunatly, it seems that the _load_sbert_model should output both modules and module_kwargs (The SentenceTranformer doc seems wrong) . I am not sure if it's related to the SentenceTransformer version but I am using the last one 3.2.0

I finally succeed to load solon changing the _load_sbert_model in colbert.py It should be modified: https://github.com/lightonai/pylate/blob/ddaf8f82dfd8725275c2362c2560c78565b5a874/pylate/models/colbert.py#L1153 and here https://github.com/lightonai/pylate/blob/ddaf8f82dfd8725275c2362c2560c78565b5a874/pylate/models/colbert.py#L1194-L1199

Let me know, if I am doing something wrong or if my issue is useful.

Benoît HARDIER

NohTow commented 1 month ago

Hello,

Indeed, breaking changes were introduced in this commit of ST, hence why we fixed the version of sentence-transformers to the last version before 3.1 (sentence-transformers == 3.0.1).

The fix is indeed what you suggested and during my preliminary tests, it seemed to work fine, but I wanted to make sure there was no regression before doing a PR for the fix and bump the version of ST. I might do the PR in the next days if it becomes needed. In the mean time, you can either use your own hacked version or use the 3.0.1 version if you do not need the latest change (e.g, ONNX backend if you are training on CPU)!

NohTow commented 1 month ago

Hello again,

I fixed the issue in #65 and now the training with the model from Ordalie works fine with ST 3.2.0! I'll merge the PR during the day alongside with other improvements and bump the version of PyLate. image

BenoitHardier commented 1 month ago

Hey

Great, It's also working on my setup.

I will try to continue digging into the repo. (I am specially interested in training/fine-tuning french retrieval models) I let you close the issue when you have merged the fix.

Benoît HARDIER

NohTow commented 1 month ago

Cool! We are also working on French models right now (on est une entreprise française à la base), hopefully we'll have cool things for you very soon!

NohTow commented 1 month ago

Closing since the PR has been merged.