Instructions to use ctheodoris/Geneformer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ctheodoris/Geneformer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="ctheodoris/Geneformer")# Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("ctheodoris/Geneformer") model = AutoModelForMaskedLM.from_pretrained("ctheodoris/Geneformer", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
Use dynamic CUDA check instead of hardcoded device in perturber_utils.py
#594
by dlgenomics - opened
Fixes CPU-only inference, which currently fails with "AssertionError: Torch not compiled with CUDA enabled" because device="cuda" is hardcoded in gen_attention_mask().
Replaces the hardcoded "cuda" with a dynamic check ("cuda" if torch.cuda.is_available() else "cpu"), matching the pattern already used elsewhere in the codebase (e.g. load_model()).
See discussion #592: https://huggingface.co/ctheodoris/Geneformer/discussions/592
Companion PR (emb_extractor.py fix): https://huggingface.co/ctheodoris/Geneformer/discussions/593