Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
0570cd5
1
Parent(s):
146b507
Major UI improvements: Enhanced design, fixed dark mode, better examples
Browse files- Changed title to 'DentaInstruct-1.2B Demo'
- Fixed disclaimer visibility in dark mode with gradient design
- Added professional header with model statistics
- Categorised examples into 5 dental domains
- Added capability cards showcasing model strengths
- Improved chat interface with better spacing and borders
- Enhanced button styling with gradients and hover effects
- Added comprehensive About section with model details
- Improved mobile responsiveness
- Better dark mode support throughout
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: 🦷
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
|
@@ -12,37 +12,56 @@ models:
|
|
| 12 |
- yasserrmd/DentaInstruct-1.2B
|
| 13 |
---
|
| 14 |
|
| 15 |
-
#
|
| 16 |
|
| 17 |
-
An
|
| 18 |
|
| 19 |
-
## Features
|
| 20 |
|
| 21 |
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
## Important Disclaimer
|
| 28 |
|
| 29 |
-
⚠️ **This model is for
|
| 30 |
|
| 31 |
-
## Model
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
##
|
| 39 |
|
| 40 |
-
|
| 41 |
-
-
|
| 42 |
-
-
|
| 43 |
-
-
|
| 44 |
-
- Preventive
|
| 45 |
-
- Dental anatomy and terminology
|
| 46 |
|
| 47 |
## Credits
|
| 48 |
|
|
|
|
| 1 |
---
|
| 2 |
+
title: DentaInstruct-1.2B Demo
|
| 3 |
emoji: 🦷
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
|
|
|
| 12 |
- yasserrmd/DentaInstruct-1.2B
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# DentaInstruct-1.2B Demo
|
| 16 |
|
| 17 |
+
An advanced AI-powered dental education assistant featuring the DentaInstruct-1.2B model, designed to provide comprehensive educational information about dental health, procedures, and oral care.
|
| 18 |
|
| 19 |
+
## Key Features
|
| 20 |
|
| 21 |
+
### 🎯 Specialised Dental AI
|
| 22 |
+
- **Domain-Specific Training**: Fine-tuned on comprehensive dental educational content from the MIRIAD dataset
|
| 23 |
+
- **1.17B Parameters**: Optimised for efficient, fast responses while maintaining accuracy
|
| 24 |
+
- **Context-Aware**: Maintains conversation history for more coherent, contextual responses
|
| 25 |
+
|
| 26 |
+
### 💡 Comprehensive Coverage
|
| 27 |
+
- **Patient Education**: Clear explanations of dental conditions and treatments
|
| 28 |
+
- **Procedure Details**: Step-by-step breakdowns of dental procedures
|
| 29 |
+
- **Prevention & Care**: Evidence-based oral hygiene guidance
|
| 30 |
+
- **Paediatric Dentistry**: Specialised information for children's dental health
|
| 31 |
+
- **Emergency Guidance**: Educational information about dental emergencies
|
| 32 |
+
- **Professional Terminology**: Detailed explanations of dental anatomy and terms
|
| 33 |
+
|
| 34 |
+
### 🚀 Advanced Interface
|
| 35 |
+
- **Intuitive Chat Interface**: Natural conversation flow with the AI assistant
|
| 36 |
+
- **Categorised Examples**: Quick-start questions organised by topic
|
| 37 |
+
- **Customisable Parameters**: Fine-tune response generation (temperature, length, etc.)
|
| 38 |
+
- **Dark Mode Support**: Fully optimised for both light and dark themes
|
| 39 |
+
- **Mobile Responsive**: Works seamlessly on all devices
|
| 40 |
+
- **Fast Response Times**: Typically under 2 seconds per query
|
| 41 |
|
| 42 |
## Important Disclaimer
|
| 43 |
|
| 44 |
+
⚠️ **Educational Use Only**: This AI model provides educational information about dental topics and is designed for learning purposes only. It is **NOT** a substitute for professional dental or medical advice, diagnosis, or treatment. Always seek the advice of your dentist or qualified healthcare provider with any questions about a medical condition or treatment.
|
| 45 |
|
| 46 |
+
## Model Specifications
|
| 47 |
|
| 48 |
+
| Specification | Details |
|
| 49 |
+
|--------------|---------|
|
| 50 |
+
| **Architecture** | Transformer-based language model |
|
| 51 |
+
| **Base Model** | LiquidAI LFM2-1.2B |
|
| 52 |
+
| **Parameters** | 1.17 billion |
|
| 53 |
+
| **Training Data** | MIRIAD dental dataset |
|
| 54 |
+
| **Context Length** | 2048 tokens |
|
| 55 |
+
| **Inference** | GPU-accelerated with bfloat16 precision |
|
| 56 |
+
| **Response Time** | < 2 seconds average |
|
| 57 |
|
| 58 |
+
## Use Cases
|
| 59 |
|
| 60 |
+
- **Patient Education**: Help patients understand dental procedures and conditions
|
| 61 |
+
- **Student Learning**: Assist dental students with study materials and explanations
|
| 62 |
+
- **Quick Reference**: Look up dental terminology and concepts
|
| 63 |
+
- **Treatment Understanding**: Learn about various treatment options
|
| 64 |
+
- **Preventive Care**: Get guidance on oral health maintenance
|
|
|
|
| 65 |
|
| 66 |
## Credits
|
| 67 |
|
app.py
CHANGED
|
@@ -107,150 +107,566 @@ def generate_response(
|
|
| 107 |
|
| 108 |
return response
|
| 109 |
|
| 110 |
-
#
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
custom_css = """
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
border
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
}
|
| 131 |
"""
|
| 132 |
|
| 133 |
-
# Create Gradio interface
|
| 134 |
with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
|
| 135 |
-
|
|
|
|
| 136 |
"""
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
| 140 |
"""
|
| 141 |
)
|
| 142 |
|
|
|
|
| 143 |
gr.HTML(
|
| 144 |
"""
|
| 145 |
-
<div class="
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
</div>
|
| 150 |
"""
|
| 151 |
)
|
| 152 |
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
)
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
)
|
| 163 |
|
|
|
|
| 164 |
with gr.Row():
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
)
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
| 203 |
)
|
| 204 |
|
| 205 |
-
|
| 206 |
-
examples=EXAMPLES,
|
| 207 |
-
inputs=msg,
|
| 208 |
-
label="Example Questions"
|
| 209 |
-
)
|
| 210 |
-
|
| 211 |
gr.Markdown(
|
| 212 |
"""
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
|
| 218 |
-
|
| 219 |
-
-
|
| 220 |
-
-
|
| 221 |
-
-
|
| 222 |
-
-
|
|
|
|
| 223 |
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
"""
|
| 226 |
)
|
| 227 |
|
| 228 |
# Event handlers
|
| 229 |
def respond(message, chat_history, temperature, max_new_tokens, top_p, repetition_penalty):
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
|
|
|
| 241 |
msg.submit(
|
| 242 |
respond,
|
| 243 |
[msg, chatbot, temperature, max_new_tokens, top_p, repetition_penalty],
|
| 244 |
-
[msg, chatbot]
|
|
|
|
| 245 |
)
|
| 246 |
|
| 247 |
submit.click(
|
| 248 |
respond,
|
| 249 |
[msg, chatbot, temperature, max_new_tokens, top_p, repetition_penalty],
|
| 250 |
-
[msg, chatbot]
|
|
|
|
| 251 |
)
|
| 252 |
|
| 253 |
-
clear.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
|
|
|
|
| 255 |
if __name__ == "__main__":
|
| 256 |
-
demo.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
return response
|
| 109 |
|
| 110 |
+
# Categorised example questions for better showcase
|
| 111 |
+
EXAMPLE_CATEGORIES = {
|
| 112 |
+
"Patient Education": [
|
| 113 |
+
"What are the main types of dental cavities and how can I prevent them?",
|
| 114 |
+
"Explain the stages of gum disease from gingivitis to periodontitis",
|
| 115 |
+
"What should I expect during my first dental cleaning appointment?",
|
| 116 |
+
],
|
| 117 |
+
"Treatment Procedures": [
|
| 118 |
+
"Walk me through the steps of a root canal treatment",
|
| 119 |
+
"What's the difference between a crown and a veneer?",
|
| 120 |
+
"How does the dental implant process work from start to finish?",
|
| 121 |
+
],
|
| 122 |
+
"Oral Health & Prevention": [
|
| 123 |
+
"What's the proper brushing technique for optimal plaque removal?",
|
| 124 |
+
"How does fluoride protect teeth and is it safe for children?",
|
| 125 |
+
"What foods should I avoid to maintain healthy teeth?",
|
| 126 |
+
],
|
| 127 |
+
"Paediatric Dentistry": [
|
| 128 |
+
"When should a child have their first dental visit?",
|
| 129 |
+
"Explain the tooth eruption timeline in children",
|
| 130 |
+
"How can parents help prevent early childhood cavities?",
|
| 131 |
+
],
|
| 132 |
+
"Emergency & Post-Care": [
|
| 133 |
+
"What should I do if I knock out a permanent tooth?",
|
| 134 |
+
"How should I care for my mouth after wisdom tooth extraction?",
|
| 135 |
+
"What are signs of a dental infection that needs immediate attention?",
|
| 136 |
+
]
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
# Flatten examples for the Examples component
|
| 140 |
+
EXAMPLES = []
|
| 141 |
+
for category, questions in EXAMPLE_CATEGORIES.items():
|
| 142 |
+
for question in questions:
|
| 143 |
+
EXAMPLES.append([question])
|
| 144 |
+
|
| 145 |
+
# Custom CSS for improved styling with proper dark mode support
|
| 146 |
custom_css = """
|
| 147 |
+
/* Improved disclaimer box with proper dark mode support */
|
| 148 |
+
.disclaimer-box {
|
| 149 |
+
background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 100%);
|
| 150 |
+
border: 2px solid #f0ad4e;
|
| 151 |
+
border-radius: 10px;
|
| 152 |
+
padding: 16px 20px;
|
| 153 |
+
margin: 20px 0;
|
| 154 |
+
font-size: 14px;
|
| 155 |
+
line-height: 1.6;
|
| 156 |
+
position: relative;
|
| 157 |
+
overflow: hidden;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
/* Dark mode disclaimer */
|
| 161 |
+
.dark .disclaimer-box {
|
| 162 |
+
background: linear-gradient(135deg, #3d2f1f 0%, #4a3a28 100%);
|
| 163 |
+
border: 2px solid #d4a574;
|
| 164 |
+
color: #ffd9b3;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
.disclaimer-box::before {
|
| 168 |
+
content: '';
|
| 169 |
+
position: absolute;
|
| 170 |
+
left: 0;
|
| 171 |
+
top: 0;
|
| 172 |
+
bottom: 0;
|
| 173 |
+
width: 4px;
|
| 174 |
+
background: #f0ad4e;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.dark .disclaimer-box::before {
|
| 178 |
+
background: #d4a574;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.disclaimer-title {
|
| 182 |
+
font-weight: 600;
|
| 183 |
+
color: #d58512;
|
| 184 |
+
margin-bottom: 8px;
|
| 185 |
+
display: flex;
|
| 186 |
+
align-items: center;
|
| 187 |
+
gap: 8px;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
.dark .disclaimer-title {
|
| 191 |
+
color: #ffa500;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
.disclaimer-text {
|
| 195 |
+
color: #856404;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
.dark .disclaimer-text {
|
| 199 |
+
color: #ffd9b3;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
/* Model capabilities cards */
|
| 203 |
+
.capability-cards {
|
| 204 |
+
display: grid;
|
| 205 |
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
| 206 |
+
gap: 16px;
|
| 207 |
+
margin: 20px 0;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
.capability-card {
|
| 211 |
+
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
|
| 212 |
+
border: 1px solid #dee2e6;
|
| 213 |
+
border-radius: 8px;
|
| 214 |
+
padding: 16px;
|
| 215 |
+
transition: transform 0.2s, box-shadow 0.2s;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
.dark .capability-card {
|
| 219 |
+
background: linear-gradient(135deg, #2b2b2b 0%, #1f1f1f 100%);
|
| 220 |
+
border: 1px solid #404040;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
.capability-card:hover {
|
| 224 |
+
transform: translateY(-2px);
|
| 225 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
.dark .capability-card:hover {
|
| 229 |
+
box-shadow: 0 4px 12px rgba(255,255,255,0.1);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.capability-title {
|
| 233 |
+
font-weight: 600;
|
| 234 |
+
color: #495057;
|
| 235 |
+
margin-bottom: 8px;
|
| 236 |
+
font-size: 16px;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.dark .capability-title {
|
| 240 |
+
color: #e9ecef;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
.capability-description {
|
| 244 |
+
color: #6c757d;
|
| 245 |
+
font-size: 14px;
|
| 246 |
+
line-height: 1.5;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.dark .capability-description {
|
| 250 |
+
color: #adb5bd;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/* Stats badges */
|
| 254 |
+
.stats-container {
|
| 255 |
+
display: flex;
|
| 256 |
+
gap: 16px;
|
| 257 |
+
flex-wrap: wrap;
|
| 258 |
+
margin: 16px 0;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.stat-badge {
|
| 262 |
+
background: linear-gradient(135deg, #e7f3ff 0%, #cfe2ff 100%);
|
| 263 |
+
border: 1px solid #b6d4fe;
|
| 264 |
+
border-radius: 20px;
|
| 265 |
+
padding: 8px 16px;
|
| 266 |
+
display: flex;
|
| 267 |
+
align-items: center;
|
| 268 |
+
gap: 8px;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
.dark .stat-badge {
|
| 272 |
+
background: linear-gradient(135deg, #1a3a52 0%, #0f2940 100%);
|
| 273 |
+
border: 1px solid #2563eb;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
.stat-label {
|
| 277 |
+
color: #0066cc;
|
| 278 |
+
font-weight: 500;
|
| 279 |
+
font-size: 12px;
|
| 280 |
+
text-transform: uppercase;
|
| 281 |
+
letter-spacing: 0.5px;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
.dark .stat-label {
|
| 285 |
+
color: #60a5fa;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
.stat-value {
|
| 289 |
+
color: #004099;
|
| 290 |
+
font-weight: 700;
|
| 291 |
+
font-size: 14px;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
.dark .stat-value {
|
| 295 |
+
color: #93bbfc;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
/* Improved button styling */
|
| 299 |
+
.gr-button-primary {
|
| 300 |
+
background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%) !important;
|
| 301 |
+
border: none !important;
|
| 302 |
+
color: white !important;
|
| 303 |
+
font-weight: 600 !important;
|
| 304 |
+
transition: all 0.3s ease !important;
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
.gr-button-primary:hover {
|
| 308 |
+
background: linear-gradient(135deg, #0052a3 0%, #003d7a 100%) !important;
|
| 309 |
+
transform: translateY(-1px);
|
| 310 |
+
box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
/* Chat improvements */
|
| 314 |
+
.gr-chatbot {
|
| 315 |
+
border-radius: 12px !important;
|
| 316 |
+
border: 1px solid #dee2e6 !important;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
.dark .gr-chatbot {
|
| 320 |
+
border: 1px solid #404040 !important;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
/* Example section styling */
|
| 324 |
+
.example-category {
|
| 325 |
+
margin-bottom: 12px;
|
| 326 |
+
padding: 12px;
|
| 327 |
+
background: #f8f9fa;
|
| 328 |
+
border-radius: 8px;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
.dark .example-category {
|
| 332 |
+
background: #1f1f1f;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
.example-category-title {
|
| 336 |
+
font-weight: 600;
|
| 337 |
+
color: #495057;
|
| 338 |
+
margin-bottom: 8px;
|
| 339 |
+
font-size: 14px;
|
| 340 |
+
text-transform: uppercase;
|
| 341 |
+
letter-spacing: 0.5px;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
.dark .example-category-title {
|
| 345 |
+
color: #e9ecef;
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
/* Header styling */
|
| 349 |
+
.main-header {
|
| 350 |
+
background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
|
| 351 |
+
color: white;
|
| 352 |
+
padding: 32px;
|
| 353 |
+
border-radius: 12px;
|
| 354 |
+
margin-bottom: 24px;
|
| 355 |
+
text-align: center;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
.dark .main-header {
|
| 359 |
+
background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
.header-title {
|
| 363 |
+
font-size: 36px;
|
| 364 |
+
font-weight: 700;
|
| 365 |
+
margin-bottom: 12px;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
.header-subtitle {
|
| 369 |
+
font-size: 18px;
|
| 370 |
+
opacity: 0.95;
|
| 371 |
+
font-weight: 400;
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
/* Mobile responsiveness */
|
| 375 |
+
@media (max-width: 768px) {
|
| 376 |
+
.capability-cards {
|
| 377 |
+
grid-template-columns: 1fr;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
.stats-container {
|
| 381 |
+
flex-direction: column;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
.stat-badge {
|
| 385 |
+
width: 100%;
|
| 386 |
+
justify-content: center;
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.header-title {
|
| 390 |
+
font-size: 28px;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
.header-subtitle {
|
| 394 |
+
font-size: 16px;
|
| 395 |
+
}
|
| 396 |
}
|
| 397 |
"""
|
| 398 |
|
| 399 |
+
# Create Gradio interface with improved design
|
| 400 |
with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
|
| 401 |
+
# Professional header with gradient
|
| 402 |
+
gr.HTML(
|
| 403 |
"""
|
| 404 |
+
<div class="main-header">
|
| 405 |
+
<h1 class="header-title">🦷 DentaInstruct-1.2B Demo</h1>
|
| 406 |
+
<p class="header-subtitle">Advanced AI assistant for dental education and oral health information</p>
|
| 407 |
+
</div>
|
| 408 |
"""
|
| 409 |
)
|
| 410 |
|
| 411 |
+
# Model statistics and capabilities
|
| 412 |
gr.HTML(
|
| 413 |
"""
|
| 414 |
+
<div class="stats-container">
|
| 415 |
+
<div class="stat-badge">
|
| 416 |
+
<span class="stat-label">Model Size</span>
|
| 417 |
+
<span class="stat-value">1.17B params</span>
|
| 418 |
+
</div>
|
| 419 |
+
<div class="stat-badge">
|
| 420 |
+
<span class="stat-label">Base Model</span>
|
| 421 |
+
<span class="stat-value">LFM2-1.2B</span>
|
| 422 |
+
</div>
|
| 423 |
+
<div class="stat-badge">
|
| 424 |
+
<span class="stat-label">Training Data</span>
|
| 425 |
+
<span class="stat-value">MIRIAD Dental</span>
|
| 426 |
+
</div>
|
| 427 |
+
<div class="stat-badge">
|
| 428 |
+
<span class="stat-label">Response Time</span>
|
| 429 |
+
<span class="stat-value">< 2 seconds</span>
|
| 430 |
+
</div>
|
| 431 |
</div>
|
| 432 |
"""
|
| 433 |
)
|
| 434 |
|
| 435 |
+
# Improved disclaimer with better visibility
|
| 436 |
+
gr.HTML(
|
| 437 |
+
"""
|
| 438 |
+
<div class="disclaimer-box">
|
| 439 |
+
<div class="disclaimer-title">
|
| 440 |
+
⚠️ Educational Use Only - Important Medical Disclaimer
|
| 441 |
+
</div>
|
| 442 |
+
<div class="disclaimer-text">
|
| 443 |
+
This AI model provides educational information about dental topics and is designed for learning purposes only.
|
| 444 |
+
It is <strong>NOT</strong> a substitute for professional dental or medical advice, diagnosis, or treatment.
|
| 445 |
+
Always seek the advice of your dentist or qualified healthcare provider with any questions about a medical condition or treatment.
|
| 446 |
+
</div>
|
| 447 |
+
</div>
|
| 448 |
+
"""
|
| 449 |
)
|
| 450 |
|
| 451 |
+
# Model capabilities showcase
|
| 452 |
+
gr.HTML(
|
| 453 |
+
"""
|
| 454 |
+
<h2 style="margin-top: 24px; margin-bottom: 16px;">What can DentaInstruct help you with?</h2>
|
| 455 |
+
<div class="capability-cards">
|
| 456 |
+
<div class="capability-card">
|
| 457 |
+
<div class="capability-title">📚 Patient Education</div>
|
| 458 |
+
<div class="capability-description">Clear explanations of dental conditions, treatments, and procedures in patient-friendly language</div>
|
| 459 |
+
</div>
|
| 460 |
+
<div class="capability-card">
|
| 461 |
+
<div class="capability-title">🔍 Procedure Details</div>
|
| 462 |
+
<div class="capability-description">Step-by-step breakdowns of common dental procedures from cleanings to complex treatments</div>
|
| 463 |
+
</div>
|
| 464 |
+
<div class="capability-card">
|
| 465 |
+
<div class="capability-title">🛡️ Prevention Tips</div>
|
| 466 |
+
<div class="capability-description">Evidence-based oral hygiene guidance and preventive care recommendations</div>
|
| 467 |
+
</div>
|
| 468 |
+
<div class="capability-card">
|
| 469 |
+
<div class="capability-title">👶 Paediatric Dentistry</div>
|
| 470 |
+
<div class="capability-description">Specialised information about children's dental development and care</div>
|
| 471 |
+
</div>
|
| 472 |
+
<div class="capability-card">
|
| 473 |
+
<div class="capability-title">🚨 Emergency Guidance</div>
|
| 474 |
+
<div class="capability-description">Educational information about dental emergencies and post-treatment care</div>
|
| 475 |
+
</div>
|
| 476 |
+
<div class="capability-card">
|
| 477 |
+
<div class="capability-title">🦷 Anatomy & Terms</div>
|
| 478 |
+
<div class="capability-description">Detailed explanations of dental anatomy and professional terminology</div>
|
| 479 |
+
</div>
|
| 480 |
+
</div>
|
| 481 |
+
"""
|
| 482 |
)
|
| 483 |
|
| 484 |
+
# Main chat interface
|
| 485 |
with gr.Row():
|
| 486 |
+
with gr.Column(scale=1):
|
| 487 |
+
chatbot = gr.Chatbot(
|
| 488 |
+
height=500,
|
| 489 |
+
label="Dental Education Assistant",
|
| 490 |
+
show_label=True,
|
| 491 |
+
avatar_images=None,
|
| 492 |
+
bubble_full_width=False,
|
| 493 |
+
render_markdown=True,
|
| 494 |
+
)
|
| 495 |
+
|
| 496 |
+
with gr.Row():
|
| 497 |
+
msg = gr.Textbox(
|
| 498 |
+
label="Your dental question",
|
| 499 |
+
placeholder="Ask about dental procedures, oral health, treatment options, or any dental topic...",
|
| 500 |
+
lines=3,
|
| 501 |
+
scale=4,
|
| 502 |
+
container=False,
|
| 503 |
+
)
|
| 504 |
+
|
| 505 |
+
with gr.Row():
|
| 506 |
+
submit = gr.Button("Send Question", variant="primary", scale=1)
|
| 507 |
+
clear = gr.Button("Clear Chat", scale=1)
|
| 508 |
|
| 509 |
+
# Advanced settings in a collapsible section
|
| 510 |
+
with gr.Accordion("⚙️ Advanced Settings", open=False):
|
| 511 |
+
with gr.Row():
|
| 512 |
+
with gr.Column(scale=1):
|
| 513 |
+
temperature = gr.Slider(
|
| 514 |
+
minimum=0.1,
|
| 515 |
+
maximum=1.0,
|
| 516 |
+
value=0.3,
|
| 517 |
+
step=0.1,
|
| 518 |
+
label="Temperature",
|
| 519 |
+
info="Lower values (0.1-0.3) for factual responses, higher (0.7-1.0) for creative explanations"
|
| 520 |
+
)
|
| 521 |
+
|
| 522 |
+
max_new_tokens = gr.Slider(
|
| 523 |
+
minimum=64,
|
| 524 |
+
maximum=1024,
|
| 525 |
+
value=512,
|
| 526 |
+
step=64,
|
| 527 |
+
label="Response Length",
|
| 528 |
+
info="Maximum number of tokens in the response"
|
| 529 |
+
)
|
| 530 |
+
|
| 531 |
+
with gr.Column(scale=1):
|
| 532 |
+
top_p = gr.Slider(
|
| 533 |
+
minimum=0.1,
|
| 534 |
+
maximum=1.0,
|
| 535 |
+
value=0.95,
|
| 536 |
+
step=0.05,
|
| 537 |
+
label="Top-p (Nucleus Sampling)",
|
| 538 |
+
info="Controls diversity of word choices"
|
| 539 |
+
)
|
| 540 |
+
|
| 541 |
+
repetition_penalty = gr.Slider(
|
| 542 |
+
minimum=1.0,
|
| 543 |
+
maximum=1.5,
|
| 544 |
+
value=1.05,
|
| 545 |
+
step=0.05,
|
| 546 |
+
label="Repetition Penalty",
|
| 547 |
+
info="Reduces repetitive phrases in responses"
|
| 548 |
+
)
|
| 549 |
+
|
| 550 |
+
# Example questions organised by category
|
| 551 |
+
with gr.Accordion("💡 Example Questions by Category", open=True):
|
| 552 |
+
gr.Examples(
|
| 553 |
+
examples=EXAMPLES[:8], # Show first 8 examples
|
| 554 |
+
inputs=msg,
|
| 555 |
+
label="Quick Start Examples",
|
| 556 |
)
|
| 557 |
|
| 558 |
+
# Additional categorised examples
|
| 559 |
+
gr.Markdown(
|
| 560 |
+
"""
|
| 561 |
+
### More Example Categories:
|
| 562 |
+
- **Patient Education**: Understanding conditions, prevention, and treatment basics
|
| 563 |
+
- **Treatment Procedures**: Detailed explanations of dental procedures
|
| 564 |
+
- **Oral Health & Prevention**: Daily care and preventive measures
|
| 565 |
+
- **Paediatric Dentistry**: Children's dental health and development
|
| 566 |
+
- **Emergency & Post-Care**: Urgent situations and aftercare instructions
|
| 567 |
+
"""
|
| 568 |
)
|
| 569 |
|
| 570 |
+
# About section with professional information
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 571 |
gr.Markdown(
|
| 572 |
"""
|
| 573 |
+
---
|
| 574 |
+
|
| 575 |
+
## About DentaInstruct-1.2B
|
| 576 |
+
|
| 577 |
+
DentaInstruct-1.2B is a specialised language model fine-tuned specifically for dental education and oral health information.
|
| 578 |
+
Built on the efficient LFM2-1.2B architecture, it combines compact size with domain expertise to provide accurate,
|
| 579 |
+
educational content about dentistry.
|
| 580 |
+
|
| 581 |
+
### Key Features:
|
| 582 |
+
- **Specialised Training**: Fine-tuned on comprehensive dental educational content from the MIRIAD dataset
|
| 583 |
+
- **Efficient Architecture**: 1.17B parameters optimised for fast response times
|
| 584 |
+
- **Broad Coverage**: Knowledgeable about general dentistry, orthodontics, periodontics, endodontics, and more
|
| 585 |
+
- **Educational Focus**: Designed to explain complex dental concepts in accessible language
|
| 586 |
+
- **Multi-context Support**: Can handle patient education, professional discussions, and academic queries
|
| 587 |
|
| 588 |
+
### Technical Specifications:
|
| 589 |
+
- **Architecture**: Transformer-based language model
|
| 590 |
+
- **Base Model**: LiquidAI LFM2-1.2B
|
| 591 |
+
- **Training Method**: Supervised fine-tuning on dental domain data
|
| 592 |
+
- **Context Length**: 2048 tokens
|
| 593 |
+
- **Inference**: Optimised for GPU acceleration with bfloat16 precision
|
| 594 |
|
| 595 |
+
### Use Cases:
|
| 596 |
+
- Patient education materials and explanations
|
| 597 |
+
- Dental student study assistance
|
| 598 |
+
- Quick reference for dental terminology
|
| 599 |
+
- Understanding treatment options and procedures
|
| 600 |
+
- Oral health and hygiene guidance
|
| 601 |
|
| 602 |
+
### Important Considerations:
|
| 603 |
+
- This model is for educational purposes only
|
| 604 |
+
- Not intended for clinical decision-making
|
| 605 |
+
- Information should be verified with professional sources
|
| 606 |
+
- Always consult qualified dental professionals for personal health concerns
|
| 607 |
+
|
| 608 |
+
---
|
| 609 |
+
|
| 610 |
+
**Model Creator**: [@yasserrmd](https://huggingface.co/yasserrmd) |
|
| 611 |
+
**Space Developer**: [@chrisvoncsefalvay](https://huggingface.co/chrisvoncsefalvay) |
|
| 612 |
+
**License**: Apache 2.0
|
| 613 |
+
|
| 614 |
+
🔗 [Model Card](https://huggingface.co/yasserrmd/DentaInstruct-1.2B) |
|
| 615 |
+
📊 [MIRIAD Dataset](https://huggingface.co/datasets/miriad) |
|
| 616 |
+
💬 [Report Issues](https://huggingface.co/spaces/chrisvoncsefalvay/dental-vqa-comparison/discussions)
|
| 617 |
"""
|
| 618 |
)
|
| 619 |
|
| 620 |
# Event handlers
|
| 621 |
def respond(message, chat_history, temperature, max_new_tokens, top_p, repetition_penalty):
|
| 622 |
+
"""Handle user messages and generate responses"""
|
| 623 |
+
if not message.strip():
|
| 624 |
+
gr.Warning("Please enter a question")
|
| 625 |
+
return "", chat_history
|
| 626 |
+
|
| 627 |
+
try:
|
| 628 |
+
response = generate_response(
|
| 629 |
+
message,
|
| 630 |
+
chat_history,
|
| 631 |
+
temperature,
|
| 632 |
+
max_new_tokens,
|
| 633 |
+
top_p,
|
| 634 |
+
repetition_penalty
|
| 635 |
+
)
|
| 636 |
+
chat_history.append((message, response))
|
| 637 |
+
return "", chat_history
|
| 638 |
+
except Exception as e:
|
| 639 |
+
gr.Error(f"An error occurred: {str(e)}")
|
| 640 |
+
return message, chat_history
|
| 641 |
|
| 642 |
+
# Connect event handlers
|
| 643 |
msg.submit(
|
| 644 |
respond,
|
| 645 |
[msg, chatbot, temperature, max_new_tokens, top_p, repetition_penalty],
|
| 646 |
+
[msg, chatbot],
|
| 647 |
+
queue=True
|
| 648 |
)
|
| 649 |
|
| 650 |
submit.click(
|
| 651 |
respond,
|
| 652 |
[msg, chatbot, temperature, max_new_tokens, top_p, repetition_penalty],
|
| 653 |
+
[msg, chatbot],
|
| 654 |
+
queue=True
|
| 655 |
)
|
| 656 |
|
| 657 |
+
clear.click(
|
| 658 |
+
lambda: (None, ""),
|
| 659 |
+
None,
|
| 660 |
+
[chatbot, msg],
|
| 661 |
+
queue=False
|
| 662 |
+
)
|
| 663 |
|
| 664 |
+
# Launch configuration
|
| 665 |
if __name__ == "__main__":
|
| 666 |
+
demo.queue(max_size=10)
|
| 667 |
+
demo.launch(
|
| 668 |
+
share=False,
|
| 669 |
+
show_error=True,
|
| 670 |
+
server_name="0.0.0.0",
|
| 671 |
+
server_port=7860
|
| 672 |
+
)
|