DEV Community

shailendra khade
shailendra khade

Posted on

Build a Simple Local Pune Travel AI with FAISS + Ollama LLM - POC

Ever wondered how to create your own local AI assistant for city tours or travel recommendations? In this POC, we build a Pune Grand Tour AI using FAISS vector database for embeddings and Ollama LLM for generating answers. No Docker, no cloud costs β€” just local Python and embeddings.

Let’s go step by step.

πŸ”ΉPurpose of this POC

Local AI Assistant: A mini ChatGPT specialized for Pune tourism.

Quick Retrieval: Use embeddings for fast similarity search over a curated dataset.

Cost-efficient: No cloud vector DB required β€” FAISS runs entirely locally.

Hands-on AI Exploration: Learn practical AI pipeline: embeddings β†’ vector DB β†’ LLM.

πŸ”Ή Why FAISS?

FAISS (Facebook AI Similarity Search) is a high-performance library for:

Storing vector embeddings.

Performing fast similarity search (like nearest neighbor search).

Working locally, without needing cloud infrastructure.

Key point: FAISS is ideal for projects like ours because all Pune data can fit in memory, and retrieval is very fast.

πŸ”Ή Dataset

We used a simple text dataset (pune_places_chunks.txt) containing Pune's:

  1. Historical forts
  2. Monuments
  3. Museums
  4. Tourist spots

Each line or chunk represents one document. Example:

[PLACE] Shaniwar Wada
Shaniwar Wada is a historic fort located in Pune, built in 1732 by Peshwa Bajirao I.
It served as the administrative center of the Maratha Empire.


[PLACE] Aga Khan Palace
The Aga Khan Palace is known for its association with Mahatma Gandhi and history
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 1: Create Embeddings & FAISS Vector Store

Python script: ingest.py

from langchain_community.document_loaders import TextLoader
from langchain_huggingface import HuggingFaceEmbeddings
from langchain_community.vectorstores import FAISS


# 1 Load processed Pune data
loader = TextLoader("../data/processed/pune_places_chunks.txt")
documents = loader.load()


# 2 Create embeddings
embeddings = HuggingFaceEmbeddings(
    model_name="sentence-transformers/all-MiniLM-L6-v2"
)


# 3 Create FAISS vector store
vectorstore = FAISS.from_documents(documents, embeddings)


# 4 Save vector DB locally
vectorstore.save_local("../embeddings/pune_faiss")


print("Pune embeddings created successfully")

Enter fullscreen mode Exit fullscreen mode

Run:

python ingest.py

Expected output:

Pune embeddings created successfully
Enter fullscreen mode Exit fullscreen mode

Explanation:

TextLoader loads our text chunks.

HuggingFaceEmbeddings converts each document into vector representation.

FAISS.from_documents builds a searchable vector store.

save_local persists the FAISS DB for later retrieval.

πŸ”ΉStep 2: Query FAISS with Ollama LLM

Python script: chat.py

from langchain_community.vectorstores import FAISS
from langchain_huggingface import HuggingFaceEmbeddings
from langchain_ollama import OllamaLLM


# 1 Load embeddings
embeddings = HuggingFaceEmbeddings(
    model_name="sentence-transformers/all-MiniLM-L6-v2"
)
print("Embeddings loaded")


# 2 Load FAISS DB (allow pickle deserialization)
vectordb = FAISS.load_local(
    "../embeddings/pune_faiss",
    embeddings,
    allow_dangerous_deserialization=True
)
print("FAISS Vector DB loaded")


# 3 Ask a question
question = "Tell me famous places to visit in Pune"
docs = vectordb.similarity_search(question, k=3)


if len(docs) == 0:
    print("No documents retrieved. Check embeddings folder.")
    exit(1)


context = "\n".join([d.page_content for d in docs])
print(f"Retrieved docs count: {len(docs)}")
print("Context preview (first 300 chars):")
print(context[:300])


# 4 Initialize Ollama LLM
llm = OllamaLLM(model="llama3")
print("Ollama LLM loaded")


# 5 Build prompt
prompt = f"""
You are a Pune travel guide AI.
Answer using only the context below.


Context:
{context}


Question:
{question}
"""


# 6 Generate AI response
response = llm.invoke(prompt)


print("\nPune AI says:\n")
print(response)

Enter fullscreen mode Exit fullscreen mode

Run:

python chat.py

Sample output:

Embeddings loaded
FAISS Vector DB loaded
Retrieved docs count: 3
Context preview (first 300 chars):
[PLACE] Shaniwar Wada
Shaniwar Wada is a historic fort located in Pune, built in 1732...
Ollama LLM loaded


Pune AI says:


Pune is famous for Shaniwar Wada, Sinhagad Fort, Aga Khan Palace, and Dagdusheth Ganpati Temple.
Enter fullscreen mode Exit fullscreen mode

Explanation:

similarity_search retrieves the top 3 most relevant documents.

Context is combined and sent as a prompt to Ollama LLM.

LLM generates human-like answers based on retrieved Pune knowledge.

πŸ”Ή Step 3: Make it Interactive with Streamlit

We can upgrade this to a fully interactive web app (app.py):

import streamlit as st
from langchain_community.vectorstores import FAISS
from langchain_huggingface import HuggingFaceEmbeddings
from langchain_ollama import OllamaLLM


st.title("Pune Grand Tour AI")
st.write("Ask about Pune's forts, monuments, and travel tips!")


@st.cache_resource
def load_vectorstore():
    embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
    return FAISS.load_local("../embeddings/pune_faiss", embeddings, allow_dangerous_deserialization=True)


@st.cache_resource
def load_llm():
    return OllamaLLM(model="llama3")


vectordb = load_vectorstore()
llm = load_llm()


question = st.text_input("Ask a question about Pune:")


if question:
    docs = vectordb.similarity_search(question, k=3)
    if not docs:
        st.warning("No documents found!")
    else:
        context = "\n".join([d.page_content for d in docs])
        prompt = f"You are a Pune travel guide AI.\n\nContext:\n{context}\n\nQuestion:\n{question}"
        response = llm.invoke(prompt)
        st.subheader("Retrieved Context")
        st.text(context[:500] + ("..." if len(context) > 500 else ""))
        st.subheader("AI Answer")
        st.write(response)
Enter fullscreen mode Exit fullscreen mode

Run:

pip install streamlit
streamlit run app.py

Result:
A browser UI opens where you can ask any Pune-related question, and the AI responds interactively.

πŸ”Ή Key Benefits of this POC

  • Fully Local β€” No cloud or Docker dependency.
  • Fast Retrieval β€” FAISS provides instant similarity search.
  • Context-aware AI β€” Ollama LLM answers based on curated Pune knowledge.
  • Expandable β€” Add more documents, images, or travel tips.
  • Interactive UI β€” Streamlit allows anyone to use the AI easily.

πŸ”Ή Common Issues & Fixes

πŸ”Ή Use Cases

  • Local city guide AI for tourism apps
  • Educational assistant for geography/history lessons
  • Personal knowledge assistant for any curated dataset
  • Prototype for RAG (Retrieval-Augmented Generation) projects

πŸ”Ή Conclusion
With FAISS + Ollama LLM + Streamlit, you can build fast, local, context-aware AI assistants without relying on cloud services or Docker.

This Pune AI POC demonstrates how a specialized knowledge base can power a chatbot capable of giving accurate, context-specific answers.

Top comments (0)