Run this model with HF Jobs
Run ctheodoris/Geneformer on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/ctheodoris/Geneformer. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ctheodoris/Geneformer on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
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")# pip install -U transformers accelerate # 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
Fixed bug in gen_attention_mask with len > max_len
#158
by davidjwen - opened
341 unmodified lines3423433443453463473485 unmodified lines354355356357358359360361362363364365204 unmodified lines570571572573574575341 unmodified linesmax_range = min(i+forward_batch_size, total_batch_length)perturbation_minibatch = perturbation_batch.select([i for i in range(i, max_range)])# determine if need to pad or truncate batchminibatch_length_set = set(perturbation_minibatch["length"])minibatch_lengths = perturbation_minibatch["length"]5 unmodified linesif needs_pad_or_trunc == True:max_len = min(max(minibatch_length_set),model_input_size)def pad_or_trunc_example(example):example["input_ids"] = pad_or_truncate_encoding(example["input_ids"],pad_token_id,max_len)return exampleperturbation_minibatch = perturbation_minibatch.map(pad_or_trunc_example, num_proc=nproc)perturbation_minibatch.set_format(type="torch")input_data_minibatch = perturbation_minibatch["input_ids"]204 unmodified linesoriginal_lens = minibatch_encoding["length"]attention_mask = [[1]*original_len+[0]*(max_len - original_len)for original_len in original_lens]return torch.tensor(attention_mask).to("cuda")341 unmodified lines3423433443453463475 unmodified lines353354355356357358359360361362363364365366204 unmodified lines571572573574575576577578341 unmodified linesmax_range = min(i+forward_batch_size, total_batch_length)perturbation_minibatch = perturbation_batch.select([i for i in range(i, max_range)])# determine if need to pad or truncate batchminibatch_length_set = set(perturbation_minibatch["length"])minibatch_lengths = perturbation_minibatch["length"]5 unmodified linesif needs_pad_or_trunc == True:max_len = min(max(minibatch_length_set),model_input_size)print(max_len)def pad_or_trunc_example(example):example["input_ids"] = pad_or_truncate_encoding(example["input_ids"],pad_token_id,max_len)return exampleperturbation_minibatch = perturbation_minibatch.map(pad_or_trunc_example, num_proc=nproc)perturbation_minibatch.set_format(type="torch")input_data_minibatch = perturbation_minibatch["input_ids"]204 unmodified linesoriginal_lens = minibatch_encoding["length"]attention_mask = [[1]*original_len+[0]*(max_len - original_len)if original_len <= max_lenelse [1]*max_lenfor original_len in original_lens]return torch.tensor(attention_mask).to("cuda")
geneformer/in_silico_perturber.py+4-1