Spaces:
Sleeping
Sleeping
Update README.md
#1
by shak9345 - opened
README.md
CHANGED
|
@@ -1,13 +1,694 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.13'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: HOPEPET AI
|
| 3 |
+
emoji: 🐾
|
| 4 |
+
colorFrom: pink
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.0.0
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# 🐾 HOPEPET AI
|
| 14 |
+
## Pet Care Recommendation & Generation Assistant
|
| 15 |
+
|
| 16 |
+
**HOPEPET** is an AI-powered pet-care assistant for dog and cat owners.
|
| 17 |
+
The app helps users describe a pet-related problem and receive responsible first-step guidance based on similar pet-care cases.
|
| 18 |
+
|
| 19 |
+
The project combines:
|
| 20 |
+
|
| 21 |
+
- Synthetic dataset generation
|
| 22 |
+
- Data validation
|
| 23 |
+
- Descriptive statistics
|
| 24 |
+
- Exploratory Data Analysis
|
| 25 |
+
- Embedding-based recommendation
|
| 26 |
+
- Hugging Face Generative AI
|
| 27 |
+
- A complete user-input-to-AI-output pipeline
|
| 28 |
+
|
| 29 |
+
> **Important:** HOPEPET provides general guidance only and does not replace professional veterinary advice.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
# 1. Project Overview
|
| 34 |
+
|
| 35 |
+
Many pet owners are unsure what to do when their dog or cat shows unusual symptoms, anxiety, appetite changes, behavior problems, or training difficulties.
|
| 36 |
+
|
| 37 |
+
Searching online can be confusing because the same symptom can have a different urgency level depending on:
|
| 38 |
+
|
| 39 |
+
- Pet type
|
| 40 |
+
- Age group
|
| 41 |
+
- Medical background
|
| 42 |
+
- Symptom duration
|
| 43 |
+
- Appetite status
|
| 44 |
+
- Energy level
|
| 45 |
+
- Pain signs
|
| 46 |
+
- Emergency signs
|
| 47 |
+
|
| 48 |
+
For example:
|
| 49 |
+
|
| 50 |
+
- A dog shaking during fireworks may be related to anxiety.
|
| 51 |
+
- A senior cat that suddenly stops eating may require veterinary attention.
|
| 52 |
+
- A puppy biting during playtime may be a training issue.
|
| 53 |
+
- A pet with an existing medical condition may need more careful guidance than a healthy pet.
|
| 54 |
+
|
| 55 |
+
HOPEPET helps by retrieving similar pet-care cases and generating one clear, safety-focused response.
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
# 2. Main Objective
|
| 60 |
+
|
| 61 |
+
The main objective of this project is to build a complete AI application that can:
|
| 62 |
+
|
| 63 |
+
1. Receive a pet-care question from the user.
|
| 64 |
+
2. Convert the user input into an embedding vector.
|
| 65 |
+
3. Compare the user input to the dataset cases.
|
| 66 |
+
4. Retrieve the top 3 most similar cases.
|
| 67 |
+
5. Use a Hugging Face generative model to create one final response.
|
| 68 |
+
6. Provide urgency level, safe first steps, recommended next step, and veterinary warning.
|
| 69 |
+
|
| 70 |
+
---
|
| 71 |
+
|
| 72 |
+
# 3. Full AI Pipeline
|
| 73 |
+
|
| 74 |
+
The final HOPEPET pipeline is:
|
| 75 |
+
|
| 76 |
+
**User input → Embedding model → Top 3 similar cases → Hugging Face generation model → Final AI response**
|
| 77 |
+
|
| 78 |
+

|
| 79 |
+
|
| 80 |
+
This pipeline connects recommendation and generation.
|
| 81 |
+
The recommendation system finds relevant similar cases, and the generation component turns those cases into a clear response for the user.
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
# 4. Dataset Overview
|
| 86 |
+
|
| 87 |
+
The dataset is a synthetic pet-care dataset with structured and text-based fields.
|
| 88 |
+
|
| 89 |
+

