LOHAMEIT commited on
Commit
cb58256
1 Parent(s): 384ff1d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +73 -102
README.md CHANGED
@@ -6,137 +6,108 @@ base_model:
6
  tags:
7
  - mental_health
8
  ---
9
-
10
- ---
11
-
12
- # BITShyd: Facial Expression and Mental Health Counseling AI
13
 
14
  [![Hugging Face](https://img.shields.io/badge/Model-Hugging%20Face-blue)](https://huggingface.co/LOHAMEIT/BITShyd)
15
 
16
  ### Project Summary
17
 
18
- **BITShyd** is an advanced AI model that combines **facial expression recognition** with **mental health counseling dialogues**, designed to offer empathetic responses based on both visual and conversational cues. This project fine-tunes a conversational AI with the **Amod/mental_health_counseling_conversations** dataset, adapting it specifically for virtual counseling and emotional support applications.
19
-
20
- The model leverages LoRA (Low-Rank Adaptation) and Unsloth fine-tuning techniques for efficient adaptation, making it suitable for use on various hardware setups, from personal devices to cloud-based applications.
21
-
22
- ---
23
-
24
- ## Model Details
25
-
26
- - **Model Type**: Conversational AI with emotional intelligence features
27
- - **Dataset**: [Amod/mental_health_counseling_conversations](https://huggingface.co/datasets/Amod/mental_health_counseling_conversations)
28
- - **Fine-Tuning Methods**: LoRA & Unsloth for optimized performance and low latency
29
- - **Primary Applications**: Virtual mental health support, empathetic AI assistants, interactive emotional response models
30
 
31
  ---
32
 
33
- ## Key Features
34
 
35
- - **Real-Time Facial Expression Recognition**: Capable of identifying emotional expressions such as happiness, sadness, anger, surprise, and neutrality.
36
- - **Empathetic, Contextually Aware Responses**: Trained specifically for counseling-based responses, this model interacts in an emotionally supportive way.
37
- - **Scalable Fine-Tuning Techniques**: LoRA and Unsloth allow for efficient, resource-light tuning, making the model adaptable to different devices.
38
 
39
  ---
40
 
41
- ## Quickstart Guide
42
-
43
- Here’s how to get started with using this model in your own applications.
44
-
45
- ### Installation and Setup
46
-
47
- 1. **Install Hugging Face Transformers and Required Libraries**:
48
- ```bash
49
- pip install transformers torch
50
- ```
51
-
52
- 2. **Load the Model and Tokenizer**
53
- ```python
54
- from transformers import AutoTokenizer, AutoModelForCausalLM
55
-
56
- tokenizer = AutoTokenizer.from_pretrained("LOHAMEIT/BITShyd")
57
- model = AutoModelForCausalLM.from_pretrained("LOHAMEIT/BITShyd")
58
- ```
59
 
60
- 3. **Preparing Input**
61
- - **Text Input**: This model uses text prompts, ideally incorporating facial expression indicators for contextual awareness.
62
- - **Image Input** (Optional): For real-time interaction, integrate with a facial expression API to enhance response generation based on user expressions.
 
63
 
64
- 4. **Generate a Response**
65
- ```python
66
- input_text = "Hello, I feel anxious today."
67
- inputs = tokenizer(input_text, return_tensors="pt")
68
- output = model.generate(**inputs, max_length=50)
69
- print(tokenizer.decode(output[0], skip_special_tokens=True))
70
- ```
71
 
72
- ---
73
 
74
- ## Usage Examples
 
 
75
 
76
- ### 1. Mental Health Support Assistant
77
- ```python
78
- input_text = "I'm feeling overwhelmed and don't know how to manage my stress."
79
- inputs = tokenizer(input_text, return_tensors="pt")
80
- output = model.generate(**inputs, max_length=50)
81
- print(tokenizer.decode(output[0], skip_special_tokens=True))
82
- ```
83
- Expected Response:
84
- > "I'm here for you. It sounds like things are challenging right now. Let's take a deep breath together. Would you like to talk more about what's overwhelming you?"
85
-
86
- ### 2. Emotionally Responsive AI Assistant
87
- This example integrates with a facial expression API to adjust responses based on detected emotions (like sadness or happiness).
88
-
89
- ```python
90
- detected_emotion = "sadness" # Detected through facial expression analysis
91
- input_text = "I've been feeling lonely lately."
92
- inputs = tokenizer(f"{detected_emotion} | {input_text}", return_tensors="pt")
93
- output = model.generate(**inputs, max_length=50)
94
- print(tokenizer.decode(output[0], skip_special_tokens=True))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  ```
96
- Expected Response:
97
- > "I'm sorry you're feeling this way. Loneliness can be really tough. Sometimes sharing your feelings can help. I'm here to listen if you'd like to talk."
98
 
99
  ---
100
 
101
- ## Model Training and Fine-Tuning Details
102
 
103
- This model was trained with **LoRA** and **Unsloth**:
 
 
 
104
 
105
- - **LoRA (Low-Rank Adaptation)**: LoRA enables the model to retain core knowledge while adapting efficiently to new data, making it ideal for nuanced tasks like mental health counseling.
106
- - **Unsloth**: Unsloth enhances inference speed, allowing the model to process requests with lower latency, suitable for real-time interaction scenarios.
107
-
108
- Training Configurations:
109
-
110
- | Parameter | Description |
111
- |-----------------|-------------------------------------|
112
- | Model Size | 8 Billion Parameters |
113
- | Epochs | 3 |
114
- | Learning Rate | 5e-5 |
115
- | Batch Size | 8 |
116
- | Dataset | Amod/mental_health_counseling_conversations |
117
- | Optimizations | LoRA and Unsloth |
118
 
119
  ---
120
 
121
- ## Future Work
122
 
123
- - **Advanced Emotion Detection**: Plan to integrate a broader range of emotions and body language cues.
124
- - **Interactive Widgets**: Adding Hugging Face widget for real-time interactions directly on this model’s page.
125
- - **Deployment Options**: Explore integration with cloud-based platforms for widespread access.
126
 
127
- ---
128
-
129
- ## License
130
-
131
- This model is available under the Apache 2.0 License. For detailed terms, refer to the [LICENSE](LICENSE.md) file in the repository.
132
 
133
  ---
134
 
135
- ### Explore the Model
136
-
137
- Interact with the model here: [LOHAMEIT/BITShyd](https://huggingface.co/LOHAMEIT/BITShyd)
138
-
139
- For any feedback or collaboration requests, feel free to reach out on Hugging Face or GitHub!
140
-
141
- ---
142
 
 
 
 
 
6
  tags:
7
  - mental_health
8
  ---
9
+ # BITShyd: AI-Enhanced Facial Expression & Mental Health Counseling
 
 
 
10
 
11
  [![Hugging Face](https://img.shields.io/badge/Model-Hugging%20Face-blue)](https://huggingface.co/LOHAMEIT/BITShyd)
12
 
13
  ### Project Summary
14
 
15
+ **BITShyd** is an innovative AI project developed at BITS Pilani, Hyderabad, designed to bridge the gap between **facial expression recognition** and **mental health counseling**. Using a combination of conversational AI fine-tuned on the **Amod/mental_health_counseling_conversations** dataset and real-time facial expression analysis, the model provides contextual responses tailored to the emotional state of the user. This empathetic AI supports mental health applications and interactive emotional support systems.
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  ---
18
 
19
+ ## Key Features and Technology
20
 
21
+ - **Facial Expression Recognition**: Detects emotions (happy, sad, angry, surprised, etc.) using real-time video input, enhanced with `face-api.js`.
22
+ - **Conversational AI for Mental Health**: The model generates empathetic, supportive responses in mental health contexts, using fine-tuning on the Amod dataset.
23
+ - **Low-Rank Adaptation (LoRA)** and **Unsloth Fine-Tuning**: These techniques streamline adaptation and latency, allowing use across hardware setups, from personal devices to cloud platforms.
24
 
25
  ---
26
 
27
+ ## Technical Overview
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
+ - **Base Model**: LLaMA 3.1 (8B parameters) on Hugging Face
30
+ - **Dataset**: [Amod/mental_health_counseling_conversations](https://huggingface.co/datasets/Amod/mental_health_counseling_conversations)
31
+ - **Optimization**: LoRA for lightweight tuning and Unsloth for improved inference latency
32
+ - **Supported Use Cases**: Virtual mental health counseling, empathetic AI interactions, real-time emotional analysis
33
 
34
+ ### Fine-Tuning Details
 
 
 
 
 
 
35
 
36
+ The model utilizes **LoRA** and **Unsloth** fine-tuning, which make it adaptable to a range of devices by reducing the resource load without compromising on performance:
37
 
38
+ - **Parameter-Efficient Training**: LoRA keeps the model’s core knowledge while adapting to new data, critical for sensitive applications like mental health.
39
+ - **Latency Optimization**: Unsloth helps reduce response time, essential for real-time interaction.
40
+ - **Training Configurations**:
41
 
42
+ | Parameter | Value |
43
+ |-----------------|-----------------------------------|
44
+ | Model Size | 8 Billion Parameters |
45
+ | Epochs | 3 |
46
+ | Learning Rate | 5e-5 |
47
+ | Batch Size | 8 |
48
+ | Dataset | Amod/mental_health_counseling_conversations |
49
+ | Optimizations | LoRA and Unsloth |
50
+
51
+ ### Code for Facial Expression Recognition
52
+
53
+ Below is a snippet using `face-api.js` for real-time expression detection and emoji overlay based on emotions detected:
54
+
55
+ ```javascript
56
+ const video = document.getElementById('video');
57
+ const expressionsToEmoji = { happy: '😊', sad: '😢', angry: '😠', surprised: '😮', fearful: '😨' };
58
+
59
+ async function loadModels() {
60
+ await faceapi.nets.tinyFaceDetector.loadFromUri('models');
61
+ await faceapi.nets.faceExpressionNet.loadFromUri('models');
62
+ await startVideo();
63
+ }
64
+
65
+ async function startVideo() {
66
+ const stream = await navigator.mediaDevices.getUserMedia({ video: true });
67
+ video.srcObject = stream;
68
+ }
69
+
70
+ async function detectFaces() {
71
+ const detections = await faceapi.detectAllFaces(video, new faceapi.TinyFaceDetectorOptions())
72
+ .withFaceExpressions();
73
+
74
+ // Render emoji based on emotion
75
+ detections.forEach(detection => {
76
+ const expressions = detection.expressions;
77
+ const topExpression = Object.keys(expressions).reduce((a, b) => expressions[a] > expressions[b] ? a : b);
78
+ const emoji = expressionsToEmoji[topExpression] || '🙂';
79
+ // Code to overlay emoji on video feed...
80
+ });
81
+ }
82
+
83
+ loadModels();
84
  ```
 
 
85
 
86
  ---
87
 
88
+ ## Pros & Cons of Fine-Tuning Techniques
89
 
90
+ ### Advantages
91
+ - **Efficient Adaptability**: LoRA enables fine-tuning with minimal additional parameters, making the model flexible for different datasets without extensive resources.
92
+ - **Reduced Latency**: Unsloth optimizes real-time response speed, vital for real-time interactions in mental health applications.
93
+ - **Scalability**: These techniques allow the model to run on a range of devices, expanding access to diverse user bases.
94
 
95
+ ### Disadvantages
96
+ - **Limited Transfer to Drastically Different Domains**: LoRA and Unsloth are efficient within the trained domain but may struggle with applications vastly different from the original training data.
97
+ - **Computational Constraints**: Although reduced, fine-tuning large models can still demand significant resources for high-quality performance in real-world applications.
 
 
 
 
 
 
 
 
 
 
98
 
99
  ---
100
 
101
+ ## Why Building Projects is Crucial Beyond DSA Skills
102
 
103
+ Building real-world projects like BITShyd is invaluable compared to simply mastering algorithms and data structures (DSA). While DSA provides foundational skills for coding efficiency, **project-based learning** fosters critical skills like problem-solving, innovation, and practical application. These skills are essential in building technology that interacts with the real world, like empathetic AI. In a 9-to-5 job, growth is often linear, but personal projects allow you to create, innovate, and potentially develop tech that impacts millions—especially in fields like AI, where emotional intelligence and empathy are groundbreaking.
 
 
104
 
105
+ BITShyd represents this mindset, and we encourage developers to focus on projects that break conventional boundaries and offer more than predefined answers to problems. At BITS Pilani, we aim to encourage building, experimenting, and understanding the end-to-end process of creating impactful technology.
 
 
 
 
106
 
107
  ---
108
 
109
+ ## Future Enhancements
 
 
 
 
 
 
110
 
111
+ - **Expanded Emotion Detection**: Plan to integrate a broader set of emotional expressions and even body language for deeper analysis.
112
+ - **Deployment Options**: Considering integration with cloud platforms for broad accessibility and robust interaction.
113
+ - **Error Handling**: Addressing the recent challenge with the Ollama API, ensuring smooth integration for stable performance.