Pythia 160m C2s
這是一個基於Pythia-160m語言模型,使用Cell2Sentence方法在單細胞RNA測序數據上微調的模型,能夠進行條件性細胞生成、無條件細胞生成和細胞類型預測。
下載量 64
發布時間 : 2/14/2024
模型概述
該模型將單細胞RNA測序數據轉化為按表達水平排序的基因名稱序列(稱為'細胞句子'),利用大型語言模型處理單細胞轉錄組學數據。
模型特點
Cell2Sentence方法
創新性地將單細胞RNA測序數據轉化為基因名稱序列,使語言模型能夠處理轉錄組數據
多任務能力
支持條件性細胞生成、無條件細胞生成和細胞類型預測三種主要任務
高性能表現
在k近鄰分類和Gromov-Wasserstein距離評估中優於同類模型
模型能力
單細胞轉錄組數據分析
條件性細胞生成
無條件細胞生成
細胞類型預測
使用案例
生物醫學研究
免疫細胞分析
基於免疫組織數據集生成特定類型的免疫細胞表達譜
可用於研究免疫細胞的特異性和功能
細胞類型識別
根據基因表達模式預測未知細胞的類型
在測試數據上表現出優於其他方法的分類性能
藥物開發
虛擬細胞生成
生成特定條件下的虛擬細胞表達數據
可用於藥物篩選和效果預測
🚀 Pythia-160m-c2s模型
這是由EleutherAI開發的Pythia-160m模型,使用Cell2Sentence方法在完整的單細胞RNA測序(scRNA-seq)細胞上進行了微調。Cell2Sentence是一種將大語言模型應用於單細胞轉錄組學的新方法。我們將單細胞RNA測序數據轉換為由表達水平排序的基因名稱序列,稱為“細胞句子”。更多詳細信息,請參考下面鏈接的論文。該模型在來自Domínguez等人的免疫組織數據集上進行訓練,使用8塊A100 40GB GPU,耗時約20小時,完成以下任務:
- 條件細胞生成
- 無條件細胞生成
- 細胞類型預測
🚀 快速開始
本模型是基於Pythia-160m模型,利用Cell2Sentence方法在完整的scRNA-seq細胞上微調得到。Cell2Sentence能將單細胞轉錄組數據轉化為“細胞句子”,便於大語言模型處理。
✨ 主要特性
- 創新方法應用:採用Cell2Sentence方法,將單細胞RNA測序數據轉換為基因名稱序列,適配大語言模型處理單細胞轉錄組學。
- 多任務訓練:在條件細胞生成、無條件細胞生成和細胞類型預測等任務上進行訓練。
- 高性能表現:在KNN分類和Gromov - Wasserstein(GW)距離評估中表現出色。
📦 安裝指南
文檔未提供安裝步驟,此處跳過。
💻 使用示例
基礎用法
我們提供了一個如何使用該模型進行條件細胞生成的示例,其中包含一個後處理函數,用於去除重複和無效的基因。為了生成完整的細胞,需要將max_length
生成參數更改為9200。不過,如果需要生成完整細胞,建議使用A100 GPU以保證推理速度和內存容量。
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)
高級用法
文檔未提及高級用法相關內容,此處跳過。
📚 詳細文檔
評估指標
本模型在KNN分類和Gromov - Wasserstein(GW)距離上進行了評估。生成細胞的標籤是其生成提示中對應的細胞類型。真實細胞是從保留的測試數據集中有放回採樣得到的。生成的細胞使用論文中描述的方法轉換為表達向量。完整的實驗細節請參考論文。
模型 | 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 |
相關鏈接
Cell2Sentence鏈接:
- GitHub: https://github.com/vandijklab/cell2sentence-ft
- 論文: https://www.biorxiv.org/content/10.1101/2023.09.11.557287v3
Pythia鏈接:
- GitHub: https://github.com/EleutherAI/pythia
- 論文: https://arxiv.org/abs/2304.01373
- Hugging Face: https://huggingface.co/EleutherAI/pythia-160m
🔧 技術細節
文檔未提供足夠的技術實現細節,此處跳過。
📄 許可證
本項目採用CC BY - NC - ND 4.0許可證。
Chemberta Zinc Base V1
基於RoBERTa架構的Transformer模型,專為化學SMILES字符串的掩碼語言建模任務設計
分子模型
C
seyonec
323.83k
48
Molformer XL Both 10pct
Apache-2.0
MoLFormer是基於ZINC和PubChem中11億分子SMILES字符串預訓練的化學語言模型,本版本使用兩個數據集各10%樣本訓練
分子模型
Transformers

M
ibm-research
171.96k
19
Evo 1 8k Base
Apache-2.0
Evo是一個能夠進行長上下文建模和設計的生物基礎模型,使用StripedHyena架構,能以單核苷酸、字節級分辨率對序列進行建模。
分子模型
Transformers

E
togethercomputer
31.09k
9
Evo 1 131k Base
Apache-2.0
Evo是一款能夠進行長上下文建模與設計的生物基礎模型,採用條紋鬣狗架構,可在單核苷酸字節級分辨率下建模序列。
分子模型
Transformers

E
togethercomputer
22.70k
108
Materials.smi Ted
Apache-2.0
IBM提出的化學語言基礎模型,支持分子表示轉換與量子屬性預測等多種任務
分子模型
Transformers

M
ibm-research
20.65k
27
Tabpfn V2 Clf
TabPFN是一款基於Transformer架構的表格數據基礎模型,通過先驗數據學習機制,能夠在無需任務特定訓練的情況下,在小規模表格數據集上實現卓越性能。
分子模型
T
Prior-Labs
20.09k
33
Tabpfn Mix 1.0 Classifier
Apache-2.0
基於表格數據的基礎模型,預訓練數據來自隨機分類器混合生成的合成數據集
分子模型
Safetensors
T
autogluon
19.77k
13
Nucleotide Transformer V2 50m Multi Species
核苷酸變換器是一組基於全基因組DNA序列進行預訓練的基礎語言模型,整合了3200多個人類基因組和850個廣泛物種的基因組數據。
分子模型
Transformers

N
InstaDeepAI
18.72k
3
Multitask Text And Chemistry T5 Base Augm
MIT
一個多領域、多任務的語言模型,旨在解決化學與自然語言領域的廣泛任務。
分子模型
Transformers 英語

M
GT4SD
11.01k
8
Rnaernie
RNAErnie是一個基於非編碼RNA序列進行自監督預訓練的模型,採用多階段掩碼語言建模目標,為RNA研究提供強大的特徵表示能力。
分子模型
PyTorch
R
multimolecule
11.00k
1
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98