|
| 90 |
+
|
| 91 |
+
| Metric | Value |
|
| 92 |
+
|---|---|
|
| 93 |
+
| Project name | HOPEPET |
|
| 94 |
+
| Dataset type | Synthetic text dataset |
|
| 95 |
+
| Number of rows | 10,000 |
|
| 96 |
+
| Domain | Pet care |
|
| 97 |
+
| Supported pets | Dogs and cats |
|
| 98 |
+
| Main AI tasks | Recommendation + Generation |
|
| 99 |
+
| Main retrieval field | `retrieval_text` |
|
| 100 |
+
| Final output | User-facing pet-care guidance |
|
| 101 |
+
|
| 102 |
+
Each row in the dataset represents one possible pet-care case.
|
| 103 |
+
|
| 104 |
+
The dataset includes information such as:
|
| 105 |
+
|
| 106 |
+
- Pet type
|
| 107 |
+
- Pet age
|
| 108 |
+
- Pet age group
|
| 109 |
+
- Medical background
|
| 110 |
+
- Recent change
|
| 111 |
+
- Main symptom
|
| 112 |
+
- Secondary symptoms
|
| 113 |
+
- Symptom duration
|
| 114 |
+
- Appetite status
|
| 115 |
+
- Water intake
|
| 116 |
+
- Energy level
|
| 117 |
+
- Pain signs
|
| 118 |
+
- Emergency signs
|
| 119 |
+
- Problem category
|
| 120 |
+
- Urgency level
|
| 121 |
+
- Recommended next step
|
| 122 |
+
- Triage reason
|
| 123 |
+
- Safe first steps
|
| 124 |
+
- User question
|
| 125 |
+
- Short recommendation
|
| 126 |
+
- Detailed advice
|
| 127 |
+
- Veterinary warning
|
| 128 |
+
- Keywords
|
| 129 |
+
- Retrieval text
|
| 130 |
+
|
| 131 |
+
---
|
| 132 |
+
|
| 133 |
+
# 5. Synthetic Data Generation
|
| 134 |
+
|
| 135 |
+
The dataset was created synthetically for the HOPEPET use case.
|
| 136 |
+
|
| 137 |
+
The goal was to create a large and diverse dataset that supports both:
|
| 138 |
+
|
| 139 |
+
1. Similar case recommendation
|
| 140 |
+
2. AI-generated responses
|
| 141 |
+
|
| 142 |
+
The generation process focused on realistic combinations of symptoms, pet types, age groups, medical backgrounds, urgency levels, and recommendations.
|
| 143 |
+
|
| 144 |
+
## Prompting Techniques Used
|
| 145 |
+
|
| 146 |
+
The synthetic data generation process used several prompting techniques:
|
| 147 |
+
|
| 148 |
+
### Role-Based Prompting
|
| 149 |
+
|
| 150 |
+
The model was asked to act as a dataset creator for a responsible pet-care AI assistant.
|
| 151 |
+
|
| 152 |
+
### Constraint-Based Prompting
|
| 153 |
+
|
| 154 |
+
The data had to follow a specific structure with required columns, controlled categories, and safety-focused outputs.
|
| 155 |
+
|
| 156 |
+
### Variation Prompting
|
| 157 |
+
|
| 158 |
+
The dataset includes different symptoms, pet ages, medical backgrounds, environments, urgency levels, and user goals.
|
| 159 |
+
|
| 160 |
+
### Safety-Focused Prompting
|
| 161 |
+
|
| 162 |
+
The generated cases include emergency signs, veterinary warnings, safe first steps, and responsible recommendations.
|
| 163 |
+
|
| 164 |
+
### Retrieval-Focused Prompting
|
| 165 |
+
|
| 166 |
+
A special column called `retrieval_text` was created.
|
| 167 |
+
This column combines the most important details of each case into one searchable text field for embeddings.
|
| 168 |
+
|
| 169 |
+
---
|
| 170 |
+
|
| 171 |
+
# 6. Data Validation and Quality Checks
|
| 172 |
+
|
| 173 |
+
Before building the AI components, I validated the dataset.
|
| 174 |
+
|
| 175 |
+
The validation process included:
|
| 176 |
+
|
| 177 |
+
- Checking dataset shape
|
| 178 |
+
- Checking column names
|
| 179 |
+
- Checking data types
|
| 180 |
+
- Checking missing values
|
| 181 |
+
- Checking duplicate rows
|
| 182 |
+
- Checking unique values
|
| 183 |
+
- Checking categorical consistency
|
| 184 |
+
- Checking text length fields
|
| 185 |
+
|
| 186 |
+

