Closed kunalr97 closed 11 months ago
Hello!
The cross-encoder is indeed quite memory intensive (I tested everything with 48GB GPU memory). Two things that might work:
1) I'm not sure if all memory allocated by SapBERT would be cleared by empty_cache()
, you might instead want to save the candidate dataset to disk and restart the process / notebook to make sure CUDA memory is entirely freed up.
2) You can reduce the memory footprint of the cross-encoder by reducing the number of candidates subject to re-ranking (which equals the batch size) to something like 16 instead of 64.
Another thing that might work (though I have not tested the performance), would be to use a smaller BERT model, i.e.,
train_args = CrossEncoderTrainingArgs(model_name="distilbert-base-multilingual-cased")
Hi,
Thanks for your quick response. I will try this and hope that it works. Where exactly do i need to do this ?
2. You can reduce the memory footprint of the cross-encoder by reducing the number of candidates subject to re-ranking (which equals the batch size) to something like 16 instead of 64.
Thanks in advance
There are multiple steps at which you can reduce the number of candidates. However, if you follow this notebook (https://github.com/hpi-dhc/xmen/blob/main/examples/02_BRONCO.ipynb), then setting K_RERANKING = 16
just before calling CrossEncoderReranker.prepare_data
should do the trick.
Note: I assume that this will cost you a bit of recall@1, but it might actually increase precision. To get precision, recall and F1 scores at the end, use evaluate
instead of evaluate_at_k
Thanks a lot! I don't get that error now.
Thank you for pointing this issue out, I have linked this thread in the README
When i try to train the cross encoder on the BRONCO dataset for prediciting the ICD code for the diagnoses entities. I get this error:
I tried running this line and it does not seem to work. Also there are not any other processes running on the GPU.
Thanks in advance for your help.