RouteNER is a lightweight (~15MB) BERT-based model meticulously fine-tuned for Trip Planning Entity Recognition (NER) 🧭. Designed to extract critical entities such as "From" (origin), "To" (destination), and "Mode" (transportation method) from natural language travel queries, RouteNER empowers travel assistants 🤖, chatbots 💬, navigation systems 🗺️, and more. Its compact size and high accuracy make it ideal for deployment in resource-constrained environments, delivering robust performance without sacrificing speed.
FromToModeNatural Language Processing (NLP) is a field of artificial intelligence that enables machines to understand, interpret, and generate human language. By combining linguistics, computer science, and machine learning, NLP powers applications like chatbots, translation services, and sentiment analysis. RouteNER leverages NLP to process travel-related queries, transforming unstructured text into structured, actionable data.
Named Entity Recognition (NER) is a subtask of NLP that identifies and classifies key entities in text, such as names, locations, or organizations. In the context of RouteNER, NER is used to extract travel-specific entities (From, To, Mode) with high precision, enabling seamless integration into travel planning workflows.
RouteNER is purpose-built to streamline trip planning by accurately extracting essential travel details from user queries. Whether you're building a virtual travel agent, a navigation app, or a customer service chatbot, RouteNER provides a reliable, lightweight solution for understanding user intent and delivering relevant responses. Its focus on travel-specific entities makes it a specialized tool for the tourism and transportation industries.
| ✨ Feature | 📌 Description |
|---|---|
| 🎯 Task | Named Entity Recognition (NER) for trip planning queries. |
| 🔍 Entities | From (origin), To (destination), Mode (transportation method). |
| 🤖 Model | Fine-tuned BERT-mini (boltuix/bert-mini) for token classification. |
| 🌐 Language | English. |
| ⚖️ Model Size | ~15MB, optimized for low-resource environments like mobile devices. |
| 📚 Library | Hugging Face Transformers. |
| 🔧 Framework | PyTorch. |
| 🚀 Deployment | Lightweight design ensures fast inference, even on edge devices. |
RouteNER is built upon boltuix/bert-mini, a compact variant of the BERT (Bidirectional Encoder Representations from Transformers) architecture. Unlike traditional NLP models that process text unidirectionally, BERT's bidirectional approach captures contextual relationships by analyzing both preceding and following words in a sentence. This enables RouteNER to understand nuanced travel queries with high accuracy.
bert-mini is significantly smaller than larger BERT models (e.g., BERT-base at ~440MB), making it ideal for resource-constrained environments like mobile apps or IoT devices.bert-mini allowed rapid experimentation with part-of-speech tagging and BIO (Beginning, Inside, Outside) schemes, resulting in a robust and precise NER model.By leveraging bert-mini, RouteNER achieves a balance of accuracy, speed, and efficiency, making it a go-to solution for travel-related NLP tasks.
Get started with RouteNER by installing the required dependencies:
pip install transformers torch
Use the Hugging Face pipeline for quick and easy inference.
from transformers import pipeline
# 🤖 Load the model
ner_pipeline = pipeline("token-classification", model="boltuix/RouteNER", aggregation_strategy="simple")
# 📝 Input travel query
query = "I want to travel from New York to Chicago by train."
# 🧠 Perform NER
results = ner_pipeline(query)
# 📤 Display extracted entities
print(results)
🔎 Sample Output
[
{"entity_group": "from_loc", "word": "New York", "score": 0.999},
{"entity_group": "to_loc", "word": "Chicago", "score": 0.998},
{"entity_group": "transport_mode", "word": "train", "score": 0.997}
]
Extract entities into a structured JSON format for integration into travel applications.
from transformers import pipeline
import json
# 🚀 Load the NER model
ner_pipeline = pipeline("token-classification", model="boltuix/RouteNER", aggregation_strategy="simple")
# 🧾 Input query
query = "Plan a trip to New York from San Francisco by flight."
# 🧠 Perform NER
results = ner_pipeline(query)
# 📦 Initialize output dictionary
output = {
"from": "",
"to": "",
"mode": ""
}
# 🧹 Extract entities
for item in results:
entity = item["entity_group"]
word = item["word"].strip(".").strip()
if entity == "from_loc":
output["from"] = word
elif entity == "to_loc":
output["to"] = word
elif entity == "transport_mode":
output["mode"] = word
# 🖨️ Print structured output
print(json.dumps(output, indent=2))
🔎 Sample Output
{
"from": "San Francisco",
"to": "New York",
"mode": "flight"
}
Below are diverse test cases showcasing RouteNER's ability to handle a wide range of travel queries, including complex and unconventional inputs.
✅ Test Case 1
Sentence: Take a flight from San Francisco to Los Angeles.
Output:
✅ Test Case 2
Sentence: I need a bus ticket from Houston to Austin.
Output:
✅ Test Case 3
Sentence: Navigate me from Thompsonburgh - Port MH to Clark LLC HQ 163 5756 Salazar Rapids Suite 176 East Patrickfurt NC 56993 Cook Islands using FlixBus ride.
Output:
✅ Test Case 4
Sentence: Guide me from New Jacqueline Region MA to Port Christine AR via horse-drawn carriage ride.
Output:
✅ Test Case 5
Sentence: Take me from Franklinfurt Downtown MH to Government Stephanieburgh MN 05480 with Canadian VIA Rail.
Output:
✅ Test Case 6
Sentence: Book a ferry from Miami to the Bahamas.
Output:
✅ Test Case 7
Sentence: Plan a road trip from Seattle to Yellowstone National Park by car.
Output:
RouteNER is versatile and can be applied across various domains. Here are some exciting use cases:
RouteNER into websites or apps for destination exploration.Evaluated on a custom dataset, RouteNER delivers impressive results:
| Metric | Score |
|---|---|
| Accuracy | 0.95 |
| Precision | 0.94 |
| Recall | 0.93 |
| F1-Score | 0.94 |
These metrics reflect the model's ability to accurately identify and classify travel entities, even in complex or ambiguous queries.
RouteNER was fine-tuned on a robust dataset comprising:
From, To, Mode) to ensure high-quality training data. The dataset includes both simple queries (e.g., "Fly from Boston to Miami") and complex ones (e.g., addresses with detailed location descriptions), ensuring RouteNER generalizes well across real-world scenarios.
boltuix/bert-mini bert-mini's architecture to capture part-of-speech relationships and entity boundaries.Unlock the full potential of RouteNER with these integration ideas:
RouteNER for specific domains or additional entities.This model is licensed under the Apache 2.0 License.
boltuix/bert-mini. We’d love to hear from you! For questions, feedback, or collaboration opportunities:
Plan your next adventure with RouteNER! 🌍✈️🚄🧳