arafatanam commited on
Commit
e30fbb5
Β·
verified Β·
1 Parent(s): 8ac590e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +205 -3
README.md CHANGED
@@ -1,3 +1,205 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - arafatanam/Student-Mental-Health-Counseling-10K
5
+ language:
6
+ - en
7
+ base_model:
8
+ - unsloth/llama-3-8b-Instruct
9
+ tags:
10
+ - Student-Mental-Health
11
+ - Llama
12
+ - Empathy
13
+ - Support
14
+ ---
15
+ # SMILE-llama-3-8b-Instruct πŸŽ“βœ¨
16
+
17
+ **Student Mental Intelligence for Learning & Excellence**
18
+
19
+ A fine-tuned LLaMA 3 8B model designed to support students in their academic journey by providing intelligent guidance on learning strategies, mental well-being, and academic excellence.
20
+
21
+ ## 🌟 Model Overview
22
+
23
+ SMILE (Student Mental Intelligence for Learning & Excellence) is a specialized conversational AI model built to understand and address the unique challenges faced by students. It combines academic guidance with mental health awareness to create a comprehensive support system for learners at all levels.
24
+
25
+ ### Key Features
26
+
27
+ - 🧠 **Mental Health Support**: Provides empathetic responses to student stress, anxiety, and emotional challenges
28
+ - πŸ“š **Academic Guidance**: Offers study tips, time management strategies, and learning optimization techniques
29
+ - 🎯 **Goal Setting**: Helps students set realistic academic goals and develop action plans
30
+ - 🀝 **Peer Support**: Simulates supportive peer interactions and collaborative learning approaches
31
+ - 🌱 **Personal Growth**: Encourages self-reflection and personal development alongside academic achievement
32
+
33
+ ## πŸ”§ Model Details
34
+
35
+ - **Base Model**: `unsloth/llama-3-8b-Instruct-bnb-4bit`
36
+ - **Architecture**: LLaMA 3 8B with 4-bit quantization
37
+ - **Fine-tuning Method**: PEFT (Parameter Efficient Fine-Tuning)
38
+ - **Training Dataset**: [`arafatanam/Student-Mental-Health-Counseling-10K`](https://huggingface.co/datasets/arafatanam/Student-Mental-Health-Counseling-10K)
39
+ - **Additional Data**: University student data collected from North South University, Dhaka, Bangladesh
40
+ - **Specialization**: Student mental health and academic excellence
41
+ - **Language**: English
42
+
43
+ ## πŸš€ Quick Start
44
+
45
+ ### Installation
46
+
47
+ ```bash
48
+ pip install -U python-dotenv gradio transformers accelerate bitsandbytes
49
+ pip install torch --index-url https://download.pytorch.org/whl/cu121
50
+ ```
51
+
52
+ ### Loading the Model
53
+
54
+ ```python
55
+ import torch
56
+ from transformers import AutoModelForCausalLM, AutoTokenizer
57
+ from peft import PeftConfig, PeftModel
58
+ import gradio as gr
59
+ import re
60
+ from huggingface_hub import login
61
+
62
+ # Login to Hugging Face (required for gated models)
63
+ login("your_hf_token_here")
64
+
65
+ # Load model and tokenizer
66
+ base_model = "unsloth/llama-3-8b-Instruct-bnb-4bit"
67
+ adapter = "arafatanam/SMILE-llama-3-8b-Instruct"
68
+
69
+ # Load tokenizer
70
+ tokenizer = AutoTokenizer.from_pretrained(
71
+ base_model,
72
+ add_bos_token=True,
73
+ trust_remote_code=True,
74
+ padding_side='left'
75
+ )
76
+
77
+ # Load base model with PEFT adapter
78
+ config = PeftConfig.from_pretrained(adapter)
79
+ model = AutoModelForCausalLM.from_pretrained(
80
+ config.base_model_name_or_path,
81
+ load_in_4bit=True,
82
+ device_map='auto',
83
+ torch_dtype='auto'
84
+ )
85
+ model = PeftModel.from_pretrained(model, adapter)
86
+ model.eval()
87
+ ```
88
+
89
+ ### Gradio Interface
90
+
91
+ ```python
92
+ # Removes all instances of **bold**
93
+ def clean_markdown_bold(response):
94
+ return re.sub(r"\*\*(.*?)\*\*", r"\1", response)
95
+
96
+ # Define chat function
97
+ def smile_chat(message, history):
98
+ # Format user message
99
+ user_message = [{"role": "user", "content": message}]
100
+
101
+ # Tokenize input
102
+ input_ids = tokenizer.apply_chat_template(
103
+ user_message,
104
+ tokenize=True,
105
+ add_generation_prompt=True,
106
+ return_tensors='pt'
107
+ ).to(model.device)
108
+
109
+ # Generate response
110
+ outputs = model.generate(
111
+ input_ids=input_ids,
112
+ max_new_tokens=220,
113
+ do_sample=True,
114
+ temperature=0.1,
115
+ top_k=30,
116
+ top_p=0.9,
117
+ repetition_penalty=1.15,
118
+ no_repeat_ngram_size=2,
119
+ pad_token_id=tokenizer.pad_token_id,
120
+ eos_token_id=tokenizer.eos_token_id
121
+ )
122
+
123
+ # Extract and decode response
124
+ generated_ids = outputs[:, input_ids.shape[1]:]
125
+ response = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
126
+ response = clean_markdown_bold(response)
127
+
128
+ if not response.endswith(('.', '!', '?')):
129
+ response += '.'
130
+
131
+ return response.strip()
132
+
133
+ # Create Gradio interface for SMILE model
134
+ gr.ChatInterface(
135
+ fn=smile_chat,
136
+ title="SMILE - Student Mental Intelligence for Learning & Excellence",
137
+ description="Your AI companion for academic success and mental well-being",
138
+ examples=[
139
+ ["I'm feeling overwhelmed with my coursework. How can I manage my stress?"],
140
+ ["What are some effective study techniques for better retention?"],
141
+ ["I'm struggling with procrastination. Can you help me stay motivated?"],
142
+ ["How do I balance academic pressure with self-care?"],
143
+ ["I feel like I'm falling behind in my studies. What should I do?"],
144
+ ["Can you help me create a study schedule that works?"],
145
+ ["I'm anxious about upcoming exams. How can I prepare mentally?"],
146
+ ["How do I maintain good mental health during challenging academic periods?"]
147
+ ]
148
+ ).launch(share=True, pwa=True, prevent_thread_lock=True)
149
+ ```
150
+
151
+ ## πŸ’‘ Use Cases
152
+
153
+ ### Academic Support
154
+ - Study planning and organization
155
+ - Learning strategy optimization
156
+ - Time management guidance
157
+ - Exam preparation techniques
158
+ - Research and writing assistance
159
+
160
+ ### Mental Health & Well-being
161
+ - Stress management techniques
162
+ - Anxiety coping strategies
163
+ - Motivation and confidence building
164
+ - Work-life balance guidance
165
+ - Emotional support during difficult periods
166
+
167
+ ### Personal Development
168
+ - Goal setting and achievement
169
+ - Self-reflection and growth
170
+ - Building resilience
171
+ - Developing healthy study habits
172
+ - Fostering a growth mindset
173
+
174
+ ## 🎯 Example Conversations
175
+
176
+ **Student**: "I'm feeling really stressed about my upcoming finals. I can't seem to focus and I'm worried I'll fail."
177
+
178
+ **SMILE**: "I understand how overwhelming finals can feel, and your concerns are completely valid. Let's work together on some strategies to help you regain focus and confidence. First, try breaking your study material into smaller, manageable chunks. Create a realistic study schedule that includes regular breaks and self-care activities. Remember, some stress is normal, but if it's paralyzing you, consider techniques like deep breathing or short meditation sessions. You've made it this far in your studies, which shows you have the capability to succeed."
179
+
180
+ ---
181
+
182
+ **Student**: "I keep procrastinating on my assignments. I know what I need to do, but I just can't get started."
183
+
184
+ **SMILE**: "Procrastination often stems from feeling overwhelmed or fearing imperfection. Try the 'two-minute rule': if a task takes less than two minutes, do it immediately. For larger tasks, commit to just 15 minutes of work. Often, starting is the hardest part, and you'll find yourself continuing beyond that initial commitment. Also, identify your peak energy hours and schedule important work during those times. Remember, progress is better than perfection."
185
+
186
+ ## ⚠️ Limitations & Disclaimers
187
+
188
+ - This model provides educational and emotional support but is not a replacement for professional mental health services
189
+ - For serious mental health concerns, please consult with qualified healthcare professionals
190
+ - The model's responses are based on training data and should be considered as supportive guidance, not professional advice
191
+ - Always prioritize your safety and well-being above academic achievement
192
+
193
+ ## 🀝 Contributing
194
+
195
+ We welcome contributions to improve SMILE! Whether it's reporting issues, suggesting improvements, or sharing use cases, your feedback helps make this model better for all students.
196
+
197
+ ## πŸ™ Acknowledgments
198
+
199
+ - Built upon Meta's LLaMA 3 architecture
200
+ - Fine-tuned using Unsloth's optimized implementation
201
+ - Developed with a focus on student mental health and academic success
202
+
203
+ ---
204
+
205
+ **Remember**: Your mental health matters just as much as your academic success. SMILE is here to support you in achieving both! 🌟