# gtCLIP — Gene-set Text CLIP A CLIP-style model that aligns gene set embeddings (via [GSFM](https://huggingface.co/maayanlab/gsfm)) with biomedical text embeddings (via [S-PubMedBert-MS-MARCO](https://huggingface.co/pritamdeka/S-PubMedBert-MS-MARCO)) in a shared latent space. ## Quick Start ```bash GIT_LFS_SKIP_SMUDGE=1 pip install git+https://huggingface.co/maayanlab/gsfm pip install sentence-transformers huggingface_hub ``` ```python from huggingface_hub import hf_hub_download import importlib.util py_path = hf_hub_download("DaveLab/gtCLIP", "gtCLIP.py") spec = importlib.util.spec_from_file_location("gtCLIP", py_path) mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) GeneSetTextEncoder = mod.GeneSetTextEncoder model = GeneSetTextEncoder.from_pretrained("DaveLab/gtCLIP", device="cuda") # Encode a gene set gene_emb = model.encode_gene_symbols(["TP53", "BRCA1", "MYC", "CDK2"]) # Encode a text description text_emb = model.encode_text_normalized(["DNA damage repair pathway"]) # Compute similarity similarity = (gene_emb @ text_emb.T).item() print(f"Similarity: {similarity:.4f}") ``` ## Files | File | Description | |------|-------------| | `gtCLIP.py` | Model class definition | | `gtCLIP.pt` | Trained weights + config | | `config.json` | Architecture hyperparameters | ## Architecture - **Gene encoder**: GSFM (frozen or partially fine-tuned) → projection MLP → shared space - **Text encoder**: PubMedBERT (frozen or partially fine-tuned) → projection MLP → shared space - **Training**: Contrastive CLIP loss with gene-set overlap soft targets + reconstruction auxiliary loss