File size: 9,377 Bytes
5752653 160a336 5752653 160a336 5752653 1d44aa7 160a336 4facfce 5752653 160a336 5752653 4facfce 160a336 5752653 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 4facfce 160a336 1d44aa7 160a336 4facfce 5752653 160a336 5752653 160a336 0adb5e2 160a336 5752653 160a336 5752653 160a336 5752653 160a336 5752653 160a336 5752653 160a336 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
---
license: apache-2.0
language:
- en
library_name: transformers
pipeline_tag: token-classification
tags:
- biology
- chemistry
- medical
- cancer
- carcinogenesis
- biomedical
- ner
- oncology
datasets:
- jimnoneill/CarD-T-NER
metrics:
- accuracy
- precision
- recall
- f1
model-index:
- name: CarD-T
results:
- task:
type: token-classification
name: Named Entity Recognition
dataset:
name: CarD-T-NER
type: jimnoneill/CarD-T-NER
metrics:
- type: precision
value: 0.894
- type: recall
value: 0.857
- type: f1
value: 0.875
---
# CarD-T: Carcinogen Detection via Transformers
## Overview
CarD-T (Carcinogen Detection via Transformers) is a novel text analytics approach that combines transformer-based machine learning with probabilistic statistical analysis to efficiently nominate carcinogens from scientific texts. This model is designed to address the challenges faced by current systems in managing the burgeoning biomedical literature related to carcinogen identification and classification.
## Model Details
* **Architecture**: Based on Bio-ELECTRA, a 335 million parameter language model (sultan/BioM-ELECTRA-Large-SQuAD2)
* **Training Data**: [CarD-T-NER dataset](https://huggingface.co/datasets/jimnoneill/CarD-T-NER) containing 19,975 annotated examples from PubMed abstracts (2000-2024)
* Training set: 11,985 examples
* Test set: 7,990 examples
* **Task**: Named Entity Recognition (NER) for carcinogen identification using BIO tagging
* **Performance**:
* Precision: 0.894
* Recall: 0.857
* F1 Score: 0.875
## Named Entity Labels
The model recognizes 4 entity types using BIO (Beginning-Inside-Outside) tagging scheme, resulting in 9 total labels:
| Label ID | Label | Description |
|----------|-------|-------------|
| 0 | O | Outside any entity |
| 1 | B-carcinogen | Beginning of carcinogen entity |
| 2 | I-carcinogen | Inside carcinogen entity |
| 3 | B-negative | Beginning of negative/exculpatory evidence |
| 4 | I-negative | Inside negative evidence |
| 5 | B-cancertype | Beginning of cancer type/metadata |
| 6 | I-cancertype | Inside cancer type/metadata |
| 7 | B-antineoplastic | Beginning of anti-cancer agent |
| 8 | I-antineoplastic | Inside anti-cancer agent |
### Entity Type Descriptions:
* **carcinogen**: Substances or agents implicated in carcinogenesis
* **negative**: Exculpating evidence for potential carcinogenic entities
* **cancertype**: Metadata including organism (human/animal/cell), cancer type, and affected organs
* **antineoplastic**: Chemotherapy drugs and cancer-protective agents
## Use Cases
* Streamlining toxicogenomic literature reviews
* Identifying potential carcinogens for further investigation
* Augmenting existing carcinogen databases with emerging candidates
* Extracting structured information from cancer research literature
* Supporting evidence-based oncology research
## Limitations
* Identifies potential candidates, not confirmed carcinogens
* Analysis limited to abstract-level information
* May be influenced by publication trends and research focus shifts
* Requires validation by domain experts for clinical applications
## Installation
```bash
pip install transformers torch datasets
```
## Usage
### Basic Usage
```python
from transformers import AutoTokenizer, AutoModelForTokenClassification
import torch
# Load model and tokenizer
model_name = "jimnoneill/CarD-T"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForTokenClassification.from_pretrained(model_name)
# Define label mappings
id2label = {
0: "O",
1: "B-carcinogen",
2: "I-carcinogen",
3: "B-negative",
4: "I-negative",
5: "B-cancertype",
6: "I-cancertype",
7: "B-antineoplastic",
8: "I-antineoplastic"
}
```
### Named Entity Recognition Pipeline
```python
def predict_entities(text):
# Tokenize input
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
# Get predictions
with torch.no_grad():
outputs = model(**inputs)
predictions = outputs.logits.argmax(dim=2)
# Convert tokens and predictions to entities
tokens = tokenizer.convert_ids_to_tokens(inputs.input_ids[0])
entities = []
current_entity = None
current_tokens = []
for token, pred_id in zip(tokens, predictions[0]):
pred_label = id2label[pred_id.item()]
if pred_label == "O":
if current_entity:
entities.append({
"entity": current_entity,
"text": tokenizer.convert_tokens_to_string(current_tokens)
})
current_entity = None
current_tokens = []
elif pred_label.startswith("B-"):
if current_entity:
entities.append({
"entity": current_entity,
"text": tokenizer.convert_tokens_to_string(current_tokens)
})
current_entity = pred_label[2:]
current_tokens = [token]
elif pred_label.startswith("I-") and current_entity:
current_tokens.append(token)
# Don't forget the last entity
if current_entity:
entities.append({
"entity": current_entity,
"text": tokenizer.convert_tokens_to_string(current_tokens)
})
return entities
# Example usage
text = "Benzene exposure has been linked to acute myeloid leukemia, while vitamin D shows antineoplastic properties."
entities = predict_entities(text)
for entity in entities:
print(f"{entity['entity']}: {entity['text']}")
```
### Using with Hugging Face Pipeline
```python
from transformers import pipeline
# Create NER pipeline
ner_pipeline = pipeline(
"token-classification",
model=model_name,
aggregation_strategy="simple"
)
# Analyze text
text = "Studies show asbestos causes mesothelioma in humans, but aspirin may have protective effects."
results = ner_pipeline(text)
# Display results
for entity in results:
print(f"{entity['entity_group']}: {entity['word']} (confidence: {entity['score']:.3f})")
```
### Processing Scientific Abstracts
```python
def analyze_abstract(abstract):
"""Analyze a scientific abstract for cancer-related entities."""
entities = predict_entities(abstract)
# Organize by entity type
results = {
"carcinogens": [],
"protective_agents": [],
"cancer_types": [],
"negative_findings": []
}
for entity in entities:
if entity['entity'] == "carcinogen":
results["carcinogens"].append(entity['text'])
elif entity['entity'] == "antineoplastic":
results["protective_agents"].append(entity['text'])
elif entity['entity'] == "cancertype":
results["cancer_types"].append(entity['text'])
elif entity['entity'] == "negative":
results["negative_findings"].append(entity['text'])
return results
# Example with a scientific abstract
abstract = """
Recent studies in male rats exposed to compound X showed increased incidence of
hepatocellular carcinoma. However, concurrent administration of resveratrol
demonstrated significant protective effects against liver tumor development.
No carcinogenic activity was observed in female mice under similar conditions.
"""
analysis = analyze_abstract(abstract)
print("Analysis Results:")
for category, items in analysis.items():
if items:
print(f"\n{category.replace('_', ' ').title()}:")
for item in items:
print(f" - {item}")
```
## Training Configuration
The model was fine-tuned using the following configuration:
```python
from transformers import TrainingArguments
training_args = TrainingArguments(
output_dir="./card-t-model",
learning_rate=2e-5,
per_device_train_batch_size=16,
per_device_eval_batch_size=16,
num_train_epochs=5,
weight_decay=0.01,
evaluation_strategy="epoch",
save_strategy="epoch",
load_best_model_at_end=True,
metric_for_best_model="f1",
push_to_hub=True,
)
```
If you use this model in your research, please cite:
```bibtex
@article{oneill2024cardt,
title={CarD-T: Interpreting Carcinomic Lexicon via Transformers},
author={O'Neill, Jamey and Reddy, G.A. and Dhillon, N. and Tripathi, O. and Alexandrov, L. and Katira, P.},
journal={MedRxiv},
year={2024},
doi={10.1101/2024.08.13.24311948}
}
```
## License
This model is released under the Apache License 2.0, matching the license of the training dataset.
## Acknowledgments
We thank the biomedical research community for making their findings publicly available through PubMed, enabling the creation of this model. Special thanks to the Bio-ELECTRA team for the base model architecture.
## Contact
For questions, feedback, or collaborations:
- **Author**: Jamey O'Neill
- **Email**: [email protected]
- **Hugging Face**: [@jimnoneill](https://huggingface.co/jimnoneill)
- **Dataset**: [CarD-T-NER](https://huggingface.co/datasets/jimnoneill/CarD-T-NER)
## Disclaimer
This model is intended for research purposes only. It should not be used as a sole source for medical decisions or clinical diagnoses. Always consult with qualified healthcare professionals and validate findings through appropriate experimental methods. |