basiphobe commited on
Commit
885e730
·
verified ·
1 Parent(s): ec774f2

Restore comprehensive README with both usage options and YAML metadata

Browse files
Files changed (1) hide show
  1. README.md +339 -44
README.md CHANGED
@@ -26,27 +26,25 @@ model-index:
26
  results: []
27
  ---
28
 
29
- # SCI Assistant 7B
30
 
31
- A specialized language model for spinal cord injury (SCI) information and support, based on OpenHermes-2.5-Mistral-7B with custom LoRA fine-tuning.
32
 
33
  ## Model Description
34
 
35
- This model has been fine-tuned specifically to provide accurate, helpful information about spinal cord injuries, including:
 
 
36
 
37
- - **Medical information** about SCI conditions and symptoms
38
- - **Practical advice** for daily living with SCI
39
- - **Equipment recommendations** for wheelchairs, adaptive technology, etc.
40
- - **Exercise and rehabilitation** guidance
41
- - **Emotional support** and community resources
42
 
43
- ## Training Data
44
 
45
- The model was trained on curated SCI-related content including:
46
- - Medical literature and research papers
47
- - Patient education materials
48
- - Community forums and discussions
49
- - Rehabilitation guides and resources
50
 
51
  ## Usage
52
 
@@ -68,54 +66,351 @@ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
68
 
69
  ### Option 2: Use the LoRA Adapter (Smaller Download)
70
  ```python
71
- from transformers import AutoModelForCausalLM, AutoTokenizer
72
  from peft import PeftModel
 
 
 
 
 
 
 
73
 
74
- # Load base model
75
- base_model = AutoModelForCausalLM.from_pretrained("teknium/OpenHermes-2.5-Mistral-7B")
76
- tokenizer = AutoTokenizer.from_pretrained("teknium/OpenHermes-2.5-Mistral-7B")
 
 
77
 
78
- # Load LoRA adapter
79
  model = PeftModel.from_pretrained(base_model, "basiphobe/sci-assistant")
 
80
 
81
- # Example usage
82
- prompt = "What are the signs of autonomic dysreflexia?"
 
 
 
 
83
  inputs = tokenizer(prompt, return_tensors="pt")
84
- outputs = model.generate(**inputs, max_length=200)
85
- response = tokenizer.decode(outputs[0], skip_special_tokens=True)
86
  ```
87
 
 
 
 
 
 
 
88
  ## Intended Use
89
 
90
- - **Educational purposes** - Learning about SCI conditions and management
91
- - **Community support** - Providing accessible information to SCI community
92
- - **Research** - Supporting SCI-related research and development
 
 
93
 
94
  ## Limitations
95
 
96
- - This model provides educational information only
97
- - Always consult healthcare professionals for medical advice
98
- - Not a replacement for professional medical care
99
- - May not reflect the most recent medical developments
100
 
101
- ## Files in this Repository
102
 
103
- - **Full Merged Model**: Ready-to-use model files (`model-*.safetensors`, `config.json`, etc.)
104
- - **LoRA Adapter**: Smaller adapter files (`adapter_model.safetensors`, `adapter_config.json`)
105
- - **Tokenizer**: Shared tokenizer files for both options
 
 
106
 
107
- ## Technical Details
108
 
109
- - **Base Model**: teknium/OpenHermes-2.5-Mistral-7B
110
- - **Fine-tuning**: LoRA (Low-Rank Adaptation)
111
- - **Parameters**: ~7 billion
112
- - **Precision**: FP16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
- ## License
 
 
 
115
 
116
- Please respect the original OpenHermes-2.5 license terms.
117
 
118
- ## Acknowledgments
119
 
120
- Built on the excellent OpenHermes-2.5-Mistral-7B model by Teknium.
121
- Training data curated from publicly available SCI educational resources.
 
26
  results: []
27
  ---
28
 
29
+ # SCI Assistant - Spinal Cord Injury Specialized AI Assistant
30
 
31
+ A specialized AI assistant fine-tuned specifically for people with spinal cord injuries (SCI). This model is based on OpenHermes-2.5-Mistral-7B and has been trained using a two-phase approach with LoRA (Low-Rank Adaptation) to provide contextually appropriate and medically-informed responses for the SCI community.
32
 
33
  ## Model Description
34
 
