Feature Extraction
Transformers
Safetensors
chest2vec
text-embeddings
retrieval
radiology
chest
qwen
custom_code
Instructions to use chest2vec/chest2vec_0.6B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chest2vec/chest2vec_0.6B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="chest2vec/chest2vec_0.6B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("chest2vec/chest2vec_0.6B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload configuration_chest2vec.py with huggingface_hub
Browse files- configuration_chest2vec.py +15 -10
configuration_chest2vec.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
-
"""Configuration for Chest2Vec — a
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
Qwen3-Embedding convention.
|
| 7 |
"""
|
|
|
|
| 8 |
from transformers import PretrainedConfig
|
| 9 |
|
| 10 |
|
|
@@ -13,14 +14,18 @@ class Chest2VecConfig(PretrainedConfig):
|
|
| 13 |
|
| 14 |
def __init__(
|
| 15 |
self,
|
|
|
|
| 16 |
base_model: str = "Qwen/Qwen3-Embedding-0.6B",
|
| 17 |
-
|
| 18 |
-
require_flash_attention_2: bool = True,
|
| 19 |
default_max_len: int = 512,
|
|
|
|
|
|
|
| 20 |
**kwargs,
|
| 21 |
):
|
|
|
|
|
|
|
| 22 |
self.base_model = base_model
|
| 23 |
-
self.
|
| 24 |
-
self.require_flash_attention_2 = require_flash_attention_2
|
| 25 |
self.default_max_len = default_max_len
|
| 26 |
-
|
|
|
|
|
|
| 1 |
+
"""Configuration for Chest2Vec — a Qwen3-Embedding model (LoRA merged in) for chest
|
| 2 |
+
radiology report embeddings.
|
| 3 |
|
| 4 |
+
Self-contained: the merged encoder weights ship in the repo, so loading needs neither the
|
| 5 |
+
`chest2vec` package nor a download of the base Qwen3-Embedding weights. Produces a single
|
| 6 |
+
L2-normalized report embedding (last-token / EOS pooling), Qwen3-Embedding convention.
|
| 7 |
"""
|
| 8 |
+
from typing import Optional
|
| 9 |
from transformers import PretrainedConfig
|
| 10 |
|
| 11 |
|
|
|
|
| 14 |
|
| 15 |
def __init__(
|
| 16 |
self,
|
| 17 |
+
encoder_config: Optional[dict] = None,
|
| 18 |
base_model: str = "Qwen/Qwen3-Embedding-0.6B",
|
| 19 |
+
hidden_size: int = 1024,
|
|
|
|
| 20 |
default_max_len: int = 512,
|
| 21 |
+
pooling: str = "last_token",
|
| 22 |
+
matryoshka_dims: Optional[list] = None,
|
| 23 |
**kwargs,
|
| 24 |
):
|
| 25 |
+
super().__init__(**kwargs)
|
| 26 |
+
self.encoder_config = encoder_config or {}
|
| 27 |
self.base_model = base_model
|
| 28 |
+
self.hidden_size = hidden_size
|
|
|
|
| 29 |
self.default_max_len = default_max_len
|
| 30 |
+
self.pooling = pooling
|
| 31 |
+
self.matryoshka_dims = matryoshka_dims or []
|