Feature Extraction
Transformers
Safetensors
Italian
radgraph_it
radiology
information-extraction
named-entity-recognition
relation-extraction
medical
radgraph
custom_code
Instructions to use radgraphIT/Radgraph-IT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use radgraphIT/Radgraph-IT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="radgraphIT/Radgraph-IT", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("radgraphIT/Radgraph-IT", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 920 Bytes
0c48771 | 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 | """Run a trained model on a document and get back decoded predictions.
Port of the one thing `radgraph.dygie.predictors.dygie.DyGIEPredictor` did that this project
actually used: forward pass -> `PredictedNER` / `PredictedRelation` objects, in document
(here: sentence, since there's always exactly one) coordinates.
"""
import torch
from .dataset import Example, build_example
from .document import Document
from .model import DyGIEModel
from .vocab import Vocabulary
@torch.no_grad()
def predict_document(model: DyGIEModel, vocab: Vocabulary, doc: Document, max_span_width: int) -> dict:
model.eval()
example: Example = build_example(doc, vocab, max_span_width)
output = model(example)
return {
"doc_key": doc.doc_key,
"example": example,
"predicted_ner": output["ner"].get("predictions", []),
"predicted_relations": output["relation"].get("predictions", []),
}
|