|
| 187 |
+
|
| 188 |
+
The dataset was cleaned and prepared for analysis.
|
| 189 |
+
After cleaning, the dataset contains no missing values and no duplicate rows.
|
| 190 |
+
|
| 191 |
+
---
|
| 192 |
+
|
| 193 |
+
# 7. Descriptive Statistics
|
| 194 |
+
|
| 195 |
+
## 7.1 Numeric Summary
|
| 196 |
+
|
| 197 |
+
The main numeric fields are:
|
| 198 |
+
|
| 199 |
+
- `pet_age_years`
|
| 200 |
+
- `user_question_word_count`
|
| 201 |
+
- `retrieval_text_word_count`
|
| 202 |
+
- `detailed_advice_word_count`
|
| 203 |
+
|
| 204 |
+
These fields help check whether the values are reasonable and whether the text fields are suitable for the next stages of the project.
|
| 205 |
+
|
| 206 |
+

|
| 207 |
+
|
| 208 |
+
The numeric analysis shows that pet ages are within a realistic range for dogs and cats.
|
| 209 |
+
The text length analysis shows that `retrieval_text` is longer than `user_question`, which is expected because it includes richer structured context.
|
| 210 |
+
|
| 211 |
+
---
|
| 212 |
+
|
| 213 |
+
## 7.2 Categorical Summary
|
| 214 |
+
|
| 215 |
+
The dataset also contains important categorical features.
|
| 216 |
+
|
| 217 |
+
Examples include:
|
| 218 |
+
|
| 219 |
+
- `pet_type`
|
| 220 |
+
- `pet_age_group`
|
| 221 |
+
- `problem_category`
|
| 222 |
+
- `urgency_level`
|
| 223 |
+
- `medical_background`
|
| 224 |
+
- `recommended_next_step`
|
| 225 |
+
|
| 226 |
+
For categorical variables, I checked:
|
| 227 |
+
|
| 228 |
+
- Number of unique values
|
| 229 |
+
- Most frequent value
|
| 230 |
+
- Frequency of the most common value
|
| 231 |
+
- Percentage of the most common value
|
| 232 |
+
|
| 233 |
+

|
| 234 |
+
|
| 235 |
+
This shows that the dataset includes both controlled categories and meaningful variety.
|
| 236 |
+
For example, `pet_type` has a small number of values, while `medical_background` includes more diverse medical contexts.
|
| 237 |
+
|
| 238 |
+
---
|
| 239 |
+
|
| 240 |
+
# 8. Exploratory Data Analysis
|
| 241 |
+
|
| 242 |
+
## 8.1 Pet Type Distribution
|
| 243 |
+
|
| 244 |
+

|
| 245 |
+
|
| 246 |
+
The dataset is almost balanced between dog and cat cases.
|
| 247 |
+
This is important because the app is designed to support both dog and cat owners.
|
| 248 |
+
|
| 249 |
+
---
|
| 250 |
+
|
| 251 |
+
## 8.2 Pet Age Group Distribution
|
| 252 |
+
|
| 253 |
+

|
| 254 |
+
|
| 255 |
+
The dataset includes all major life stages:
|
| 256 |
+
|
| 257 |
+
- Puppies
|
| 258 |
+
- Kittens
|
| 259 |
+
- Adult pets
|
| 260 |
+
- Senior pets
|
| 261 |
+
|
| 262 |
+
Age is important because the same symptom may have a different urgency level depending on the pet’s life stage.
|
| 263 |
+
|
| 264 |
+
---
|
| 265 |
+
|
| 266 |
+
## 8.3 Problem Category Distribution
|
| 267 |
+
|
| 268 |
+

