Symptom Based Hospital Finder
Sentence embeddings + cosine retrieval for hospital recommendation
NLP
Overview
A team project focused on Natural Language Processing. I explored LLMs, sentence embedding models, and tokenization while implementing weighted embeddings for different data fields. I was responsible for crawling hospital and review data from the “Modoodoc” platform and developing the sentence embedding pipeline.
After benchmarking several Korean-specific models including SRoBERTa, SBERT, and SNUlp, I chose SBERT (jhgan/ko-sroberta-sts) for its superior performance on Korean STS tasks.
Preview
Pipeline — technical architecture
Phase A: Sentence Refinement
When a user enters symptoms, the system uses the Gemini API to bridge “everyday language” and “medical terminology.” Gemini is used to clean up typos and the sentence structures that vary from user to user, and the refined sentence then has the user's current location appended to it to construct the final input to use.
Phase B: Weighted Multi-Field Hospital Embeddings
Hospital data — department, address, hospital name, reviews, and more — is collected from Modoodoc and stored in the database. For every hospital in the database, a single representative vector is created by embedding four fields separately and combining them with specific weights:
| Field | Weight | Description |
|---|---|---|
medical_subject | 0.4 | Primary factor for matching symptoms |
address | 0.4 | Ensures geographic relevance |
hospital_name | 0.1 | Identity context |
opening_hours | 0.1 | Temporal context |
Embeddings are pre-computed and stored as .pt files for low-latency responses.
Phase C: Semantic Ranking & Retrieval
The input refined in Phase A is vectorized using the same model. Cosine similarity is computed against the hospital embedding matrix, and the top-k hospitals (default: 10) with the highest similarity scores are returned.
Key Specifications
| Component | Specification |
|---|---|
| LLM Model | gemini |
| Embedding Model | jhgan/ko-sroberta-sts (HuggingFace) |
| Embedding Dimension | 768 dimensions |
| Similarity Metric | Cosine Similarity |
| Vector Storage | PyTorch Serialization (.pt) |
Pipeline Flow
User input symptom → Gemini (Input Refinement) → SBERT (Query Encoding) → Cosine Similarity vs. Weighted Hospital Matrix → Top-10 Ranking → UI Display