Running locally with custom models
Hi,
Thank you so much for this awesome project! I'm trying to visualize the attention weights of the model I trained (RoBERTa model with a multi-task final layer, fine-tuned using HuggingFace) and I'm wondering if that is supported by exBERT. Also, I'm wondering if there will be any modification of the code needed if I trained my model using HuggingFace version later than v2.8. Thanks a lot!
Apologies for taking so long to respond -- exBERT should work out of the box with Roberta but I haven't run it through tests for models trained on more recent versions of huggingface. My guess is that it would work as I am not aware of differences to how they save the model's weights. Would you be willing to try and see what issues you run into with your model? I will gladly take a look to fix/update anything that is not working.
@bhoov - I am unclear how to get this to connect to my existing ClinicalBERT model, can you please provide some guidance so I can see metrics in the web UI?
The following instructions pull the model from https://huggingface.co/emilyalsentzer/Bio_ClinicalBERT with some sensible defaults. They should also work for a local model saved with huggingface's API
There are 2 main parts to exbert:
- Part A: The attention visualization and layer exploration (quick)
- Part B: Annotating a custom (small-ish) corpus and searching for nearest embeddings over them. (harder)
After you setup the environment:
- Part A:
python server/main.py --model emilyalsentzer/Bio_ClinicalBERT --kind bidirectional - Part B: From the root of the project:
cd server/data_processing
python create_corpus.py -f MY_LOCAL_CLINICAL_CORPUS.txt -o ../../clinical_corpus --model emilyalsentzer/Bio_ClinicalBERT
cd ../..
python server/main.py --model emilyalsentzer/BioClinicalBERT --kind bidirectional --corpus clinical_corpus/
@bhoov Thank you 🙏 kindly for that explanation this helps a lot.
As for using makefile, it does break, and have been unsuccessful starting it up via other instructions.
If you can help me get it going, I’d be more than happy to contribute a Dockerfile so it will run everywhere. I also think that is a opportunity for me to refac some of the code & upgrade to PyTorch 1.7 & HuggingFace:latest, while I’m in there containerizing it. Let me know plz.