|
| 269 |
+
|
| 270 |
+
The dataset covers several pet-care problem categories:
|
| 271 |
+
|
| 272 |
+
- Health
|
| 273 |
+
- Emergency
|
| 274 |
+
- Anxiety
|
| 275 |
+
- Behavior
|
| 276 |
+
- Training
|
| 277 |
+
- Nutrition
|
| 278 |
+
- Grooming
|
| 279 |
+
|
| 280 |
+
This variety is important because the app needs to support different types of pet-owner questions.
|
| 281 |
+
|
| 282 |
+
---
|
| 283 |
+
|
| 284 |
+
## 8.4 Urgency Level Distribution
|
| 285 |
+
|
| 286 |
+

|
| 287 |
+
|
| 288 |
+
The dataset includes four urgency levels:
|
| 289 |
+
|
| 290 |
+
- Low
|
| 291 |
+
- Medium
|
| 292 |
+
- High
|
| 293 |
+
- Emergency
|
| 294 |
+
|
| 295 |
+
This allows HOPEPET to provide different levels of guidance depending on the seriousness of the case.
|
| 296 |
+
|
| 297 |
+
---
|
| 298 |
+
|
| 299 |
+
## 8.5 Medical Background Distribution
|
| 300 |
+
|
| 301 |
+

|
| 302 |
+
|
| 303 |
+
Medical background is important because the same symptom can require different guidance depending on the pet’s health history.
|
| 304 |
+
|
| 305 |
+
---
|
| 306 |
+
|
| 307 |
+
# 9. Relationship and Consistency Analysis
|
| 308 |
+
|
| 309 |
+
## 9.1 Problem Category vs Urgency Level
|
| 310 |
+
|
| 311 |
+

|
| 312 |
+
|
| 313 |
+
This heatmap checks whether different problem categories are connected to reasonable urgency levels.
|
| 314 |
+
|
| 315 |
+
Emergency cases should be strongly connected to Emergency urgency.
|
| 316 |
+
Training, grooming, and nutrition cases are usually less urgent.
|
| 317 |
+
|
| 318 |
+
This supports the logic and responsibility of the dataset.
|
| 319 |
+
|
| 320 |
+
---
|
| 321 |
+
|
| 322 |
+
## 9.2 Pet Age Group and Urgency Level
|
| 323 |
+
|
| 324 |
+

|
| 325 |
+
|
| 326 |
+
This bubble chart shows how pet age groups are distributed across urgency levels.
|
| 327 |
+
|
| 328 |
+
It confirms that puppies, kittens, adult pets, and senior pets are represented across the dataset.
|
| 329 |
+
|
| 330 |
+
---
|
| 331 |
+
|
| 332 |
+
## 9.3 Emergency Signs and Urgency Distribution
|
| 333 |
+
|
| 334 |
+

|
| 335 |
+
|
| 336 |
+
This graph is one of the most important safety checks.
|
| 337 |
+
|
| 338 |
+
Cases with emergency signs are connected to Emergency urgency.
|
| 339 |
+
This supports the safety logic of the dataset and helps ensure that high-risk cases receive appropriate recommendations.
|
| 340 |
+
|
| 341 |
+
---
|
| 342 |
+
|
| 343 |
+
## 9.4 Recommended Next Step by Urgency Level
|
| 344 |
+
|
| 345 |
+

|
| 346 |
+
|
| 347 |
+
This heatmap checks whether the recommended next step matches the urgency level.
|
| 348 |
+
|
| 349 |
+
For example:
|
| 350 |
+
|
| 351 |
+
- Low urgency cases should lead to home monitoring.
|
| 352 |
+
- Medium urgency cases should lead to close monitoring.
|
| 353 |
+
- High urgency cases should lead to contacting a veterinarian soon.
|
| 354 |
+
- Emergency cases should lead to immediate emergency veterinary care.
|
| 355 |
+
|
| 356 |
+
This confirms that the recommendations are consistent with the urgency level.
|
| 357 |
+
|
| 358 |
+
---
|
| 359 |
+
|
| 360 |
+
## 9.5 High-Risk Cases by Medical Background
|
| 361 |
+
|
| 362 |
+

