Text Classification
Transformers
Safetensors
English
manta
feature-extraction
medical
decision-model
classification
calibration
multimodal
vision
radiology
pathology
clinical-text
custom_code
Instructions to use gevaertlab/MANTA-27B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gevaertlab/MANTA-27B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="gevaertlab/MANTA-27B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("gevaertlab/MANTA-27B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,762 Bytes
38aa02e | 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 | """Answer the example requests with MANTA-27B (one GPU with about 60 GB).
python example.py # examples/text_request.json and image_request.json
python example.py --request my_request.json
Prints, per question, the option probabilities (most probable first) and the answer.
"""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
def main(argv=None) -> int:
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--request", nargs="*", type=Path,
default=[HERE / "examples" / "text_request.json", HERE / "examples" / "image_request.json"])
ap.add_argument("--release", default=str(HERE), help="the release folder or its Hub repository id")
ap.add_argument("--device", default="cuda")
ap.add_argument("--option-order", default="eval", choices=("eval", "given", "sorted"))
args = ap.parse_args(argv)
from manta import Manta
model = Manta.from_pretrained(args.release, device=args.device)
for path in args.request:
request = json.loads(path.read_text())
result = model.predict(request, option_order=args.option_order)
print(f"\n{path.name} ({result['prompt_tokens']} prompt tokens)")
for qid, answer in result["questions"].items():
ranked = sorted(answer["probabilities"].items(), key=lambda kv: -kv[1])
shown = ", ".join(f"{option} {p:.3f}" for option, p in ranked)
print(f" {qid} ({answer['type']}): answer {answer['answer']} | {shown}")
return 0
if __name__ == "__main__":
sys.exit(main())
|