Updated yesterday
ollama run nishal21/geo-capital-llm
Updated yesterday
yesterday
190367a95592 · 252MB ·
Plain-English geography questions: capitals, cities, countries, timezones, currencies. Most answers come from a verified database, not from a language model.
The included LLM is a fine-tuned GPT-2 trained for under $2 on a rented Vast.ai GPU. We could not afford a larger base model, and training from scratch was not an option either (no budget to run tests or failed experiments). It is fine-tuned on geography Q&A and it is still not good: you will get answers, but they may or may not be correct. That is why this app checks the database first.
Run it:
pip install -r requirements.txt
python src/main.py
Ask> what is the capital of kerala
The capital of kerala is Thiruvananthapuram.
[verified database]
Ask> where is Alappuzha
City: Alappuzha
State/Region: Kerala
Country: India
...
Ask> currency of Japan
The currency of Japan is JPY.
Use the Python app (python src/main.py). That is the intended way to run this project.
| Goal | What to do |
|---|---|
| Capitals, currencies, timezones, populations | Ask normally. These route to the database or Wikidata first. |
City lookups (where is …) |
Use the full place name. If ambiguous, add the country: where is Usa in Japan. |
| Skip the LLM entirely | Append --db or run python src/ask.py --db "your question". |
| Force the LLM only (not recommended) | Append --llm. |
Capitals always go through the database path in the default app. You should not see wrong capital guesses from the model when using main.py normally.
The fine-tuned GPT-2 model is a fallback for questions the database cannot answer. On its own (Ollama, Hugging Face, --llm), it will return text, but accuracy is not guaranteed. Expect wrong or incomplete answers.
Answers are layered:
Question → database / Wikidata → (if no match) → geo-capital-llm
For structured facts, trust the app with [verified database] or [wikidata] in the output. Treat anything from [llm fallback] as a guess.
Requirements: Python 3.10+. About 500 MB extra disk if you download the LLM weights (optional for database-only use).
countries-states-cities-database-master folder).where is ...), you need countries+states+cities.json in the dataset’s json/ folder. It is not in the upstream repo; download it from the dataset releases if missing.pip install -r requirements.txt
python src/main.py
Single question from the command line:
python src/ask.py "what is the capital of India"
python src/ask.py --db "list states in India" # database only, no model load
what is the capital of kerala / vatican city / englandwhere is Malappuram / where is Alappuzhawhat country is Kerala inlist states in Indiacurrency of Japan / timezone of India / population of Indianative language of Indiatell me about Keralawhat is USA (also understands UK, vatican, etc.)Weights: nishal21/geo-capital-llm
| Detail | Value |
|---|---|
| Base model | GPT-2 (124M parameters) |
| Training data | ~277k Q&A pairs from the countries-states-cities dataset |
| Training cost | Under $2 (rented GPU on Vast.ai) |
| Prompt format | Question: what is the capital of Kerala? Answer: |
This model is GPT-2 fine-tuned on geography Q&A. That is the whole story.
We did not have the budget to train a bigger model (Llama, Mistral, etc.) or to train one from scratch. Scratch training needs many GPU hours just to test whether an approach works; we did not have money for those trial runs. What we could afford was one cheap fine-tune of GPT-2: less than $2 on a rented Vast.ai GPU. Fine-tuning helped a little, but the model is still weak by modern standards.
What to expect:
python src/main.py so the database and Wikidata handle the lookup first.If you pull it from Ollama or Hugging Face and ask questions directly, you are using the LLM alone. That is the worst way to use this project.
Download weights into the project:
pip install huggingface_hub
python src/download_hf_model.py
Or load in Python:
from transformers import AutoTokenizer, AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("nishal21/geo-capital-llm")
tokenizer = AutoTokenizer.from_pretrained("nishal21/geo-capital-llm")
ollama pull nishal21/geo-capital-llm
ollama run nishal21/geo-capital-llm "Question: what is the capital of Kerala? Answer:"
python src/quick_train.py # capitals only, faster
python src/full_train.py # full dataset (~280k examples)
python src/vast_train.py # GPU training helper for Vast.ai
Application code: MIT. MIT is kept here because it is simple, widely used for ML tooling, and matches the model card on Hugging Face. No patent clause is needed for this scope.
Geographic data: Countries States Cities Database by dr5hn (ODbL 1.0). Redistributing derived data requires ODbL compliance.
Wikidata enrichment: CC0 where applicable (wikidata.org).
Model weights: nishal21/geo-capital-llm (MIT).