
TCRT5-FT-TCRDB完整指南从安装到生成CDR3β序列的终极教程【免费下载链接】tcrt5_ft_tcrdb项目地址: https://ai.gitcode.com/hf_mirrors/dkarthikeyan1/tcrt5_ft_tcrdbTCRT5-FT-TCRDB是一款基于T5架构的seq2seq模型专为条件生成T细胞受体TCR序列而设计能够根据目标肽-MHCpMHC生成CDR3β序列。本教程将帮助新手用户快速掌握该模型的安装与使用方法轻松实现CDR3β序列的生成。模型简介TCRT5-FT-TCRDB是什么TCRT5-FT-TCRDB是在T5架构基础上构建的transformers模型 operationalized by the associated HuggingFace abstraction。它基于dkarthikeyan1/tcrt5_pre_tcrdb模型进行微调主要用于在给定pMHC的条件下自动生成CDR3β序列也可用于无条件生成CDR3β序列。该模型在学术研究中具有重要应用价值但不适用于临床环境。快速安装3步完成环境配置步骤1安装Python环境确保你的系统中已安装Python 3.6及以上版本。如果尚未安装可从Python官方网站下载并安装。步骤2安装依赖库使用pip命令安装所需的依赖库包括transformers等pip install transformers步骤3克隆项目仓库通过以下命令克隆项目仓库到本地git clone https://gitcode.com/hf_mirrors/dkarthikeyan1/tcrt5_ft_tcrdb入门指南生成CDR3β序列的2种方法方法1条件生成CDR3β序列条件生成需要提供pMHC作为输入以下是具体步骤和代码示例首先导入必要的库并加载模型和分词器import re from transformers import T5Tokenizer, T5ForConditionalGeneration tokenizer T5Tokenizer.from_pretrained(dkarthikeyan1/tcrt5_ft_tcrdb) tcrt5 T5ForConditionalGeneration.from_pretrained(dkarthikeyan1/tcrt5_ft_tcrdb)然后定义pMHC输入并进行编码pmhc [PMHC]KLGGALQAK[SEP]YFAMYQENVAQTDVDTLYIIYRDYTWAELAYTWY[EOS] encoded_pmhc tokenizer(pmhc, return_tensorspt)接着设置生成参数并生成CDR3β序列num_tcrs 10 # 要生成的TCR数量 num_beams 30 # 探索的beam数量推荐为TCR数量的3倍 outputs tcrt5.generate(**encoded_pmhc, max_new_tokens25, num_return_sequencesnum_tcrs, num_beamsnum_beams, return_dict_in_generateTrue)最后提取并处理生成的CDR3β序列cdr3b_sequences [re.sub(r\[.*\], , x) for x in tokenizer.batch_decode(outputs[sequences], skip_special_tokensTrue)]生成的CDR3β序列示例如下 [CASSLGTGGTDTQYF, CASSPGTGGTDTQYF, CASSLGQGGTEAFF, CASSVGTGGTDTQYF, CASSLGTGGSYEQYF, CASSPGQGGTEAFF, CASSSGTGGTDTQYF, CASSLGGGGTDTQYF, CASSLGGGSYEQYF, CASSLGTGGNQPQHF]方法2无条件生成CDR3β序列无条件生成不需要提供pMHC输入直接生成CDR3β序列代码示例如下导入库并加载模型和分词器同上然后设置生成参数并生成序列num_tcrs 10 num_beams 30 unconditional_outputs tcrt5.generate(max_new_tokens25, num_return_sequencesnum_tcrs, num_beamsnum_beams, return_dict_in_generateTrue) uncond_cdr3b_sequences [re.sub(r\[.*\], , x) for x in tokenizer.batch_decode(unconditional_outputs[sequences], skip_special_tokensTrue)]高级技巧提升生成效果的实用建议选择合适的解码策略对于条件生成使用beam search解码方法可获得较好的性能但序列多样性会有所降低。如果需要生成更多样化的序列可以尝试其他解码策略如ancestral sampling等相关方法可参考HuggingFace生成策略文档和如何生成文档。调整生成参数通过调整num_beams、max_new_tokens等参数可以影响生成序列的质量和数量。一般来说增加num_beams可以提高序列的准确性但会增加计算时间max_new_tokens则控制生成序列的长度。模型局限性与注意事项TCRT5-FT-TCRDB模型存在一些已知的局限性例如其预测倾向于采样高V(D)J重组概率的序列如OLGA计算的结果可以通过使用ancestral sampling等替代解码方法来减轻这种偏差。此外模型未在肽和MHC序列结合亲和力低的情况下进行测试因此在使用时需注意输入pMHC的合理性。训练数据与过程简介训练数据TCRT5在约1400万条来自TCRdb的TCR序列以及约74万条来自IEDB的肽-伪序列对上进行预训练。微调则使用了来自VDJdb、IEDB、McPAS的约33万对TCR:肽-伪序列对以及来自MIRA的半合成示例。训练过程预训练采用了掩码语言建模MLM类似于T5论文中的跨度重建对序列中15%的部分进行掩码然后训练模型重建被掩码的序列。微调则使用规范的交叉熵损失在肽-伪序列-CDR3β的源:目标对上进行。引用与致谢如果在研究中使用了TCRT5-FT-TCRDB模型请引用以下文献Article{Karthikeyan2025_tcrtranslate, author{Karthikeyan, Dhuvarakesh and Bennett, Sarah N. and Reynolds, Amy G. and Vincent, Benjamin G. and Rubinsteyn, Alex}, title{Conditional generation of real antigen-specific T cell receptor sequences}, journal{Nature Machine Intelligence}, year{2025}, month{Sep}, day{08}, abstract{Despite recent advances in T cell receptor (TCR) engineering, designing functional TCRs against arbitrary targets remains challenging due to complex rules governing cross-reactivity and limited paired data. Here we present TCR-TRANSLATE, a sequence-to-sequence framework that adapts low-resource machine translation techniques to generate antigen-specific TCR sequences against unseen epitopes. By evaluating 12 model variants of the BART and T5 model architectures, we identified key factors affecting performance and utility, revealing discordances between these objectives. Our flagship model, TCRT5, outperforms existing approaches on computational benchmarks, prioritizing functionally relevant sequences at higher ranks. Most significantly, we experimentally validated a computationally designed TCR against Wilms tumour antigen, a therapeutically relevant target in leukaemia, excluded from our training and validation sets. Although the identified TCR shows cross-reactivity with pathogen-derived peptides, highlighting limitations in specificity, our work represents the successful computational design of a functional TCR construct against a non-viral epitope from the target sequence alone. Our findings establish a foundation for computational TCR design and reveal current limitations in data availability and methodology, providing a framework for accelerating personalized immunotherapy by reducing the search space for novel targets.}, issn{2522-5839}, doi{10.1038/s42256-025-01096-6}, url{https://doi.org/10.1038/s42256-025-01096-6} }感谢所有为TCRT5模型开发和训练提供数据支持的机构和研究人员。【免费下载链接】tcrt5_ft_tcrdb项目地址: https://ai.gitcode.com/hf_mirrors/dkarthikeyan1/tcrt5_ft_tcrdb创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考