A Laravel retrieval pipeline that searches selected portfolio content before asking an AI model to respond. Built to understand, test and explain the trade-offs of a business-content assistant.
Development status: the Ollama and Gemini retrieval paths have been exercised locally. Gemini passed 25 retrieval checks on a 26-question evaluation set; the remaining missing-price case was reviewed through a generated response. The public chatbot endpoint has been verified in RAG mode.
The problem
The original chatbot sent the complete reference content on each request. I built a separate retrieval path to select relevant excerpts and make the sources traceable. For a small portfolio, full context remains a reasonable baseline; retrieval adds complexity and must earn its place through evaluation.
The implementation
Split approved profile, project and service data into 31 topic-based chunks with stable identifiers and source links.
Generate embeddings, store them outside the public website and reuse unchanged vectors using content hashes and a model fingerprint.
Embed each question and compare it with the indexed vectors using cosine similarity in PHP. With this small collection, a dedicated vector database is unnecessary.
Send up to three accepted excerpts and bounded conversation history to Groq. Resolve recognised citation identifiers to source URLs on the server.
What the evaluation revealed
A request for a tattoo studio website retrieved the correct service, but the original threshold discarded it. Adjusting the provisional cutoff from 0.30 to 0.25 and extending the question set produced 19 passing retrieval checks, plus one missing-price case requiring answer review, using local EmbeddingGemma. These figures describe this small test set, not overall chatbot accuracy, and do not apply automatically to Gemini.
A conversation test also exposed first-person wording and unsupported product features. Revised instructions improved the repeated example. This demonstrated why good retrieval and correct citations do not, by themselves, prove a faithful answer.
Operational decisions
Ollama supports local experimentation; a separate Gemini adapter allows hosted embeddings without relying on a personal computer. The providers use separate indexes and calibrated cutoffs: 0.25 for the local EmbeddingGemma experiment and 0.60 for Gemini on the current evaluation set. Re-indexing the unchanged Gemini sources reused all 31 vectors without new embedding requests. Failed indexing preserves the previous file. Gemini requests have a daily application limit and bounded timeouts. Keys, vectors and evaluation reports stay out of the public build.
Limits and next checks
Embedding scores are not confidence percentages. Follow-up handling currently uses a bounded previous question and needs broader topic-switch testing. Switching embedding models requires a fresh index and provider-specific evaluation. The implementation is retrieval-augmented generation, not an autonomous agent.
The hosted RAG endpoint has been exercised with a real request. Further production checks include end-to-end latency under representative traffic and continued review of source-grounded answers. Local response checks covered a follow-up, an unknown hourly rate and an unrelated recipe request. They are examples, not a comprehensive accuracy guarantee.