A small semantic search demo over simulated embedded-system logs. A FastAPI backend embeds each log line with a local Ollama model, indexes the vectors in FAISS, and returns the most similar logs for a free-text query. A Next.js frontend provides a search box and a results table.
- Loads sample logs (
date,log) frombackend/data/logs.csv(sensor readings, CPU/memory/disk usage, network metrics, etc.). - Generates embeddings at startup with the
nomic-embed-textmodel through Ollama. - Normalizes vectors and builds a FAISS
IndexFlatIPindex, so inner product equals cosine similarity. POST /search/takes{"text": "..."}and returns the top 3 matches with date, log text and similarity score.GET /returns a simple status message.- Frontend page with a search input, Search and Clear buttons, and a table showing key, date, log and similarity percentage.
- Backend: Python, FastAPI, Uvicorn, pandas, NumPy, FAISS, Ollama Python client
- Frontend: Next.js 15, React 18, HeroUI, Tailwind CSS, TypeScript
backend/
main.py FastAPI app, embedding and FAISS search
data/logs.csv Sample log data
requirements.txt
frontend/
app/page.tsx Search UI
... Next.js / HeroUI template config
Prerequisites: Python 3, Node.js, and Ollama running locally.
-
Pull the embedding model:
ollama pull nomic-embed-text
-
Start the backend (from
backend/, since the CSV path is relative):cd backend python -m venv .venv && source .venv/bin/activate pip install -r requirements.txt pip install faiss-cpu fastapi dev main.py # serves on http://localhost:8000
Note:
requirements.txtdoes not list FAISS, so it is installed separately here (faiss-cpuis an assumption; any FAISS build providing thefaissmodule works). -
Start the frontend:
cd frontend npm install npm run dev # http://localhost:3000
The frontend calls http://localhost:8000/search/ (hardcoded in frontend/app/page.tsx), and the backend CORS settings allow http://localhost:3000.
Personal use-case project exploring text embeddings and vector search. The frontend is built on the HeroUI Next.js app template.
See the LICENSE file.