my2000cup commited on
Commit
bb9eeee
·
1 Parent(s): 5cdb6dc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +48 -3
README.md CHANGED
@@ -68,9 +68,54 @@ library_name: peft
68
  Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
  ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  [More Information Needed]
75
 
76
  ## Training Details
 
68
  Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
  ## How to Get Started with the Model
71
+ ```python
72
+ import torch
73
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
74
+ from peft import PeftModel
75
+
76
+ # Load the base model and tokenizer
77
+ base_model_id = "deepseek-ai/deepseek-r1-distill-qwen-7b"
78
+ tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
79
+ tokenizer.pad_token = tokenizer.eos_token
80
+
81
+ # Load the base model
82
+ base_model = AutoModelForCausalLM.from_pretrained(
83
+ base_model_id,
84
+ device_map="auto",
85
+ trust_remote_code=True,
86
+ torch_dtype=torch.float16
87
+ )
88
+
89
+ # Load the fine-tuned LoRA adapter
90
+ adapter_path = "your-username/deepseek-medical-reasoner" # Replace with actual model path
91
+ model = PeftModel.from_pretrained(
92
+ base_model,
93
+ adapter_path,
94
+ torch_dtype=torch.float16,
95
+ device_map="auto"
96
+ )
97
+
98
+ # Create a text generation pipeline
99
+ pipe = pipeline(
100
+ "text-generation",
101
+ model=model,
102
+ tokenizer=tokenizer,
103
+ max_new_tokens=512,
104
+ temperature=0.6,
105
+ top_p=0.95,
106
+ repetition_penalty=1.15
107
+ )
108
+
109
+ # Example usage
110
+ prompt = """Please reason step by step:
111
+
112
+ A 45-year-old patient presents with sudden onset chest pain, shortness of breath, and anxiety.
113
+ The pain is described as sharp and worsens with deep breathing.
114
+ What is the most likely diagnosis and what immediate tests should be ordered?"""
115
+
116
+ result = pipe(prompt)
117
+ print(result[0]["generated_text"])
118
+ ```
119
  [More Information Needed]
120
 
121
  ## Training Details