|
| 363 |
+
|
| 364 |
+
This graph shows the percentage of High or Emergency cases within each medical background.
|
| 365 |
+
|
| 366 |
+
This is important because pets with existing medical conditions may require more careful guidance.
|
| 367 |
+
|
| 368 |
+
---
|
| 369 |
+
|
| 370 |
+
## 9.6 Recommended Next Step by Problem Category
|
| 371 |
+
|
| 372 |
+

|
| 373 |
+
|
| 374 |
+
This graph shows how recommended next steps vary across problem categories.
|
| 375 |
+
|
| 376 |
+
It demonstrates that the dataset does not provide the same recommendation for every case, but adjusts the next step based on the type and seriousness of the problem.
|
| 377 |
+
|
| 378 |
+
---
|
| 379 |
+
|
| 380 |
+
## 9.7 High-Risk Rate by Appetite and Energy
|
| 381 |
+
|
| 382 |
+

|
| 383 |
+
|
| 384 |
+
This graph checks the relationship between appetite status, energy level, and high-risk cases.
|
| 385 |
+
|
| 386 |
+
This is useful because appetite and energy are important indicators in pet-care situations.
|
| 387 |
+
|
| 388 |
+
---
|
| 389 |
+
|
| 390 |
+
## 9.8 Risk Lift by Recent Change
|
| 391 |
+
|
| 392 |
+

|
| 393 |
+
|
| 394 |
+
This graph shows whether recent changes are associated with higher or lower high-risk rates compared to the overall dataset.
|
| 395 |
+
|
| 396 |
+
Recent changes can be important context when evaluating a pet’s condition.
|
| 397 |
+
|
| 398 |
+
---
|
| 399 |
+
|
| 400 |
+
# 10. Text Analysis for Embeddings
|
| 401 |
+
|
| 402 |
+
The recommendation system uses the `retrieval_text` column.
|
| 403 |
+
|
| 404 |
+
The `retrieval_text` field combines important structured case information into one searchable text.
|
| 405 |
+
|
| 406 |
+
It includes:
|
| 407 |
+
|
| 408 |
+
- Pet type
|
| 409 |
+
- Age group
|
| 410 |
+
- Medical background
|
| 411 |
+
- Main symptom
|
| 412 |
+
- Secondary symptoms
|
| 413 |
+
- Symptom duration
|
| 414 |
+
- Appetite status
|
| 415 |
+
- Energy level
|
| 416 |
+
- Pain signs
|
| 417 |
+
- Emergency signs
|
| 418 |
+
- Urgency level
|
| 419 |
+
- Recommended next step
|
| 420 |
+
|
| 421 |
+
This gives the embedding model more context than using the user question alone.
|
| 422 |
+
|
| 423 |
+
The reason I used `retrieval_text` is that semantic search works better when the model receives the full context of the case, not only the short user question.
|
| 424 |
+
|
| 425 |
+
---
|
| 426 |
+
|
| 427 |
+
# 11. Recommendation with Embeddings
|
| 428 |
+
|
| 429 |
+
The recommendation task is a text-to-vector similarity task.
|
| 430 |
+
|
| 431 |
+
Each case in the dataset is converted into a numerical vector using a Hugging Face embedding model.
|
| 432 |
+
|
| 433 |
+
The user input is also converted into a vector.
|
| 434 |
+
|
| 435 |
+
Then, cosine similarity is used to retrieve the most similar cases from the dataset.
|
| 436 |
+
|
| 437 |
+
The recommendation pipeline is:
|
| 438 |
+
|
| 439 |
+
1. User enters a pet-care question.
|
| 440 |
+
2. The question is converted into an embedding.
|
| 441 |
+
3. The system compares it to all saved dataset embeddings.
|
| 442 |
+
4. The system retrieves the top 3 most similar cases.
|
| 443 |
+
5. The retrieved cases are used as context for the generation step.
|
| 444 |
+
|
| 445 |
+
---
|
| 446 |
+
|
| 447 |
+
## 11.1 Tested Hugging Face Embedding Models
|
| 448 |
+
|
| 449 |
+
I tested three Hugging Face embedding models:
|
| 450 |
+
|
| 451 |
+
| Model | Type |
|
| 452 |
+
|---|---|
|
| 453 |
+
| `sentence-transformers/all-MiniLM-L6-v2` | Text embedding |
|
| 454 |
+
| `sentence-transformers/paraphrase-MiniLM-L3-v2` | Text embedding |
|
| 455 |
+
| `sentence-transformers/all-mpnet-base-v2` | Text embedding |
|
| 456 |
+
|
| 457 |
+
The models were evaluated using test queries with expected problem categories.
|
| 458 |
+
|
| 459 |
+
The score used here is a retrieval hit rate, not traditional classification accuracy.
|
| 460 |
+
A Top 3 hit means that the expected problem category appeared somewhere within the top 3 retrieved cases.
|
| 461 |
+
|
| 462 |
+
---
|
| 463 |
+
|
| 464 |
+
## 11.2 Embedding Model Evaluation
|
| 465 |
+
|
| 466 |
+
| Model | Embedding Dimension | Runtime Seconds | Top 3 Category Hit Rate | Top 5 Category Hit Rate |
|
| 467 |
+
|---|---:|---:|---:|---:|
|
| 468 |
+
| all-MiniLM-L6-v2 | 384 | 100.03 | 1.00 | 1.00 |
|
| 469 |
+
| paraphrase-MiniLM-L3-v2 | 384 | 25.77 | 0.83 | 1.00 |
|
| 470 |
+
| all-mpnet-base-v2 | 768 | 610.24 | 1.00 | 1.00 |
|
| 471 |
+
|
| 472 |
+

