CodCodingCode commited on
Commit
41d11a7
·
verified ·
1 Parent(s): 356dd3a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -1
README.md CHANGED
@@ -1,14 +1,90 @@
1
  ---
 
 
 
 
 
 
 
2
  base_model: deepseek-ai/DeepSeek-V2-Lite
3
- library_name: peft
4
  ---
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  # Model Card for Model ID
7
 
8
  <!-- Provide a quick summary of what the model is/does. -->
9
 
10
 
11
 
 
12
  ## Model Details
13
 
14
  ### Model Description
 
1
  ---
2
+ library_name: transformers
3
+ pipeline_tag: text-generation
4
+ tags:
5
+ - text-generation
6
+ - medical
7
+ - loRA
8
+ - 4bit
9
  base_model: deepseek-ai/DeepSeek-V2-Lite
 
10
  ---
11
 
12
+ # DeepSeek-V2-medical
13
+
14
+ This repository contains a 4-bit LoRA fine-tuned adapter on top of [deepseek-ai/DeepSeek-V2-Lite](https://huggingface.co/deepseek-ai/DeepSeek-V2-Lite) for medical treatment planning.
15
+
16
+ ## Model Card
17
+
18
+ - **Base model:** `deepseek-ai/DeepSeek-V2-Lite` (4-bit quantized)
19
+ - **Adapter:** LoRA, trained on clinical vignette→treatment pairs
20
+ - **Tokenizer:** same as base, with pad_token set to eos
21
+
22
+ ## Usage
23
+
24
+ ```python
25
+ from transformers import AutoTokenizer, BitsAndBytesConfig
26
+ from peft import PeftModel
27
+ import torch
28
+
29
+ # 1) Load tokenizer + adapter
30
+ tokenizer = AutoTokenizer.from_pretrained(
31
+ "CodCodingCode/DeepSeek-V2-medical", trust_remote_code=True
32
+ )
33
+ tokenizer.pad_token_id = tokenizer.pad_token_id or tokenizer.eos_token_id
34
+
35
+ # 2) Reload quantized base
36
+ bnb = BitsAndBytesConfig(
37
+ load_in_4bit=True,
38
+ bnb_4bit_quant_type="nf4",
39
+ bnb_4bit_compute_dtype=torch.float16,
40
+ )
41
+ base = AutoModelForCausalLM.from_pretrained(
42
+ "deepseek-ai/DeepSeek-V2-Lite",
43
+ quantization_config=bnb,
44
+ device_map="auto",
45
+ trust_remote_code=True,
46
+ )
47
+ base.resize_token_embeddings(len(tokenizer))
48
+
49
+ # 3) Attach LoRA adapter
50
+ model = PeftModel.from_pretrained(
51
+ base,
52
+ "CodCodingCode/DeepSeek-V2-medical",
53
+ device_map="auto",
54
+ trust_remote_code=True,
55
+ )
56
+ model.config.use_cache = False
57
+
58
+ # 4) Generate text
59
+ prompt = (
60
+ "### Instruction:\n"
61
+ "You are a board-certified clinician. Based on the following patient vignette, "
62
+ "suggest a concise treatment plan:\n\n"
63
+ "### Input:\n"
64
+ "A 65-year-old presents with chronic shortness of breath and persistent cough...\n\n"
65
+ "### Response:\n"
66
+ )
67
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
68
+
69
+ outputs = model.generate(
70
+ **inputs,
71
+ max_new_tokens=128,
72
+ do_sample=True,
73
+ top_p=0.9,
74
+ temperature=0.8,
75
+ pad_token_id=tokenizer.pad_token_id,
76
+ eos_token_id=tokenizer.eos_token_id,
77
+ )
78
+
79
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
80
+
81
  # Model Card for Model ID
82
 
83
  <!-- Provide a quick summary of what the model is/does. -->
84
 
85
 
86
 
87
+
88
  ## Model Details
89
 
90
  ### Model Description