Files changed (1) hide show
  1. README.md +74 -6
README.md CHANGED
@@ -89,18 +89,86 @@ Users should treat this model as an assistant, not a replacement for professiona
89
 
90
  ### Install Required Libraries
91
 
 
 
 
 
 
 
 
 
 
 
 
92
  ```bash
93
- pip install transformers torch optimum
 
 
 
 
 
 
94
  ```
 
 
 
95
 
96
- ```bash
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  from transformers import AutoTokenizer, AutoModelForCausalLM
98
 
99
  model_name = "himel06/DoctorHimel_V1"
100
  tokenizer = AutoTokenizer.from_pretrained(model_name)
101
- model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype="auto")
102
- ```
103
 
 
 
 
 
104
  ```bash
105
  prompt_template = """
106
  Below is a medical question. Please provide a detailed and accurate response based on your knowledge.
@@ -111,7 +179,7 @@ Below is a medical question. Please provide a detailed and accurate response bas
111
  ### Answer:
112
  """
113
  ```
114
-
115
  ```bash
116
  question = """A 61-year-old woman with a long history of involuntary urine loss during activities like coughing or
117
  sneezing but no leakage at night undergoes a gynecological exam and Q-tip test. Based on these findings,
@@ -120,7 +188,7 @@ question = """A 61-year-old woman with a long history of involuntary urine loss
120
  input_text = prompt_template.format(question)
121
 
122
  ```
123
-
124
  ```bash
125
  inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
126
  outputs = model.generate(
 
89
 
90
  ### Install Required Libraries
91
 
92
+ ### for colab
93
+
94
+ 1. Check python version
95
+ ```
96
+ !python --version
97
+ ```
98
+ 2. Clean cache
99
+ ```
100
+ !pip cache purge
101
+ ```
102
+ 3. install dependancy
103
  ```bash
104
+ !pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0
105
+ !pip install transformers accelerate
106
+ !pip install bitsandbytes
107
+ !pip install -U peft
108
+ !pip install huggingface_hub[hf_xet]
109
+ ```
110
+ 4. check torch version
111
  ```
112
+ import torch
113
+ import torchvision
114
+ import torchaudio
115
 
116
+ print(f"Torch version: {torch.__version__}")
117
+ print(f"Torchvision version: {torchvision.__version__}")
118
+ print(f"Torchaudio version: {torchaudio.__version__}")
119
+ ```
120
+ 5. Check if a CUDA device is available
121
+ ```
122
+ import torch
123
+
124
+ print(f"CUDA available: {torch.cuda.is_available()}")
125
+ print(f"CUDA device count: {torch.cuda.device_count()}")
126
+ print(f"Current device: {torch.cuda.current_device()}")
127
+ print(f"Device name: {torch.cuda.get_device_name(0)}" if torch.cuda.is_available() else "No GPU found")
128
+ ```
129
+ 6. Result Shape
130
+ ```
131
+ # Create a tensor and move it to GPU
132
+ tensor = torch.randn(1000, 1000).cuda()
133
+
134
+ # Perform a matrix multiplication on the GPU
135
+ result = torch.matmul(tensor, tensor)
136
+
137
+ print(f"Result shape: {result.shape}")
138
+ ```
139
+ 7. move model to GPU
140
+ ```
141
+ import torch.nn as nn
142
+ import torch.optim as optim
143
+
144
+ # Sample neural network
145
+ model = nn.Sequential(
146
+ nn.Linear(1000, 500),
147
+ nn.ReLU(),
148
+ nn.Linear(500, 10)
149
+ )
150
+
151
+ # Move the model to the GPU
152
+ model = model.cuda()
153
+
154
+ # Sample input data (1000 samples, 1000 features)
155
+ inputs = torch.randn(1000, 1000).cuda()
156
+
157
+ # Forward pass
158
+ output = model(inputs)
159
+ print(output.shape)
160
+ ```
161
+ 8. Load model
162
+ ```
163
  from transformers import AutoTokenizer, AutoModelForCausalLM
164
 
165
  model_name = "himel06/DoctorHimel_V1"
166
  tokenizer = AutoTokenizer.from_pretrained(model_name)
 
 
167
 
168
+ # Load model without adapters or LoRA configuration
169
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype="auto", low_cpu_mem_usage=True)
170
+ ```
171
+ 9. Prompt template
172
  ```bash
173
  prompt_template = """
174
  Below is a medical question. Please provide a detailed and accurate response based on your knowledge.
 
179
  ### Answer:
180
  """
181
  ```
182
+ 10. Question template
183
  ```bash
184
  question = """A 61-year-old woman with a long history of involuntary urine loss during activities like coughing or
185
  sneezing but no leakage at night undergoes a gynecological exam and Q-tip test. Based on these findings,
 
188
  input_text = prompt_template.format(question)
189
 
190
  ```
191
+ 11. Output template
192
  ```bash
193
  inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
194
  outputs = model.generate(