Views
No views yet
| Property | Value |
|---|---|
| Base Model | intfloat/multilingual-e5-large |
| Architecture | XLMRobertaModel (24 layers, 16 heads) |
| Embedding Dimension | 1024 |
| Model Size | 2.2 GB (SafeTensors) |
| Max Sequence Length | 512 tokens |
| Languages | 100 languages (English, Sinhala, Tamil, Hindi, Arabic, Chinese, Japanese, Korean, French, German, Spanish, and 90+ more) |
| License | MIT (model) + ODbL (location data) |
| File | Size | Description |
|---|---|---|
model.safetensors | 2.2 GB | multilingual-e5-large model weights |
models/ | — | Tokenizer, config, and sentence-transformers config |
srilanka_places.db | 38 MB | SQLite database of 117,446 Sri Lanka locations |
srilanka_embeddings_large.npy | ~480 MB | Pre-computed 1024-dim embeddings (117,446 x 1024) |
faiss_index_large.bin | ~480 MB | FAISS IVFFlat index (nlist=200) for instant semantic search |
id_mapping_large.npy | ~2 MB | ID-to-index mapping for result retrieval |
metadata.json | 1 KB | Model metadata and usage information |
| Category | Count | Examples |
|---|---|---|
| 🛣️ Named Roads | 38,874 | A1, E01, Galle Road, Marine Drive |
| 🏠 Buildings | 11,751 | Commercial, residential, government |
| 🏘️ Populated Places | 4,482 | Cities, towns, villages (Colombo, Kandy, Galle, Jaffna, etc.) |
| 🏪 Shops | 4,463 | Retail stores, supermarkets, pharmacies |
| ⛪ Places of Worship | 4,401 | Buddhist temples, churches, mosques, kovils |
| 🏫 Schools | 4,401 | Government schools, international schools, universities |
| 🏥 Hospitals | 902 | Government hospitals, private clinics, Ayurvedic |
| 🚔 Police Stations | 420 | Police stations and posts |
| 🏦 Banks & ATMs | 1,200+ | Commercial banks (BOC, People's Bank, HNB, Commercial Bank, etc.) |
| 🏨 Hotels | 850+ | Hotels, guesthouses, resorts |
| 🍽️ Restaurants | 2,000+ | Restaurants, cafes, food outlets |
| 🏛️ Government Offices | 1,500+ | Divisional secretariats, municipal councils, government departments |
| ⛽ Fuel Stations | 600+ | Petrol stations (Ceypetco, Lanka IOC, etc.) |
| 🌿 Natural Features | 2,500+ | Rivers, mountains, forests, beaches |
| 🚉 Transport Hubs | 350+ | Railway stations, bus stands, airports |
| 🏟️ Landmarks | 1,200+ | Monuments, parks, stadiums, museums |
| 📦 And 10+ more categories | — | Industrial, agricultural, utilities, etc. |
1from sentence_transformers import SentenceTransformer
2import faiss
3import numpy as np
4import sqlite3
5import json
6
7# Load the model
8model = SentenceTransformer('deathlegionteam/sri-lanka-location-intelligence')
9
10# Load FAISS index and ID mapping
11index = faiss.read_index('faiss_index_large.bin')
12id_mapping = np.load('id_mapping_large.npy', allow_pickle=True)
13
14# Connect to database
15conn = sqlite3.connect('srilanka_places.db')
16cursor = conn.cursor()
17
18def search_locations(query, top_k=10):
19 """Search any location in Sri Lanka by semantic query."""
20 # Encode query
21 query_vec = model.encode(['query: ' + query], normalize_embeddings=True)
22
23 # Search FAISS index
24 distances, indices = index.search(query_vec.astype(np.float32), top_k)
25
26 # Fetch results from database
27 results = []
28 for i, idx in enumerate(indices[0]):
29 location_id = id_mapping[idx]
30 cursor.execute("SELECT * FROM locations WHERE id=?", (int(location_id),))
31 row = cursor.fetchone()
32 if row:
33 # Convert sqlite3.Row to dict
34 cols = [d[0] for d in cursor.description]
35 location = dict(zip(cols, row))
36 location['similarity'] = float(distances[0][i])
37 results.append(location)
38
39 return results
40
41# Examples
42results = search_locations("police station in Colombo")
43for r in results[:5]:
44 print(f"{r['name']} — {r['category']} ({r['latitude']}, {r['longitude']})")
45
46results = search_locations("Buddhist temple near Kandy")
47results = search_locations("hospital with emergency services")
48results = search_locations("Colombo 7 restaurant")1def search_by_category(query, category, top_k=10):
2 """Search within a specific category."""
3 query_vec = model.encode(['query: ' + query], normalize_embeddings=True)
4 distances, indices = index.search(query_vec.astype(np.float32), top_k * 3)
5
6 results = []
7 for idx in indices[0]:
8 location_id = id_mapping[idx]
9 cursor.execute("SELECT * FROM locations WHERE id=? AND category=?",
10 (int(location_id), category))
11 row = cursor.fetchone()
12 if row:
13 cols = [d[0] for d in cursor.description]
14 location = dict(zip(cols, row))
15 location['similarity'] = float(distances[0][list(indices[0]).index(idx)])
16 results.append(location)
17 if len(results) >= top_k:
18 break
19 return results
20
21# Find hospitals in the Western Province
22results = search_by_category("government hospital", "hospital", 5)1import math
2
3def haversine(lat1, lon1, lat2, lon2):
4 """Calculate distance in km between two coordinates."""
5 R = 6371
6 dlat = math.radians(lat2 - lat1)
7 dlon = math.radians(lon2 - lon1)
8 a = math.sin(dlat/2)**2 + math.cos(math.radians(lat1)) * \
9 math.cos(math.radians(lat2)) * math.sin(dlon/2)**2
10 return R * 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
11
12def find_nearby(lat, lon, radius_km=5, limit=50):
13 """Find locations near a point."""
14 # Bounding box pre-filter
15 lat_delta = radius_km / 111.0
16 lon_delta = radius_km / (111.0 * abs(math.cos(math.radians(lat))) + 0.001)
17
18 cursor.execute("""
19 SELECT * FROM locations
20 WHERE latitude BETWEEN ? AND ?
21 AND longitude BETWEEN ? AND ?
22 ORDER BY ABS(latitude - ?) + ABS(longitude - ?)
23 LIMIT ?
24 """, (lat - lat_delta, lat + lat_delta,
25 lon - lon_delta, lon + lon_delta,
26 lat, lon, limit * 2))
27
28 rows = cursor.fetchall()
29 cols = [d[0] for d in cursor.description]
30
31 results = []
32 for row in rows:
33 loc = dict(zip(cols, row))
34 dist = haversine(lat, lon, loc['latitude'], loc['longitude'])
35 if dist <= radius_km:
36 loc['distance_km'] = round(dist, 2)
37 results.append(loc)
38 if len(results) >= limit:
39 break
40
41 return results
42
43# Find everything near Colombo Fort
44nearby = find_nearby(6.9344, 79.8428, radius_km=2)| Query | Finds |
|---|---|
"police emergency" | Police stations near you |
"Colombo hospital" | National Hospital of Sri Lanka, private hospitals in Colombo |
"temple tooth relic" | Temple of the Tooth, Kandy |
"galle road restaurant" | Restaurants along Galle Road, Colombo |
"Kandy school" | Schools in Kandy district |
"fuel station A1" | Petrol stations along the A1 highway |
"beach hotel" | Beach resorts and hotels |
"central bank" | Central Bank of Sri Lanka, Colombo |
"විහාරය" (Sinhala) | Buddhist temples |
"கோவில்" (Tamil) | Hindu temples/kovils |
sri-lanka-latest.osm.pbf, 136 MB)User Query (in any language)
↓
multilingual-e5-large (1024-dim embedding)
↓
FAISS IVFFlat Index (nlist=200, cosine similarity)
↓
SQLite Database → Location Name + Coordinates + Category + Tags
↓
Structured Results with similarity scores