Instructions to use aehrc/cxrmate-rrg24 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aehrc/cxrmate-rrg24 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="aehrc/cxrmate-rrg24", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("aehrc/cxrmate-rrg24", trust_remote_code=True) model = AutoModel.from_pretrained("aehrc/cxrmate-rrg24", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload model
Browse files- modelling_cxrrg.py +3 -3
modelling_cxrrg.py
CHANGED
|
@@ -317,7 +317,7 @@ class CXRRGModel(VisionEncoderDecoderModel):
|
|
| 317 |
)
|
| 318 |
])
|
| 319 |
|
| 320 |
-
token_type_ids[ids[:, 0], ids[:, 1]] = self.config.section_ids[i + 1]
|
| 321 |
|
| 322 |
return token_type_ids
|
| 323 |
|
|
@@ -333,7 +333,7 @@ class CXRRGModel(VisionEncoderDecoderModel):
|
|
| 333 |
token_type_ids - token type identifiers.
|
| 334 |
"""
|
| 335 |
|
| 336 |
-
token_type_ids = torch.full([token_ids.shape[0], 1], self.config.section_ids[0], dtype=torch.long, device=token_ids.device)
|
| 337 |
|
| 338 |
# https://huggingface.co/docs/transformers/model_doc/bert#transformers.BertTokenizer.create_token_type_ids_from_sequences.example
|
| 339 |
token_ids = token_ids[:, :-1]
|
|
@@ -342,7 +342,7 @@ class CXRRGModel(VisionEncoderDecoderModel):
|
|
| 342 |
|
| 343 |
# Find first occurrence of special token, which indicates the boundary between sections:
|
| 344 |
exists = torch.any(token_ids == j, dim=1, keepdim=True)
|
| 345 |
-
token_type_ids[exists] = self.config.section_ids[i + 1]
|
| 346 |
|
| 347 |
return token_type_ids
|
| 348 |
|
|
|
|
| 317 |
)
|
| 318 |
])
|
| 319 |
|
| 320 |
+
token_type_ids[ids[:, 0], ids[:, 1]] = self.config.decoder.section_ids[i + 1]
|
| 321 |
|
| 322 |
return token_type_ids
|
| 323 |
|
|
|
|
| 333 |
token_type_ids - token type identifiers.
|
| 334 |
"""
|
| 335 |
|
| 336 |
+
token_type_ids = torch.full([token_ids.shape[0], 1], self.config.decoder.section_ids[0], dtype=torch.long, device=token_ids.device)
|
| 337 |
|
| 338 |
# https://huggingface.co/docs/transformers/model_doc/bert#transformers.BertTokenizer.create_token_type_ids_from_sequences.example
|
| 339 |
token_ids = token_ids[:, :-1]
|
|
|
|
| 342 |
|
| 343 |
# Find first occurrence of special token, which indicates the boundary between sections:
|
| 344 |
exists = torch.any(token_ids == j, dim=1, keepdim=True)
|
| 345 |
+
token_type_ids[exists] = self.config.decoder.section_ids[i + 1]
|
| 346 |
|
| 347 |
return token_type_ids
|
| 348 |
|