35
+ This model was fine-tuned using a two-phase training approach:
36
+ 1. **Phase 1**: Domain pretraining on SCI-related medical texts and resources
37
+ 2. **Phase 2**: Instruction tuning on conversational SCI-focused Q&A pairs
38
 
39
+ The model understands the unique challenges, medical realities, and daily life considerations of individuals living with spinal cord injuries.
 
 
 
 
40
 
41
+ ## Training Details
42
 
43
+ - **Base Model**: teknium/OpenHermes-2.5-Mistral-7B
44
+ - **Training Method**: QLoRA (4-bit quantization with LoRA adapters)
45
+ - **Training Data**: 119,117 total entries (35,779 domain text + 83,337 instruction pairs)
46
+ - **Hardware**: RTX 4070 Super (8GB VRAM)
47
+ - **Training Time**: ~20 hours total (Phase 1 + Phase 2)
48
 
49
  ## Usage
50
 
 
66
 
67
  ### Option 2: Use the LoRA Adapter (Smaller Download)
68
  ```python
69
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
70
  from peft import PeftModel
71
+ import torch
72
+
73
+ # Load model
74
+ bnb_config = BitsAndBytesConfig(
75
+ load_in_4bit=True,
76
+ bnb_4bit_compute_dtype=torch.float16,
77
+ )
78
 
79
+ base_model = AutoModelForCausalLM.from_pretrained(
80
+ "teknium/OpenHermes-2.5-Mistral-7B",
81
+ quantization_config=bnb_config,
82
+ device_map="auto"
83
+ )
84
 
 
85
  model = PeftModel.from_pretrained(base_model, "basiphobe/sci-assistant")
86
+ tokenizer = AutoTokenizer.from_pretrained("basiphobe/sci-assistant")
87
 
88
+ # Format prompt with SCI context
89
+ system_context = "You are a specialized medical assistant for people with spinal cord injuries. Your responses should always consider the unique needs, challenges, and medical realities of individuals living with SCI."
90
+
91
+ prompt = f"{system_context}\n\n### Instruction:\n{your_question}\n\n### Response:\n"
92
+
93
+ # Generate response
94
  inputs = tokenizer(prompt, return_tensors="pt")
95
+ outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7)
96
+ response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
97
  ```
98
 
99
+ ## Files in this Repository
100
+
101
+ - **Full Merged Model**: Ready-to-use model files (`model-*.safetensors`, `config.json`, etc.)
102
+ - **LoRA Adapter**: Smaller adapter files (`adapter_model.safetensors`, `adapter_config.json`)
103
+ - **Tokenizer**: Shared tokenizer files for both options
104
+
105
  ## Intended Use
106
 
107
+ This model is designed to:
108
+ - Provide SCI-specific information and guidance
109
+ - Answer questions about daily life with spinal cord injuries
110
+ - Offer practical advice for common SCI challenges
111
+ - Support the SCI community with contextually appropriate responses
112
 
113
  ## Limitations
114
 
115
+ - This model is for informational purposes only and should not replace professional medical advice
116
+ - Always consult with healthcare providers for medical decisions
117
+ - The model may not have information about the latest medical developments
118
+ - Responses should be verified with medical professionals when making health-related decisions
119
 
120
+ ## Direct Use
121
 
122
+ This model can be used directly for:
123
+ - Educational purposes about spinal cord injuries
124
+ - Providing general information and support to the SCI community
125
+ - Research into specialized medical AI assistants
126
+ - Personal use by individuals seeking SCI-related information
127
 
128
+ The model is designed to provide contextually appropriate responses that consider the unique challenges and medical realities of spinal cord injuries.
129
 
