transformers safetensors llama text-generation medical conversational en zh dataset:hongzhouyu/FineMed-SFT dataset:hongzhouyu/FineMed-DPO arxiv:2501.09213 base_model:hongzhouyu/FineMedLM base_model:finetune:hongzhouyu/FineMedLM license:mit autotrain_compatible text-generation-inference endpoints_compatible region:us
---
base_model:
- meta-llama/Llama-3.1-8B
- hongzhouyu/FineMedLM
datasets:
- hongzhouyu/FineMed-SFT
- hongzhouyu/FineMed-DPO
language:
- en
- zh
library_name: transformers
license: mit
tags:
- medical
---

<div align="center">
<h1>
  FineMedLM-o1
</h1>
</div>

<div align="center">
<a href="https://github.com/hongzhouyu/FineMed" target="_blank">GitHub</a> | <a href="https://arxiv.org/abs/2501.09213" target="_blank">Paper</a>
</div>

# <span>Introduction</span>
**FineMedLM-o1** is a specialized medical LLM engineered for advanced medical reasoning. It employs a multi-step reasoning process, iteratively reflecting on and refining its thought process before delivering a final response.

For more information, visit our GitHub repository.

# <span>Usage</span>
You can use FineMedLM-o1 in the same way as `Llama-3.1-8B-Instruct`:
```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("hongzhouyu/FineMedLM-o1")
tokenizer = AutoTokenizer.from_pretrained("hongzhouyu/FineMedLM-o1")

prompt = "How do the interactions between neuronal activity, gonadal hormones, and neurotrophins influence axon regeneration post-injury, and what are the potential therapeutic implications of this research? Please think step by step."
messages = [
    {"role": "system", "content": "You are a helpful professional doctor."},
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
model_inputs = tokenizer([text], return_tensors="pt")

generated_ids = model.generate(
    model_inputs.input_ids,
    max_new_tokens=4096
)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]

print(response)
```

FineMedLM-o1 adopts a *slow-thinking* approach, with outputs formatted as:

```
**Thought**
[Reasoning process]

**Summarization**
[Output]
```

# <span>Citation</span>
```
@misc{yu2025finemedlmo1enhancingmedicalreasoning,
    title={FineMedLM-o1: Enhancing the Medical Reasoning Ability of LLM from Supervised Fine-Tuning to Test-Time Training}, 
    author={Hongzhou Yu and Tianhao Cheng and Ying Cheng and Rui Feng},
    year={2025},
    eprint={2501.09213},
    archivePrefix={arXiv},
    primaryClass={cs.CL},
    url={https://arxiv.org/abs/2501.09213}, 
}
```