Views
No views yet
Qwen/Qwen3-Embedding-4B
contrastively LoRA-adapted for chest CT / CXR report retrieval. Embedding = left-padding-aware
last-token (EOS) pooling + L2-norm. Embedding dim: 2560.AutoModelmodel.safetensors) and the tokenizer is bundled,
so loading needs no chest2vec package and no download of the base Qwen3-Embedding weights:1from transformers import AutoModel, AutoTokenizer
2model = AutoModel.from_pretrained("chest2vec/chest2vec_4B", trust_remote_code=True).eval()
3tok = AutoTokenizer.from_pretrained("chest2vec/chest2vec_4B", trust_remote_code=True)
4
5docs = ["Bibasilar atelectasis with small bilateral pleural effusions. Cardiomegaly."]
6doc_emb = model.embed_texts(docs, tokenizer=tok) # [N, 2560], L2-normalized
7
8# instruction-conditioned query
9q_emb = model.embed_instruction_query(
10 "Retrieve the chest CT report that is similar to the given report.",
11 ["pleural effusion and cardiomegaly"], tokenizer=tok)
12vals, idx = model.cosine_topk(q_emb, doc_emb, k=5)1emb512 = model.embed_texts(docs, tokenizer=tok, dim=512)
2emb256 = model.embed_texts(docs, tokenizer=tok, dim=256)config.matryoshka_dims). Use the same dim for query and corpus.Instruct: {instruction}\nQuery: {report}). Apply to the query side;
embed the corpus without an instruction. Trained on chest CT and CXR across these families:Retrieve the chest CT report that is similar to the given report. ·
Retrieve the CXR report that is similar to the given report. ·
Retrieve the CXR report that is similar to the given report with prior reference omitted.Summarize the following chest CT report · Summarize the following CXR report · Summarize the given report.Given the following chest CT report, extract the presence/absence of entities · Given the following CXR report, extract the presence/absence of entitiesGiven the following chest CT report, extract the presence/absence of upper-level entities · Given the following CXR report, extract the presence/absence of upper class entitiesFrom the following chest {CT report | X-ray report}, extract and return only the findings related to {REGION}, ignoring all information about other structures.sdpa (use flash_attention_2 on Ampere+ for speed).