1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
34model_name ="TanitAI/TANIT-Med-8B-v1"56tokenizer = AutoTokenizer.from_pretrained(model_name)7model = AutoModelForCausalLM.from_pretrained(8 model_name,9 torch_dtype=torch.bfloat16,10 device_map="auto",11 trust_remote_code=True12)1314# Medical question15question ="""A 45-year-old male presents with sudden onset chest pain radiating to
16the left arm, diaphoresis, and shortness of breath. ECG shows ST elevation in
17leads V1-V4. What is the most likely diagnosis and immediate management?"""1819messages =[20{"role":"user","content": question}21]2223# Apply chat template24input_text = tokenizer.apply_chat_template(25 messages,26 tokenize=False,27 add_generation_prompt=True28)2930inputs = tokenizer(input_text, return_tensors="pt").to(model.device)3132# Generate response33with torch.no_grad():34 outputs = model.generate(35**inputs,36 max_new_tokens=2048,37 temperature=0.6,38 top_p=0.95,39 do_sample=True40)4142response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)43print(response)
Using with vLLM (Recommended for Production)
python
1from vllm import LLM, SamplingParams
23model_name ="TanitAI/TANIT-Med-8B-v1"45llm = LLM(6 model=model_name,7 dtype="bfloat16",8 tensor_parallel_size=1,# Adjust based on your GPU setup9 trust_remote_code=True,10 max_model_len=819211)1213sampling_params = SamplingParams(14 temperature=0.6,15 top_p=0.95,16 max_tokens=204817)1819question ="What are the diagnostic criteria for Type 2 Diabetes Mellitus?"2021# Format with chat template22prompt =f"<|im_start|>user\n{question}<|im_end|>\n<|im_start|>assistant\n"2324outputs = llm.generate([prompt], sampling_params)25print(outputs[0].outputs[0].text)
Using via API (Without Loading Model)
For team members who need access without loading the model locally, use the HuggingFace Inference API:
python
1import requests
23API_URL ="https://api-inference.huggingface.co/models/TanitAI/TANIT-Med-8B-v1"4headers ={"Authorization":"Bearer YOUR_HF_TOKEN"}56defquery(payload):7 response = requests.post(API_URL, headers=headers, json=payload)8return response.json()910# Example query11output = query({12"inputs":"What is the first-line treatment for hypertension?",13"parameters":{14"max_new_tokens":1024,15"temperature":0.616}17})18print(output)
Accessing via HuggingFace Hub
python
1from huggingface_hub import InferenceClient
23client = InferenceClient(4 model="TanitAI/TANIT-Med-8B-v1",5 token="YOUR_HF_TOKEN"6)78response = client.text_generation(9"Explain the pathophysiology of heart failure.",10 max_new_tokens=1024,11 temperature=0.612)13print(response)
📊 Evaluation Results
Benchmark
Test
Test Hard
Average
50.7%
20.3%
MedQA
65.0%
32.0%
PubMedQA
68.0%
21.0%
MedMCQA
57.8%
32.0%
MMLU (Medical)
77.5%
26.0%
MMLU-Pro (Health)
47.3%
22.0%
MedExQA
73.3%
15.0%
MedBullets
42.9%
15.7%
AfriMedQA
48.9%
18.8%
MedXpertQA-R
12.1%
11.0%
MedXpertQA-U
14.6%
9.0%
Evaluated using zero-shot prompting with chain-of-thought reasoning.
📋 Training Details
Parameter
Value
Base Model
deepseek-ai/DeepSeek-R1-0528-Qwen3-8B
Training Phase
Final (v1.0)
Training Data
22K high-quality samples from Medical-R1-Distill (DeepSeek-R1 distillation)
Training Steps
687
Training Time
0.8 hours
Final Loss
0.828
Precision
bfloat16
Context Length
8,192 tokens
⚠️ Limitations & Intended Use
Intended Use
Medical education and research
Clinical decision support (with physician oversight)
Medical question answering
Healthcare documentation assistance
Limitations
Not a replacement for professional medical advice
May generate plausible-sounding but incorrect information
Performance varies across medical specialties
Should always be used with human oversight in clinical settings
Ethical Considerations
This model is intended to assist, not replace, healthcare professionals
Always verify medical information with authoritative sources
Do not use for diagnosis or treatment without professional consultation