Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
| 4 |
+
# PhenoGemini Qwen3-MoE Ranker Model Card
|
| 5 |
+
|
| 6 |
+
## Overview
|
| 7 |
+
|
| 8 |
+
This model ranks candidate disease-causing genes based on a patient’s phenotypic information. During inference, it does not generate a full free-text response. Instead, it performs gene-token subspace ranking on the logits at the final position and outputs a prioritized list of genes.
|
| 9 |
+
|
| 10 |
+
## Prompt Wrapping
|
| 11 |
+
|
| 12 |
+
Use `https://phenogemini.org` to generate a prompt that includes similar patients.
|
| 13 |
+
|
| 14 |
+
## Model Loading
|
| 15 |
+
|
| 16 |
+
```python
|
| 17 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 18 |
+
|
| 19 |
+
model_name = "DISCOStudy/PhenoGemini"
|
| 20 |
+
|
| 21 |
+
# Load tokenizer
|
| 22 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 23 |
+
|
| 24 |
+
# Load base model
|
| 25 |
+
base = AutoModelForCausalLM.from_pretrained(
|
| 26 |
+
model_name,
|
| 27 |
+
torch_dtype="auto",
|
| 28 |
+
device_map="auto",
|
| 29 |
+
trust_remote_code=True
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## Logit Masking (Gene-Token Subspace Ranking)
|
| 35 |
+
|
| 36 |
+
This model does not rank over the full vocabulary. It first masks non-gene tokens, then ranks only within the gene-token subspace:
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
with torch.no_grad():
|
| 40 |
+
prompt = "[PUT THE PROMPT GENERATED FROM https://phenogemini.org]"
|
| 41 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 42 |
+
outputs = model(inputs["input_ids"])
|
| 43 |
+
# Take logits for the last token only
|
| 44 |
+
logits = outputs.logits[0][-1]
|
| 45 |
+
# Mask non-gene tokens
|
| 46 |
+
logits[:151669] = -torch.inf
|
| 47 |
+
# Rank gene tokens by logits
|
| 48 |
+
token_ids = torch.argsort(logits, descending=True)[:8332]
|
| 49 |
+
# Output gene tokens and logits; tokens include Entrez IDs
|
| 50 |
+
tokens = tokenizer.convert_ids_to_tokens(token_ids.tolist())
|
| 51 |
+
scores = logits[token_ids].tolist()
|
| 52 |
+
```
|