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
| # ruff: noqa: F401 | |
| import warnings | |
| from pathlib import Path | |
| warnings.filterwarnings("ignore", message=".*The 'nopython' keyword.*") # noqa # isort:skip | |
| GENE_MEDIAN_FILE = Path(__file__).parent / "gene_median_dictionary_gc104M.pkl" | |
| TOKEN_DICTIONARY_FILE = Path(__file__).parent / "token_dictionary_gc104M.pkl" | |
| ENSEMBL_DICTIONARY_FILE = Path(__file__).parent / "gene_name_id_dict_gc104M.pkl" | |
| ENSEMBL_MAPPING_FILE = Path(__file__).parent / "ensembl_mapping_dict_gc104M.pkl" | |
| GENE_MEDIAN_FILE_30M = Path(__file__).parent / "gene_dictionaries_30m/gene_median_dictionary_gc30M.pkl" | |
| TOKEN_DICTIONARY_FILE_30M = Path(__file__).parent / "gene_dictionaries_30m/token_dictionary_gc30M.pkl" | |
| ENSEMBL_DICTIONARY_FILE_30M = Path(__file__).parent / "gene_dictionaries_30m/gene_name_id_dict_gc30M.pkl" | |
| ENSEMBL_MAPPING_FILE_30M = Path(__file__).parent / "gene_dictionaries_30m/ensembl_mapping_dict_gc30M.pkl" | |
| from . import ( | |
| collator_for_classification, | |
| emb_extractor, | |
| in_silico_perturber, | |
| in_silico_perturber_stats, | |
| pretrainer, | |
| tokenizer, | |
| ) | |
| from .collator_for_classification import ( | |
| DataCollatorForCellClassification, | |
| DataCollatorForGeneClassification, | |
| ) | |
| from .emb_extractor import EmbExtractor, get_embs | |
| from .in_silico_perturber import InSilicoPerturber | |
| from .in_silico_perturber_stats import InSilicoPerturberStats | |
| from .pretrainer import GeneformerPretrainer | |
| from .tokenizer import TranscriptomeTokenizer | |
| from . import classifier # noqa # isort:skip | |
| from .classifier import Classifier # noqa # isort:skip | |
| from . import mtl_classifier # noqa # isort:skip | |
| from .mtl_classifier import MTLClassifier # noqa # isort:skip | |