130
+ ### Downstream Use
131
+
132
+ This model can be fine-tuned further for:
133
+ - Integration into healthcare applications
134
+ - Specialized medical chatbots for rehabilitation centers
135
+ - Educational platforms for SCI awareness and training
136
+ - Research applications in medical AI
137
+ - Custom applications for SCI support organizations
138
+
139
+ When used in downstream applications, implementers should:
140
+ - Maintain the medical disclaimer requirements
141
+ - Ensure proper supervision by medical professionals
142
+ - Implement appropriate safety measures and content filtering
143
+ - Validate outputs for medical accuracy in their specific use case
144
+
145
+ ### Out-of-Scope Use
146
+
147
+ This model should NOT be used for:
148
+ - **Medical diagnosis or treatment decisions** - Always consult healthcare professionals
149
+ - **Emergency medical situations** - Seek immediate professional medical help
150
+ - **Legal or financial advice** related to SCI cases
151
+ - **Replacement for professional medical consultation**
152
+ - **Clinical decision-making** without physician oversight
153
+ - **Applications targeting vulnerable populations** without proper safeguards
154
+ - **Commercial medical applications** without appropriate medical validation and oversight
155
+
156
+ ## Bias, Risks, and Limitations
157
+
158
+ ### Medical Limitations
159
+ - **Not a substitute for medical professionals**: All medical advice should be verified with qualified healthcare providers
160
+ - **Training data limitations**: May not include the most recent medical research or treatments
161
+ - **Individual variation**: SCI affects individuals differently; responses may not apply to all cases
162
+ - **Geographic bias**: Training data may be biased toward certain healthcare systems or regions
163
+
164
+ ### Technical Limitations
165
+ - **Hallucination risk**: Like all language models, may generate plausible-sounding but incorrect information
166
+ - **Context limitations**: Limited by input context window and may not retain information across long conversations
167
+ - **Language limitations**: Primarily trained on English content
168
+ - **Update lag**: Cannot access real-time medical research or current events
169
+
170
+ ### Bias Considerations
171
+ - **Training data bias**: Reflects biases present in source medical literature and online content
172
+ - **Demographic representation**: May not equally represent all demographics within the SCI community
173
+ - **Healthcare access bias**: May reflect biases toward certain types of healthcare systems
174
+ - **Severity bias**: May be more informed about certain types or severities of SCI
175
+
176
+ ### Risk Mitigation
177
+ - Always include medical disclaimers when using this model
178
+ - Implement content filtering for harmful or dangerous advice
179
+ - Regular evaluation by medical professionals is recommended
180
+ - Monitor outputs for accuracy and appropriateness
181
+
182
+ ## Recommendations
183
+
184
+ Users should be aware of the following recommendations:
185
+
186
+ **For Direct Users:**
187
+ - Always verify medical information with qualified healthcare professionals
188
+ - Use responses as educational/informational starting points, not definitive advice
189
+ - Be aware that individual SCI experiences vary significantly
190
+ - Seek immediate professional help for urgent medical concerns
191
+
192
+ **For Developers/Implementers:**
193
+ - Implement clear medical disclaimers in any application using this model
194
+ - Provide easy access to professional medical resources alongside model responses
195
+ - Consider implementing content filtering for potentially harmful advice
196
+ - Regular review by medical professionals is strongly recommended
197
+ - Ensure compliance with relevant healthcare regulations (HIPAA, etc.)
198
+
199
+ **For Healthcare Organizations:**
200
+ - Professional medical oversight is essential when implementing in clinical settings
201
+ - Regular validation of model outputs against current medical standards
202
+ - Integration should complement, not replace, professional medical consultation
203
+ - Staff training on AI limitations and appropriate use cases
204
+
205
+ ## Training Details
206
+
207
+ ### Training Data
208
+
209
+ The training dataset consisted of 119,117 carefully curated entries focused on spinal cord injury information:
210
+
211
+ **Domain Pretraining Data (35,779 entries):**
212
+ - Medical literature and research papers on SCI
213
+ - Educational materials from reputable SCI organizations
214
+ - Clinical guidelines and treatment protocols
215
+ - Rehabilitation and therapy documentation
216
+ - Patient education resources
217
+
218
+ **Instruction Tuning Data (83,337 entries):**
219
+ - SCI-focused question-answer pairs
220
+ - Conversational examples with appropriate medical context
221
+ - Real-world scenarios and practical advice situations
222
+ - Educational Q&A formatted for instruction following
223
+
224
+ All training data was filtered and curated to ensure:
225
+ - Sources from reputable medical organizations and healthcare professionals
226
+ - Content originally created or reviewed by medical professionals in the SCI field
227
+ - Appropriate tone and sensitivity for SCI community
228
+ - Removal of potentially harmful or dangerous advice
229
+ - Proper medical disclaimers and context
230
+
231
+ **Note**: While the source materials were created by medical professionals, this model itself has not undergone independent medical validation.
232
+
233
+ ### Training Procedure
234
+
235
+ The model was trained using a two-phase approach with QLoRA (Quantized Low-Rank Adaptation):
236
+
237
+ **Phase 1 - Domain Pretraining:**
238
+ - Focus: Medical terminology and SCI-specific knowledge
239
+ - Duration: 2 epochs (~8 hours)
240
+ - Data: 35,779 domain text entries
241
+ - Objective: Adapt base model to SCI medical domain
242
+
243
+ **Phase 2 - Instruction Tuning:**
244
+ - Focus: Conversational abilities and response formatting
245
+ - Duration: 2 epochs (~12 hours)
246
+ - Data: 83,337 instruction-response pairs
247
+ - Objective: Teach appropriate response patterns and tone
248
+
249
+ #### Preprocessing
250
+
251
+ Training data underwent extensive preprocessing:
252
+ - Content sourced from materials created by healthcare professionals
253
+ - Sensitive content filtering and safety checks
254
+ - Standardized formatting for instruction-following
255
+ - Quality filtering to remove low-quality or inappropriate content
256
+ - Tokenization optimization for efficient training
257
+
258
+ #### Training Hyperparameters
259
+
260
+ - **Training regime:** 4-bit quantization with LoRA adapters (QLoRA)
261
+ - **Learning rate:** 2e-4 with cosine scheduling
262
+ - **LoRA rank:** 16
263
+ - **LoRA alpha:** 32
264
+ - **LoRA dropout:** 0.05
265
+ - **Target modules:** q_proj, v_proj
266
+ - **Batch size:** 4 with gradient accumulation
267
+ - **Max sequence length:** 512 tokens
268
+ - **Optimizer:** AdamW with weight decay
269
+
270
+ #### Speeds, Sizes, Times
271
+
272
+ - **Total training time:** ~20 hours (8h Phase 1 + 12h Phase 2)
273
+ - **Hardware:** RTX 4070 Super (8GB VRAM)
274
+ - **Final model size:** 30MB (LoRA adapter only)
275
+ - **Base model size:** 7B parameters (not included in adapter)
276
+ - **Training throughput:** ~3.5 samples/second average
277
+ - **Memory usage:** 6-7GB VRAM during training
278
+
279
+ ## Evaluation
280
+
281
+ ### Testing Data, Factors & Metrics
282
+
283
+ #### Testing Data
284
+
285
+ The model was evaluated using:
286
+ - Held-out test set of SCI-related questions (500 samples)
287
+ - Manual review of response quality and appropriateness
288
+ - Comparative analysis against general-purpose models on SCI topics
289
+ - Assessment of domain-specific knowledge retention
290
+
291
+ **Note**: Evaluation was conducted by the model developer, not independent medical professionals.
292
+
293
+ #### Factors
294
+
295
+ Evaluation considered multiple factors:
296
+ - **Medical accuracy**: Correctness of SCI-related information
297
+ - **Appropriateness**: Sensitivity and tone for SCI community
298
+ - **Contextual relevance**: Understanding of SCI-specific challenges
299
+ - **Safety**: Avoidance of harmful or dangerous advice
300
+ - **Completeness**: Comprehensive responses to complex questions
301
+
302
+ #### Metrics
303
+
304
+ - **Medical accuracy score**: Based on consistency with source medical literature (not independently validated)
305
+ - **Appropriateness rating**: Developer assessment of tone and sensitivity (4.2/5.0 subjective rating)
306
+ - **Response relevance**: SCI-specific context understanding (82% relevance score)
307
+ - **Safety compliance**: No obviously harmful medical advice detected in test samples
308
+ - **Response quality**: Perplexity improvements over base model for SCI domain
309
+
310
+ ### Results
311
+
312
+ **Quantitative Results:**
313
+ - 40% improvement in SCI domain perplexity over base model
314
+ - Responses demonstrate consistency with source medical literature
315
+ - 95% safety compliance (no obviously harmful medical advice detected)
316
+ - 82% average relevance score for SCI-specific contexts
317
+
318
+ **Qualitative Results:**
319
+ - Responses demonstrate clear understanding of SCI terminology and concepts
320
+ - Appropriate tone and sensitivity for disability community
321
+ - Consistent inclusion of medical disclaimers
322
+ - Good balance between being helpful and cautious about medical advice
323
+
324
+ **Limitations of Evaluation:**
325
+ - Evaluation conducted by model developer, not independent medical experts
326
+ - No formal clinical validation or testing with SCI patients
327
+ - Results based on consistency with training sources, not independent medical verification
328
+
329
+ ## Environmental Impact
330
+
331
+ Training carbon emissions estimated using energy consumption data:
332
+
333
+ - **Hardware Type:** RTX 4070 Super (8GB VRAM)
334
+ - **Hours used:** ~20 hours total training time
335
+ - **Cloud Provider:** Local training (personal hardware)
336
+ - **Compute Region:** North America
337
+ - **Carbon Emitted:** Approximately 2.1 kg CO2eq (estimated based on local energy grid)
338
+
339
+ The use of QLoRA significantly reduced training time and energy consumption compared to full fine-tuning methods, making this a relatively efficient training approach.
340
+
341
+ ## Technical Specifications
342
+
343
+ ### Model Architecture and Objective
344
+
345
+ - **Base Architecture:** Mistral 7B transformer model
346
+ - **Adaptation Method:** QLoRA (Quantized Low-Rank Adaptation)
347
+ - **Objective:** Causal language modeling with SCI domain specialization
348
+ - **Quantization:** 4-bit precision for memory efficiency
349
+ - **LoRA Configuration:** Rank-16 adapters on attention projection layers
350
+
351
+ ### Compute Infrastructure
352
+
353
+ #### Hardware
354
+
355
+ - **GPU:** NVIDIA RTX 4070 Super (8GB VRAM)
356
+ - **CPU:** Modern multi-core processor
357
+ - **RAM:** 32GB system memory
358
+ - **Storage:** NVMe SSD for fast data loading
359
+
360
+ #### Software
361
+
362
+ - **Framework:** Transformers 4.36+, PEFT 0.16.0
363
+ - **Training:** QLoRA with bitsandbytes quantization
364
+ - **Environment:** Python 3.10+, PyTorch 2.0+, CUDA 12.1
365
+
366
+ ## Citation
367
+
368
+ If you use this model in your research or applications, please cite:
369
+
370
+ **BibTeX:**
371
+ ```bibtex
372
+ @misc{sci_assistant_2025,
373
+ title={SCI Assistant: A Specialized AI Assistant for Spinal Cord Injury Support},
374
+ author={basiphobe},
375
+ year={2025},
376
+ howpublished={Hugging Face Model Repository},
377
+ url={https://huggingface.co/basiphobe/sci-assistant}
378
+ }
379
+ ```
380
+
381
+ **APA:**
382
+ basiphobe. (2025). *SCI Assistant: A Specialized AI Assistant for Spinal Cord Injury Support*. Hugging Face. https://huggingface.co/basiphobe/sci-assistant
383
+
384
+ ## Glossary
385
+
386
+ **SCI**: Spinal Cord Injury - damage to the spinal cord that results in temporary or permanent changes in function
387
+
388
+ **QLoRA**: Quantized Low-Rank Adaptation - an efficient fine-tuning method that reduces memory requirements
389
+
390
+ **Domain Pretraining**: Training phase focused on learning domain-specific terminology and knowledge
391
+
392
+ **Instruction Tuning**: Training phase focused on learning conversational patterns and response formatting
393
+
394
+ **Perplexity**: A metric measuring how well a language model predicts text (lower is better)
395
+
396
+ **LoRA**: Low-Rank Adaptation - parameter-efficient fine-tuning technique
397
+
398
+ ## Model Card Authors
399
+
400
+ **Primary Author:** basiphobe
401
+ **Model Development:** Individual research project for SCI community support
402
+ **Data Sources:** Curated from medical literature and educational materials created by healthcare professionals
403
+ **Validation Status:** Model has not undergone independent medical professional validation
404
+
405
+ ## Model Card Contact
406
 
407
+ For questions, issues, or feedback regarding this model:
408
+ - **Hugging Face:** https://huggingface.co/basiphobe/sci-assistant
409
+ - **Issues:** Please report issues through Hugging Face model repository
410
+ - **Medical Concerns:** Always consult qualified healthcare professionals
411
 
412
+ **Important Note:** This model is provided for educational and informational purposes. Always seek professional medical advice for health-related questions and decisions.
413
 
414
+ ### Framework versions
415
 
416
+ - PEFT 0.16.0