Text Generation
Transformers
Safetensors
English
llama
medical
clinical-reasoning
chain-of-thought
sft
conversational
text-generation-inference
Instructions to use BrainHealthAI/BrainMed-8B-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BrainHealthAI/BrainMed-8B-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BrainHealthAI/BrainMed-8B-SFT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("BrainHealthAI/BrainMed-8B-SFT") model = AutoModelForCausalLM.from_pretrained("BrainHealthAI/BrainMed-8B-SFT", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use BrainHealthAI/BrainMed-8B-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BrainHealthAI/BrainMed-8B-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BrainHealthAI/BrainMed-8B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/BrainHealthAI/BrainMed-8B-SFT
- SGLang
How to use BrainHealthAI/BrainMed-8B-SFT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "BrainHealthAI/BrainMed-8B-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BrainHealthAI/BrainMed-8B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "BrainHealthAI/BrainMed-8B-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BrainHealthAI/BrainMed-8B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use BrainHealthAI/BrainMed-8B-SFT with Docker Model Runner:
docker model run hf.co/BrainHealthAI/BrainMed-8B-SFT
| license: apache-2.0 | |
| base_model: FreedomIntelligence/HuatuoGPT-o1-8B | |
| library_name: transformers | |
| pipeline_tag: text-generation | |
| tags: | |
| - medical | |
| - clinical-reasoning | |
| - chain-of-thought | |
| - sft | |
| language: | |
| - en | |
| # BrainMed-8B-SFT | |
| Full-parameter supervised fine-tune of `FreedomIntelligence/HuatuoGPT-o1-8B` on | |
| [`Williamsanderson/MedReason-MedO1-Reasoning-46K`](https://huggingface.co/datasets/Williamsanderson/MedReason-MedO1-Reasoning-46K), a union of | |
| KG-grounded MedReason reasoning traces and verifier-checked medical-o1 traces. | |
| - **Parameters:** 8,030,261,248 (8.03B) - full weights, not an adapter | |
| - **Precision:** BF16 | |
| - **Recipe:** MedReason (arXiv:2504.00993) - lr 5e-6, effective batch 128, 3 epochs, | |
| cosine schedule with 5% warmup, weight decay 0.1, DeepSpeed ZeRO-3, bf16 | |
| - **Weights obtained by:** lowest held-out validation loss (val loss 0.7557 at optimizer step 1041) | |
| ## Output format | |
| The model is trained to reason inside `<think>...</think>` and answer inside | |
| `<answer>...</answer>`, under this system prompt: | |
| ``` | |
| You are a medical reasoning assistant. Work through the clinical problem step by step inside <think>...</think>, grounding every step in established medical knowledge, then give the final, complete answer inside <answer>...</answer>. | |
| ``` | |
| ## Evaluation | |
| | Benchmark | n | Accuracy | | |
| |---|---|---| | |
| | medbullets_op4 | 308 | 58.77 | | |
| | medbullets_op5 | 308 | 56.82 | | |
| | medmcqa_val | 4183 | 61.2 | | |
| | medqa_4opt | 1273 | 72.11 | | |
| | medxpertqa | 1449 | 18.08 | | |
| | pubmedqa_test | 1000 | 77.1 | | |
| Scored with the MedReason evaluation harness (greedy decoding, strict answer prompt, | |
| `max(head, tail)` extraction) on the benchmark files shipped by the MedReason and | |
| HuatuoGPT-o1 repositories - no benchmark was rebuilt or resampled. | |
| ## Data integrity | |
| Training rows: **44,351**. | |
| Rows overlapping the evaluation benchmarks were **kept**, matching the upstream setting under which the published comparison tables were produced. The overlap was measured and is declared below rather than removed; the evaluation therefore reports a clean-subset score alongside the raw one, and the clean figure is the unbiased estimate. | |
| | Benchmark | items | overlapping training rows | | |
| |---|---|---| | |
| | hle_med | 103 | 30 (29.13%) | | |
| | medbullets_op4 | 308 | 35 (11.36%) | | |
| | medbullets_op5 | 308 | 35 (11.36%) | | |
| | medqa_4opt | 1273 | 1 (0.08%) | | |
| | medqa_5opt | 1273 | 1 (0.08%) | | |
| | medxpertqa | 1449 | 15 (1.04%) | | |
| | mmlu_pro_medical | 1535 | 340 (22.15%) | | |
| This overlap originates upstream: the MedReason corpus derives reasoning traces from MMLU-medical, MedXpertQA and Humanity's Last Exam, three sets it also evaluates on. | |
| Answer-format alignment was applied to 17,083 rows (38.52%): a canonical `The answer is X.` was appended where the letter was unambiguously recoverable from options already present in the question. Questions and reasoning traces are byte-identical to the source. | |
| ## Intended use | |
| Research and decision support. Not a medical device; not for autonomous clinical use. | |
| ## Citation | |
| ```bibtex | |
| @misc{wu2025medreason, | |
| title={MedReason: Eliciting Factual Medical Reasoning Steps in LLMs via Knowledge Graphs}, | |
| author={Wu, Juncheng and others}, year={2025}, eprint={2504.00993}, archivePrefix={arXiv} | |
| } | |
| ``` | |