|
| 473 |
+
|
| 474 |
+
---
|
| 475 |
+
|
| 476 |
+
## 11.3 Selected Embedding Model
|
| 477 |
+
|
| 478 |
+
The selected embedding model is:
|
| 479 |
+
|
| 480 |
+
`sentence-transformers/all-MiniLM-L6-v2`
|
| 481 |
+
|
| 482 |
+
This model was selected because it provided the best balance between:
|
| 483 |
+
|
| 484 |
+
- Retrieval quality
|
| 485 |
+
- Runtime
|
| 486 |
+
- Embedding size
|
| 487 |
+
- Practical usability for the final Gradio app
|
| 488 |
+
|
| 489 |
+
Although `all-mpnet-base-v2` also performed well, it was much slower and produced larger embeddings.
|
| 490 |
+
Although `paraphrase-MiniLM-L3-v2` was faster, it had lower Top 3 retrieval performance.
|
| 491 |
+
|
| 492 |
+
The final embedding matrix has the shape:
|
| 493 |
+
|
| 494 |
+
`(10000, 384)`
|
| 495 |
+
|
| 496 |
+
This means that each of the 10,000 pet-care cases was converted into a 384-dimensional vector.
|
| 497 |
+
|
| 498 |
+
The embeddings were saved so the app can load them directly without recalculating them every time.
|
| 499 |
+
|
| 500 |
+
---
|
| 501 |
+
|
| 502 |
+
# 12. Recommendation Output
|
| 503 |
+
|
| 504 |
+
The recommendation function returns the top 3 most similar cases.
|
| 505 |
+
|
| 506 |
+
Each recommendation includes:
|
| 507 |
+
|
| 508 |
+
- Case ID
|
| 509 |
+
- Pet type
|
| 510 |
+
- Pet age group
|
| 511 |
+
- Problem category
|
| 512 |
+
- Urgency level
|
| 513 |
+
- Recommended next step
|
| 514 |
+
- Short recommendation
|
| 515 |
+
- Veterinary warning
|
| 516 |
+
- Similarity score
|
| 517 |
+
|
| 518 |
+
Example input:
|
| 519 |
+
|
| 520 |
+
> My senior cat stopped eating today and seems very tired.
|
| 521 |
+
|
| 522 |
+
Expected behavior:
|
| 523 |
+
|
| 524 |
+
The system should retrieve cases related to cats, appetite loss, tiredness, health or nutrition concerns, and higher urgency.
|
| 525 |
+
|
| 526 |
+
Another example input:
|
| 527 |
+
|
| 528 |
+
> My dog is shaking and hiding during fireworks.
|
| 529 |
+
|
| 530 |
+
Expected behavior:
|
| 531 |
+
|
| 532 |
+
The system should retrieve dog-related anxiety cases.
|
| 533 |
+
|
| 534 |
+
---
|
| 535 |
+
|
| 536 |
+
# 13. Generation Component
|
| 537 |
+
|
| 538 |
+
HOPEPET includes a Generative AI component using a Hugging Face model.
|
| 539 |
+
|
| 540 |
+
The generation component receives:
|
| 541 |
+
|
| 542 |
+
- The user question
|
| 543 |
+
- The top 3 retrieved similar cases
|
| 544 |
+
- Problem category
|
| 545 |
+
- Urgency level
|
| 546 |
+
- Triage reason
|
| 547 |
+
- Safe first steps
|
| 548 |
+
- Recommended next step
|
| 549 |
+
- Veterinary warning
|
| 550 |
+
|
| 551 |
+
Then it generates one final user-facing response.
|
| 552 |
+
|
| 553 |
+
The response is designed to be:
|
| 554 |
+
|
| 555 |
+
- Clear
|
| 556 |
+
- Helpful
|
| 557 |
+
- Responsible
|
| 558 |
+
- Safety-focused
|
| 559 |
+
- Based on retrieved cases
|
| 560 |
+
- Not a medical diagnosis
|
| 561 |
+
|
| 562 |
+
---
|
| 563 |
+
|
| 564 |
+
# 14. Generated Response Structure
|
| 565 |
+
|
| 566 |
+
The generated response should include:
|
| 567 |
+
|
| 568 |
+
1. Main concern
|
| 569 |
+
2. Estimated urgency level
|
| 570 |
+
3. Recommended next step
|
| 571 |
+
4. Safe first steps
|
| 572 |
+
5. Veterinary warning
|
| 573 |
+
6. Safety disclaimer
|
| 574 |
+
|
| 575 |
+
Example response structure:
|
| 576 |
+
|
| 577 |
+
> Based on similar cases, this situation may be related to a health concern.
|
| 578 |
+
> The estimated urgency level is High.
|
| 579 |
+
> Contact a veterinarian as soon as possible, especially if the pet is not eating, seems weak, shows pain, or the condition is worsening.
|
| 580 |
+
> This app provides general guidance only and does not replace professional veterinary advice.
|
| 581 |
+
|
| 582 |
+
---
|
| 583 |
+
|
| 584 |
+
# 15. Final Application Logic
|
| 585 |
+
|
| 586 |
+
The final application combines recommendation and generation.
|
| 587 |
+
|
| 588 |
+
The app flow is:
|
| 589 |
+
|
| 590 |
+
1. The user describes a pet-care problem.
|
| 591 |
+
2. The app converts the input into an embedding.
|
| 592 |
+
3. The app retrieves the top 3 most similar cases.
|
| 593 |
+
4. The app uses the retrieved cases as context.
|
| 594 |
+
5. A Hugging Face generative model creates one final response.
|
| 595 |
+
6. The user receives both similar case information and a generated explanation.
|
| 596 |
+
|
| 597 |
+
The final app displays:
|
| 598 |
+
|
| 599 |
+
- User input
|
| 600 |
+
- Top 3 similar cases
|
| 601 |
+
- AI-generated response
|
| 602 |
+
- Safety disclaimer
|
| 603 |
+
|
| 604 |
+
---
|
| 605 |
+
|
| 606 |
+
# 16. Quick Starter Examples
|
| 607 |
+
|
| 608 |
+
The final Gradio app includes three quick starter examples:
|
| 609 |
+
|
| 610 |
+
1. `My dog is shaking and hiding during fireworks.`
|
| 611 |
+
2. `My senior cat stopped eating today and seems very tired.`
|
| 612 |
+
3. `My puppy keeps biting my hands during playtime.`
|
| 613 |
+
|
| 614 |
+
These examples test different parts of the system:
|
| 615 |
+
|
| 616 |
+
- Anxiety
|
| 617 |
+
- Health / nutrition concern
|
| 618 |
+
- Training
|
| 619 |
+
|
| 620 |
+
---
|
| 621 |
+
|
| 622 |
+
# 17. Technologies Used
|
| 623 |
+
|
| 624 |
+
The project uses:
|
| 625 |
+
|
| 626 |
+
- Python
|
| 627 |
+
- Pandas
|
| 628 |
+
- NumPy
|
| 629 |
+
- Matplotlib
|
| 630 |
+
- Scikit-learn
|
| 631 |
+
- Sentence Transformers
|
| 632 |
+
- Hugging Face Transformers
|
| 633 |
+
- Hugging Face Models
|
| 634 |
+
- Gradio
|
| 635 |
+
- Google Colab
|
| 636 |
+
|
| 637 |
+
---
|
| 638 |
+
|
| 639 |
+
# 18. Safety Disclaimer
|
| 640 |
+
|
| 641 |
+
HOPEPET provides general guidance only and does not replace professional veterinary advice.
|
| 642 |
+
|
| 643 |
+
If a pet has difficulty breathing, seizures, bleeding, possible poisoning, repeated vomiting, severe weakness, collapse, or cannot stand, the user should contact a veterinarian or emergency clinic immediately.
|
| 644 |
+
|
| 645 |
+
The app should not be used for diagnosis or emergency decision-making.
|
| 646 |
+
|
| 647 |
+
---
|
| 648 |
+
|
| 649 |
+
# 19. Project Limitations
|
| 650 |
+
|
| 651 |
+
This project has several limitations:
|
| 652 |
+
|
| 653 |
+
- The dataset is synthetic.
|
| 654 |
+
- The app does not diagnose medical conditions.
|
| 655 |
+
- The app does not replace a veterinarian.
|
| 656 |
+
- The generated response depends on the quality of the retrieved similar cases.
|
| 657 |
+
- The model should be used only for general first-step guidance.
|
| 658 |
+
- Real-world deployment would require expert veterinary review and stronger safety validation.
|
| 659 |
+
|
| 660 |
+
---
|
| 661 |
+
|
| 662 |
+
# 20. Future Improvements
|
| 663 |
+
|
| 664 |
+
Possible future improvements include:
|
| 665 |
+
|
| 666 |
+
- Adding real anonymized veterinary guidance data
|
| 667 |
+
- Adding more pet types
|
| 668 |
+
- Improving the generation model
|
| 669 |
+
- Adding multilingual support
|
| 670 |
+
- Adding stronger safety filters
|
| 671 |
+
- Adding user feedback
|
| 672 |
+
- Improving recommendation evaluation with more test queries
|
| 673 |
+
- Adding more detailed emergency detection
|
| 674 |
+
- Adding structured user forms for more accurate recommendations
|
| 675 |
+
|
| 676 |
+
---
|
| 677 |
+
|
| 678 |
+
# 21. Final Summary
|
| 679 |
+
|
| 680 |
+
HOPEPET demonstrates a complete AI application pipeline.
|
| 681 |
+
|
| 682 |
+
The project includes:
|
| 683 |
+
|
| 684 |
+
1. Synthetic dataset creation
|
| 685 |
+
2. Data validation
|
| 686 |
+
3. Descriptive statistics
|
| 687 |
+
4. Exploratory Data Analysis
|
| 688 |
+
5. Embedding-based recommendation
|
| 689 |
+
6. Hugging Face text generation
|
| 690 |
+
7. User-facing AI response
|
| 691 |
+
|
| 692 |
+
The project shows how retrieval and generation can work together to create a responsible AI assistant for pet-care guidance.
|
| 693 |
+
|
| 694 |
+
The recommendation system retrieves similar cases, and the generation component turns those cases into a clear and safety-focused response for the user.
|