Best practice for integrating transformers

Dear Philipp,

Thanks for reaching out!

We have two ways, one way would be to add the models into the Docker image. For smaller transformer models, adding the weights of the transformer to the image does not add too much overhead, so this is fine. For instance, this is how a mini-lm transformer is added to the touche ads detection baseline:

# Add a line like this to your Dockerfile to ensure the tokenizer is in the docker image:
RUN python3 -c 'from transformers import AutoTokenizer, AutoModel; AutoTokenizer.from_pretrained("sentence-transformers/all-MiniLM-L6-v2"); AutoModel.from_pretrained("sentence-transformers/all-MiniLM-L6-v2");'

For larger models, this is not possible, and for this we have a --mount-hf-model flag so that you can mount a model from hugging face. For instance, here is an example on how meta-llama/Llama-3.1-8B-Instruct and meta-llama/Llama-3.1-8B are mounted to the Gen AI Detection baseline: https://github.com/pan-webis-de/pan-code/tree/master/clef25/generative-authorship-verification/pan25_genai_baselines#submit-llm-approaches-to-tira. (more details for this are available here.

Does this help you?

Best regards,

Maik