初始化项目,由ModelHub XC社区提供模型
Model: vandijklab/pythia-160m-c2s Source: Original Platform
This commit is contained in:
commit
cb8652c665
10 files changed
+257
No files matched your search
@@ -0,0 +1,50 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
||||
*.tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
*.db* filter=lfs diff=lfs merge=lfs -text
|
||||
*.ark* filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.gguf* filter=lfs diff=lfs merge=lfs -text
|
||||
*.ggml filter=lfs diff=lfs merge=lfs -text
|
||||
*.llamafile* filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
@@ -0,0 +1,149 @@
|
||||
---
|
||||
license: cc-by-4.0
|
||||
datasets:
|
||||
- vandijklab/immune-c2s
|
||||
language:
|
||||
- en
|
||||
tags:
|
||||
- pytorch
|
||||
- causal-lm
|
||||
- scRNA-seq
|
||||
---
|
||||
# Overview
|
||||
|
||||
This is the the Pythia-160m model developed by EleutherAI fine-tuned using Cell2Sentence on *full* scRNA-seq cells.
|
||||
Cell2Sentence is a novel method for adapting large language models to single-cell transcriptomics.
|
||||
We transform single-cell RNA sequencing data into sequences of gene names ordered by expression level, termed "cell sentences".
|
||||
For more details, we refer to the paper linked below.
|
||||
This model was trained on the immune tissue dataset from [Domínguez et al.](https://www.science.org/doi/10.1126/science.abl5197)
|
||||
using 8 A100 40GB GPUs for approximately 20 hours on the following tasks:
|
||||
1. conditional cell generation
|
||||
2. unconditional cell generation
|
||||
3. cell type prediction
|
||||
|
||||
## Cell2Sentence Links:
|
||||
GitHub: <https://github.com/vandijklab/cell2sentence-ft> (Note: Codebase has Apache 2.0 license, weights shared on HuggingFace are CC-by-4.0)
|
||||
Paper: <https://www.biorxiv.org/content/10.1101/2023.09.11.557287v3>
|
||||
|
||||
## Pythia Links:
|
||||
GitHub: <https://github.com/EleutherAI/pythia>
|
||||
Paper: <https://arxiv.org/abs/2304.01373>
|
||||
Hugging Face: <https://huggingface.co/EleutherAI/pythia-160m>
|
||||
|
||||
# Evaluation
|
||||
|
||||
This model was evaluated on KNN classification and Gromov-Wasserstein (GW) distance.
|
||||
The label for a generated cell is the corresponding cell type used in its corresponding prompt for generation.
|
||||
Ground truth cells were sampled with replacement from a held out test dataset.
|
||||
The generated cells are converted to expression vectors using the method described in the paper.
|
||||
For complete details on the experiments, we refer to the paper.
|
||||
|
||||
| Model | k=3 NN (↑) | k=5 NN (↑) | k=10 NN (↑) | k=25 NN (↑) | GW (↓) |
|
||||
| :---- | :---: | :---: | :---: | :---: | :----: |
|
||||
| scGEN | 0.2376 | 0.2330 | 0.2377 | 0.2335 | 315.9505 |
|
||||
| scVI | 0.2436 | 0.2400 | 0.2425 | 0.2348 | 302.1285 |
|
||||
| scDiffusion | 0.2335 | 0.2288 | 0.2368 | 0.2306 | 72.0208 |
|
||||
| scGPT | 0.1838 | 0.1788 | 0.1811 | 0.1882 | 2989.8066 |
|
||||
| **C2S (Pythia-160m)** | **0.2588** | **0.2565** | **0.2746** | **0.2715** | **54.3040** |
|
||||
|
||||
# Sample Code
|
||||
|
||||
We provide an example of how to use the model to conditionally generate a cell equipped with a post-processing function to remove duplicate and invalid genes.
|
||||
In order to generate full cells, the `max_length` generation parameter should be changed to 9200.
|
||||
However, we recommend using an A100 GPU for inference speed and memory capacity if full cell generation is required.
|
||||
Unconditional cell generation and cell type prediction prompts are included as well, but we do not include an example cell sentence to format the prompt.
|
||||
We refer to the paper and GitHub repository for instructions on how to transform expression vectors into cell sentences.
|
||||
|
||||
```
|
||||
import json
|
||||
import re
|
||||
from collections import Counter
|
||||
from typing import List
|
||||
|
||||
import torch
|
||||
from transformers import AutoTokenizer, AutoModelForCausalLM
|
||||
|
||||
|
||||
def post_process_generated_cell_sentences(
|
||||
cell_sentence: str,
|
||||
gene_dictionary: List
|
||||
):
|
||||
"""
|
||||
Post-processing function for generated cell sentences.
|
||||
Invalid genes are removed and ranks of duplicated genes are averaged.
|
||||
|
||||
Arguments:
|
||||
cell_sentence: generated cell sentence string
|
||||
gene_dictionary: list of gene vocabulary (all uppercase)
|
||||
|
||||
Returns:
|
||||
post_processed_sentence: generated cell sentence after post processing steps
|
||||
"""
|
||||
generated_gene_names = cell_sentence.split(" ")
|
||||
generated_gene_names = [generated_gene.upper() for generated_gene in generated_gene_names]
|
||||
|
||||
#--- Remove nonsense genes ---#
|
||||
generated_gene_names = [gene_name for gene_name in generated_gene_names if gene_name in gene_dictionary]
|
||||
|
||||
#--- Average ranks ---#
|
||||
gene_name_to_occurrences = Counter(generated_gene_names) # get mapping of gene name --> number of occurrences
|
||||
post_processed_sentence = generated_gene_names.copy() # copy of generated gene list
|
||||
|
||||
for gene_name in gene_name_to_occurrences:
|
||||
if gene_name_to_occurrences[gene_name] > 1 and gene_name != replace_nonsense_string:
|
||||
# Find positions of all occurrences of duplicated generated gene in list
|
||||
# Note: using post_processed_sentence here; since duplicates are being removed, list will be
|
||||
# getting shorter. Getting indices in original list will no longer be accurate positions
|
||||
occurrence_positions = [idx for idx, elem in enumerate(post_processed_sentence) if elem == gene_name]
|
||||
average_position = int(sum(occurrence_positions) / len(occurrence_positions))
|
||||
|
||||
# Remove occurrences
|
||||
post_processed_sentence = [elem for elem in post_processed_sentence if elem != gene_name]
|
||||
|
||||
# Reinsert gene_name at average position
|
||||
post_processed_sentence.insert(average_position, gene_name)
|
||||
|
||||
return post_processed_sentence
|
||||
|
||||
genes_path = "pbmc_vocab.json"
|
||||
|
||||
with open(vocab_path, "r") as f:
|
||||
gene_dictionary = json.load(f)
|
||||
|
||||
model_name = "vandijklab/pythia-160m-c2s"
|
||||
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_name,
|
||||
torch_dtype=torch.float16,
|
||||
attn_implementation="flash_attention_2"
|
||||
).to(torch.device("cuda"))
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
||||
|
||||
cell_type = "T Cell"
|
||||
ccg = f"Enumerate the genes in a {cell_type} cell with nonzero expression, from highest to lowest."
|
||||
|
||||
# Prompts for other forms a generation.
|
||||
# ucg = "Display a cell's genes by expression level, in descending order."
|
||||
# cellsentence = "CELL_SENTENCE"
|
||||
# ctp = "Identify the cell type most likely associated with these highly expressed genes listed in descending order. "
|
||||
# + cellsentence +
|
||||
# "Name the cell type connected to these genes, ranked from highest to lowest expression."
|
||||
|
||||
tokens = tokenizer(ccg, return_tensors='pt')
|
||||
input_ids = tokens['input_ids'].to(torch.device("cuda"))
|
||||
attention_mask = tokens['attention_mask'].to(torch.device("cuda"))
|
||||
|
||||
with torch.no_grad():
|
||||
outputs = model.generate(
|
||||
input_ids=input_ids,
|
||||
attention_mask=attention_mask,
|
||||
do_sample=True,
|
||||
max_length=1024,
|
||||
top_k=50,
|
||||
top_p=0.95,
|
||||
)
|
||||
|
||||
output_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
||||
cell_sentence = "".join(re.split(r"\?|\.|:", output_text)[1:]).strip()
|
||||
processed_genes = post_process_generated_cell_sentences(cell_sentence, gene_dictionary)
|
||||
```
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"_name_or_path": "/data/training-runs/EleutherAI/pythia-160m-2500genes-default_all-local292-2024-01-26_19-37-28/checkpoint-4000",
|
||||
"architectures": [
|
||||
"GPTNeoXForCausalLM"
|
||||
],
|
||||
"attention_bias": true,
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 0,
|
||||
"classifier_dropout": 0.1,
|
||||
"eos_token_id": 0,
|
||||
"hidden_act": "gelu",
|
||||
"hidden_dropout": 0.0,
|
||||
"hidden_size": 768,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 3072,
|
||||
"layer_norm_eps": 1e-05,
|
||||
"max_position_embeddings": 9200,
|
||||
"model_type": "gpt_neox",
|
||||
"num_attention_heads": 12,
|
||||
"num_hidden_layers": 12,
|
||||
"rope_scaling": null,
|
||||
"rotary_emb_base": 10000,
|
||||
"rotary_pct": 0.25,
|
||||
"tie_word_embeddings": false,
|
||||
"torch_dtype": "float32",
|
||||
"transformers_version": "4.37.1",
|
||||
"use_cache": false,
|
||||
"use_parallel_residual": true,
|
||||
"vocab_size": 50304
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"framework": "pytorch", "task": "text-generation", "allow_remote": true}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 0,
|
||||
"eos_token_id": 0,
|
||||
"transformers_version": "4.37.1"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:533d44516b8f0a8149a87ef935266a2d77df7d860c41c296cb5252629905de44
|
||||
size 649308728
|
||||
@@ -0,0 +1 @@
|
||||
["MIR1302-2HG", "FAM138A", "OR4F5", "AL627309.1", "AL627309.3", "AL627309.2", "AL627309.5", "AL627309.4", "AP006222.2", "AL732372.1", "OR4F29", "AC114498.1", "OR4F16", "AL669831.2", "LINC01409", "FAM87B", "LINC01128", "LINC00115", "FAM41C", "AL645608.6", "AL645608.2", "AL645608.4", "LINC02593", "SAMD11", "NOC2L", "KLHL17", "PLEKHN1", "PERM1", "AL645608.7", "HES4", "ISG15", "AL645608.1", "AGRN", "AL645608.5", "AL645608.8", "RNF223", "C1orf159", "AL390719.3", "LINC01342", "AL390719.2", "TTLL10-AS1", "TTLL10", "TNFRSF18", "TNFRSF4", "SDF4", "B3GALT6", "C1QTNF12", "AL162741.1", "UBE2J2", "LINC01786", "SCNN1D", "ACAP3", "PUSL1", "INTS11", "AL139287.1", "CPTP", "TAS1R3", "DVL1", "MXRA8", "AURKAIP1", "CCNL2", "MRPL20-AS1", "MRPL20", "AL391244.2", "ANKRD65", "AL391244.1", "TMEM88B", "LINC01770", "VWA1", "ATAD3C", "ATAD3B", "ATAD3A", "TMEM240", "SSU72", "AL645728.1", "FNDC10", "AL691432.4", "AL691432.2", "MIB2", "MMP23B", "CDK11B", "FO704657.1", "SLC35E2B", "CDK11A", "SLC35E2A", "NADK", "GNB1", "AL109917.1", "CALML6", "TMEM52", "CFAP74", "AL391845.2", "GABRD", "AL391845.1", "PRKCZ", "AL590822.2", "PRKCZ-AS1", "FAAP20", "AL590822.1", "SKI", "AL590822.3", "MORN1", "AL589739.1", "AL513477.2", "RER1", "PEX10", "PLCH2", "AL139246.1", "AL139246.4", "PANK4", "HES5", "AL139246.5", "TNFRSF14-AS1", "TNFRSF14", "AL139246.3", "PRXL2B", "MMEL1", "AL831784.1", "TTC34", "AC242022.2", "AC242022.1", "AL592464.2", "AL592464.3", "AL592464.1", "AL589702.1", "ACTRT2", "PRDM16-DT", "PRDM16", "AL008733.1", "AL590438.1", "AL354743.2", "AL354743.1", "ARHGEF16", "AL512413.1", "MEGF6", "AL513320.1", "TPRG1L", "WRAP73", "TP73", "AL136528.1", "AL136528.2", "CCDC27", "SMIM1", "LRRC47", "AL365330.1", "CEP104", "DFFB", "C1orf174", "LINC01134", "LINC01346", "LINC01345", "LINC02780", "AL805961.1", "LINC01777", "AL355602.1", "Z98747.1", "LINC01646", "AJAP1", "Z98886.1", "BX005132.1", "LINC02781", "LINC02782", "AL139823.1", "Z98259.3", "Z98259.2", "Z98259.1", "AL365255.1", "NPHP4", "KCNAB2", "CHD5", "RPL22", "AL031847.1", "RNF207", "ICMT", "LINC00337", "HES3", "GPR153", "ACOT7", "AL031848.2", "HES2", "ESPN", "AL031848.1", "TNFRSF25", "PLEKHG5", "NOL9", "TAS1R1", "ZBTB48", "KLHL21", "PHF13", "THAP3", "DNAJC11", "LINC01672", "AL591163.1", "CAMTA1-DT", "CAMTA1", "AL512330.1", "CAMTA1-IT1", "Z97987.1", "AL365194.1", "AL359881.3", "AL359881.2", "AL359881.1", "VAMP3", "Z98884.2", "PER3", "Z98884.1", "UTS2", "TNFRSF9", "PARK7", "AL034417.4", "AL034417.3", "ERRFI1", "AL034417.2", "LINC01714", "AL358876.2", "SLC45A1", "RERE", "RERE-AS1", "AL357552.2", "ENO1", "ENO1-AS1", "CA6", "SLC2A7", "SLC2A5", "GPR157", "MIR34AHG", "LNCTAM34A", "H6PD", "SPSB1", "BX323043.1", "LINC02606", "AL928921.1", "SLC25A33", "TMEM201", "PIK3CD", "PIK3CD-AS1", "PIK3CD-AS2", "CLSTN1", "CTNNBIP1", "AL357140.1", "AL357140.4", "LZIC", "AL357140.2", "NMNAT1", "AL603962.1", "RBP7", "UBE4B", "KIF1B", "AL139424.3", "AL139424.2", "PGD", "AL139424.1", "CENPS", "CORT", "DFFA", "AL354956.1", "PEX14", "AL139423.2", "CASZ1", "AL139423.1", "C1orf127", "TARDBP", "MASP2", "SRM", "EXOSC10", "AL109811.1", "EXOSC10-AS1", "MTOR", "MTOR-AS1", "ANGPTL7", "UBIAD1", "AL031291.1", "DISP3", "AL590989.1", "LINC01647", "AL031731.1", "FBXO2", "FBXO44", "FBXO6", "MAD2L2", "DRAXIN", "AGTRAP", "C1orf167", "AL953897.1", "MTHFR", "CLCN6", "NPPA", "NPPB", "AL021155.5", "KIAA2013", "PLOD1", "AL096840.2", "MFN2", "MIIP", "TNFRSF8", "AL357835.1", "TNFRSF1B", "VPS13D", "LINC02766", "DHRS3", "AC254633.1", "AADACL4", "AADACL3", "C1orf158", "PRAMEF12", "PRAMEF1", "LINC01784", "PRAMEF11", "HNRNPCL1", "PRAMEF2", "PRAMEF4", "PRAMEF10", "PRAMEF7", "PRAMEF6", "PRAMEF27", "HNRNPCL3", "PRAMEF25", "HNRNPCL2", "AC245056.1", "PRAMEF26", "HNRNPCL4", "PRAMEF9", "PRAMEF13", "PRAMEF18", "PRAMEF5", "PRAMEF8", "PRAMEF33", "PRAMEF15", "AC243961.1", "PRAMEF14", "PRAMEF19", "PRAMEF17", "PRAMEF20", "LRRC38", "AL354712.1", "PDPN", "AL359771.1", "PRDM2", "KAZN", "AL357873.1", "KAZN-AS1", "AL031293.1", "TMEM51-AS1", "TMEM51", "C1orf195", "FHAD1", "AL031283.2", "AL031283.3", "AL031283.1", "EFHD2", "CTRC", "CELA2A", "CELA2B", "CASP9", "DNAJC16", "AL121992.3", "AGMAT", "AL121992.1", "DDI2", "RSC1A1", "AL121992.2", "PLEKHM2", "AL450998.3", "SLC25A34", "SLC25A34-AS1", "TMEM82", "FBLIM1", "UQCRHL", "AL450998.2", "SPEN", "ZBTB17", "SRARP", "AL355994.3", "HSPB7", "CLCNKA", "CLCNKB", "FAM131C", "EPHA2", "AL451042.2", "AL451042.1", "ARHGEF19-AS1", "ARHGEF19", "AL109627.1", "CPLANE2", "FBXO42", "SZRD1", "SPATA21", "NECAP2", "LINC01772", "AL137802.2", "AL137802.1", "LINC01783", "NBPF1", "AL137798.1", "AL137798.2", "AL021920.1", "AL021920.3", "CROCC", "BX284668.1", "BX284668.2", "BX284668.5", "BX284668.6", "MFAP2", "AL049569.2", "AL049569.1", "ATP13A2", "SDHB", "PADI2", "LINC02783", "AL590644.1", "PADI1", "PADI3", "PADI4", "PADI6", "RCC2-AS1", "RCC2", "ARHGEF10L", "LINC02810", "ACTL8", "AL357509.1", "LINC01654", "IGSF21", "IGSF21-AS1", "AL591896.1", "KLHDC7A", "PAX7", "TAS1R2", "ALDH4A1", "IFFO2", "AL137127.1", "UBR4", "EMC1-AS1", "EMC1", "MRTO4", "AKR7A3", "AKRLine truncated
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"bos_token": "<|endoftext|>",
|
||||
"eos_token": "<|endoftext|>",
|
||||
"unk_token": "<|endoftext|>"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c24618a1b3e6a38167beff1c72cffd126c3a66254347304b50547d12c5f25624
|
||||
size 2113710
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"add_prefix_space": false,
|
||||
"bos_token": "<|endoftext|>",
|
||||
"eos_token": "<|endoftext|>",
|
||||
"name_or_path": "EleutherAI/gpt-neox-20b",
|
||||
"special_tokens_map_file": "/admin/home-hailey/.cache/huggingface/hub/models--EleutherAI--gpt-neox-20b/snapshots/4e49eadb5d14bd22f314ec3f45b69a87b88c7691/special_tokens_map.json",
|
||||
"tokenizer_class": "GPTNeoXTokenizer",
|
||||
"unk_token": "<|endoftext|>"
|
||||
}
|
||||
Reference in new issue
Block a user