File size: 1,597 Bytes
aed569b
7b9b676
 
 
aed569b
 
7b9b676
 
 
 
 
 
 
 
83fc95d
aed569b
 
 
 
 
7b9b676
aed569b
 
 
 
 
 
 
 
 
7b9b676
 
aed569b
 
 
 
7b9b676
 
aed569b
 
 
 
 
 
 
 
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
46
---
license: apache-2.0
library_name: transformers
pipeline_tag: question-answering
---

# MedCEG: Reinforcing Verifiable Medical Reasoning with Critical Evidence Graph

This repository contains the MedCEG model, presented in the paper [MedCEG: Reinforcing Verifiable Medical Reasoning with Critical Evidence Graph](https://huggingface.co/papers/2512.13510).

**MedCEG** is a framework that augments medical language models with clinically valid reasoning pathways. It explicitly supervises the reasoning process through a **Critical Evidence Graph (CEG)**, ensuring verifiable and logical medical deductions.

For code and more details, see the [GitHub repository](https://github.com/LinjieMu/MedCEG).

This code demonstrates how to generate responses using MedCEG.
```python
import transformers
import torch

# 1. Load Model & Tokenizer
model_id = "LinjieMu/MedCEG"
tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
model = transformers.AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)

# 2. Define Input
question = "A 78-year-old Caucasian woman presented with..."
suffix = "
Put your final answer in \\boxed{}."
messages = [{"role": "user", "content": question + suffix}]

# 3. Generate
input_ids = tokenizer.apply_chat_template(
    messages,
    add_generation_prompt=True,
    return_tensors="pt"
).to(model.device)

outputs = model.generate(input_ids, max_new_tokens=8196, do_sample=False)
decoded_response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)

print(decoded_response)
```