How to Build a Smart Cart Kiosk That Doesn’t Need the Cloud (CLIP + Qdrant Edge + Gemma)
From the publisher’s feed, collected in the ZeroLabs newsroom.
A multimodal agentic RAG system that runs entirely on your machine with the tech of 2026 — and that’s right: no cloud, no API keys, no infrastructure headaches.Consider this. You walk into a supermarket. You are looking for almond milk. You go to the dairy aisle — nothing. You ask the one staff member standing nearby and they point you to aisle seven. You find it.But what if there was no staff member? What if instead there was a kiosk with a screen at the entrance and you could just ask it in plain English, “where is dairy-free milk,” and it would tell you exactly where to go, what it costs, and why it fits in with what you’re looking for?That is what I built. A retail kiosk that understands what you are asking, not just the words you used. And the entire thing runs offline on a laptop via Ollama — with no cloud calls, no API billing, and no customer data leaving the machine. I called it the Smart Cart.The full implementation is on GitHub. You can follow along with the code as you read through this.The Problem That Started ThisMost retail search engines are bound by keywords. If a customer types “milk,” the system looks for that exact string in the database. But if they type “dairy free,” “lactose alternative,” or “vegan beverage,” standard keyword matching fails completely. None of those queries contain the word “milk,” meaning the system returns nothing useful, and the customer walks away empty-handed.To solve this, Smart Cart uses a dual-path embedding approach. Instead of keyword matching, we map the semantic meanings of text queries, audio signals, and visual camera scans into vector spaces. This allows the kiosk to understand the intent behind a query. For instance, the query “dairy-free alternative” clusters near “So Good Almond Milk” in the vector space, returning the correct recommendation immediately without requiring any keyword overlap..So Let’s Get to Know the Backbone — Qdrant EdgeQdrant Edge is probably easiest to think of as SQLite for vector databases.Instead of spinning up a separate server, managing containers, or worrying about ports, you simply install it as a Python package and start using it. No Docker, no background services, no ports to manage. It opens a local directory on disk and treats it as a shard, with all vector indexing and querying happening directly inside your Python process. Everything persists between runs just like any other file on your machine.What I liked most while building this Smart Cart was how invisible it felt. The vector database becomes part of your application rather than another piece of infrastructure you need to maintain.For a retail kiosk, that matters a lot.If someone walks into a store and asks where they can find almond milk, the kiosk should not depend on an internet connection to answer that question. Even if the store WiFi goes down, it should keep working exactly the same way.That is where Qdrant Edge fits the bill. The entire vector database — all ten products and all four vector types — lives inside a local qdrant_storage/ folder in the project. During ingestion the application writes embeddings into that folder, and during retrieval it reads them back from the same place. No separate database server, no network calls, and no coordination layer sitting in the middle.It is a surprisingly simple setup, but for an offline-first project like Smart Cart, that simplicity ended up being one of its biggest strengths.Architecture OverviewThe system has two phases. Ingestion runs once. The query loop runs every time a customer interacts with the kiosk.Ingestion:For each product, generate a MiniLM-L6 text embedding from the product metadata and parse associated nutrition PDFs using pdfplumber for the nutrition_pdf slot.Optionally generate a CLIP image embedding from the product photo.Generate a Whisper audio embedding from a TTS-synthesised voice sample of the product name.Store all vectors into Qdrant Edge under named vector slots: barcode_visual (CLIP), voice_query (MiniLM), nutrition_pdf (MiniLM), and audio_waveform (Whisper).Query loop (per customer request):Embed input: text via MiniLM, images via CLIP, or voice via Whisper ASR for superior transcription accuracy.Run cosine similarity search against the relevant named vector in Qdrant.Build a RAG context string from the top-3 matching products.Pass context to Gemma 4 12B via the local Ollama API (localhost:11434) to generate a recommendation.Return the recommendation to the UI (and optionally read it aloud via TTS).The left side runs once per product catalogue update. The right side runs in milliseconds for retrieval — with Gemma 4 12B inference now taking only 5–10 seconds on consumer Apple Silicon MPS.Why Are We Building This?Now, a true offline retail kiosk can’t just rely on standard text typing, it needs to be a genuine multi-sensory assistant. In the next few sections, we’re going to dive into how we wired up these multimodal capabilities.We’ll look at how a user can walk up and query the kiosk in three distinct ways: typing their question, speaking naturally to activate local speech-to-text, or scanning actual product barcodes in front of a WebRTC camera feed. More importantly, we’ll examine how the system processes these diverse signals under the hood from parsing raw nutrition datasheets to hot-syncing inventory levels in real-time across active terminals.Here is how it all fits together.Tech StackNutrition PDF Ingestion & Semantic Query RoutingIn Smart Cart, ingest.py now utilizes pdfplumber to extract text from product-specific PDFs located in data/pdfs/. This rich nutritional data is embedded using the MiniLM model and stored in the nutrition_pdf vector slot. At query time, the system performs Semantic Query Routing: if a user’s text contains keywords like “calories,” “sugar,” or “allergic,” the AgentService automatically routes the search to the nutrition_pdf index instead of the standard voice_query index for better precision.Real-Time Sync & WebSocket OrchestrationHave you ever used an application where you changed a setting on one page, only to realize you had to manually refresh every other screen or tab to see the update? We definitely didn’t want that kind of clunky lag on a retail kiosk. If a store manager marks a hot item as out of stock in the backend, the customer looking at the kiosk terminal at the entrance needs to know about it right away.To bridge this gap, we set up a live WebSocket handler under /ws/kiosk inmain.py. This acts as a persistent communication bridge between our FastAPI server and any connected frontend screens. When a manager toggles a product’s availability on the Admin Dashboard, it hits our PATCH stock update endpoint.Instead of running a heavy pipeline to re-calculate or re-upload the product’s neural embeddings, we leveraged Qdrant’s set_payload API. This allows us to modify the stock_status flag directly within the existing vector point’s metadata on disk. Because we skip the neural network embedding step entirely, the database update is instantaneous. Once updated, the backend immediately broadcasts the change to all connected kiosks over the WebSocket, updating the catalog view in real time.Dual-Mode Voice ProcessingThe architecture employs a dual-mode strategy for voice. While ingestion stores acoustic features synthesized via pyttsx3 in the audio_waveform slot to represent how a product “sounds,” live queries prioritize transcription accuracy. The system uses Whisper ASR first to convert the customer’s speech into text before performing a vector search, ensuring the LLM receives clean, actionable input.What you could swap in:● Ollama Setup: Ensure you have Ollama running locally. The system defaults to gemma4:12b for superior reasoning.● CLIP → SigLIP: Google’s improved version, same API, better zero-shot accuracy.● Qdrant Edge → ChromaDB: Slightly different API but same embedded concept if you want Python-native persistence.Get Ready to Build with MeStep 1 — Feature Extraction and Vector ProjectionThe foundation of our multimodal search lies in how we calculate embeddings for text, images, and audio waveforms before upserting them to Qdrant. In ingest.py, we load the CLIP processor and model to handle image embeddings. To compute clean 512-dimensional visual vectors from camera frames, we explicitly pass inputs through CLIP’s vision model and project them into the contrastive space, applying L2 normalization:# Extract and project visual featuresvision_out = model.vision_model(pixel_values=pixel_values)features = model.visual_projection(vision_out.pooler_output)features = features / features.norm(dim=-1, keepdim=True) # L2 normaliseFor text queries, we utilize all-MiniLM-L6-v2 in retriever_service.py to produce highly precise 384-dimensional text embeddings, while audio_embed_service.py processes raw audio waveforms through the Whisper-base encoder.This structured projection ensures that regardless of the input modality, all vectors are cleanly formatted, normalized, and mapped to their corresponding named slots in Qdrant.Step 2 — Ingesting the Product CatalogueThe product catalogue lives in data/products.json. Ten SKUs covering milk, oats, tea, pancake mix, yogurt, lentils, snacks, supplements, and coconut oil — a realistic slice of an Indian supermarket’s health food section.Running ingest populates all four named vector slots for each product:.venv/bin/python3.11 ingest.pyA note on the image warnings: the ingest script expects product photos at data/images/{product_id}.jpg. Since the repo does not ship actual product images, it substitutes a grey 224×224 placeholder for the barcode_visual vector. Text and voice search are unaffected — those use CLIP text embeddings and Whisper audio embeddings respectively, and both work correctly. If you drop real product images into data/images/, re-running ingest.py will overwrite just those vectors using deterministic UUIDs without touching anything else.The Nutrition PDF Ingestion & Semantic Query Routing LayerTo give our kiosk deep knowledge of ingredients and allergens, we added PDF sheet extraction. During ingestion, ingest.py reads product-specific PDFs in data/pdfs/ using the pdfplumber library. This text is embedded with our sentence-transformers/all-MiniLM-L6-v2 model and saved into the nutrition_pdf named vector slot. At query time, we perform Semantic Query Routing in retriever_service.py: if a user’s text contains keywords like ‘calories,’ ‘sugar,’ or ‘allergic,’ the system automatically searches the nutrition_pdf index instead of the standard voice_query index for maximum precision.Step 3 — The Agentic RAG LoopThis is where the project earns the name “agentic.” The AgentService is not just a retriever that formats results. It has agency over what it does with the query. The loop looks like this:def respond(self, user_input, input_type, aisle_number=None, products=None):# Retrieval is skipped when the caller provides pre-fetched products.# This prevents double-retrieval and ensures Gemma reasons about# the exact same products shown to the customer.if products is None:products = self._retrieve(user_input, input_type, aisle_number)context = self._build_context(products, query_str)response = self._call_gemma(context)if input_type == "audio":self._speak_async(response)return responseTo ensure absolute consistency, the API endpoint retrieves the products first and passes them directly to the respond() method. This design guarantees that Gemma reasons about the exact same products currently shown to the customer on the kiosk screen, providing a single source of truth.The fix is the products parameter. The endpoint does retrieval first, passes the results directly to the agent, and the agent skips its internal retrieval entirely. One retrieval, one source of truth.The system prompt for Gemma is deliberately constrained:_SYSTEM_PROMPT = ("You are a friendly, knowledgeable retail assistant at an Indian supermarket kiosk. ""You have been given the top product matches from our store database. ""Based only on the provided product data, give the customer a clear, helpful, ""spoken-style recommendation in 2–3 sentences. ""Mention aisle number and price in INR. ""If the customer asked for a dietary alternative, explain why your suggestion fits. ""Never mention model names, databases, or technical details.")That last line “never mention model names or databases” is important for a kiosk UX. The customer does not care that the answer came from a vector similarity search followed by a generative model. They just want to find their product.Step 4 — The FastAPI BackendThe server exposes three query endpoints plus a WebSocket for real-time kiosk state:The text endpoint in action:curl -X POST http://localhost:8000/query/text \-H "Content-Type: application/json" \-d '{"query":"where is milk"}' \ - max-time 600Response:{"response": "Okay, looking for milk? I'd recommend the Amul Taaza Full Cream Milk - it's in Aisle 3 and costs just ₹68.00. It's fresh, creamy cow's milk packed with calcium and protein, perfect if you enjoy drinking it plain or using it in your favourite recipes!","products": […]}Note that the top-scored product by cosine similarity was actually the almond milk (0.6055) because “where is milk” semantically clusters near the dairy-free section. But Gemma read the full context — all three retrieved products — and correctly surfaced Amul Taaza as the primary recommendation because the query did not signal any dietary restriction. The reasoning layer is doing real work here, not just parroting the top retrieval result.For database lock safety, the server initializes Qdrant Edge inside the FastAPI lifespan startup event. Since Qdrant Edge uses a local file-based lock, this ensures that the storage lock is managed safely within the application process lifecycle.Step 5 — The Next.js Kiosk UIThe UI has four interaction modes:● Text search — type a query, get a recommendation. Works right now.● Voice search — tap the mic button, speak your query. The system runs Whisper ASR transcription then the same text retrieval pipeline. The audio endpoint in the backend does this:transcribed_text = _audio_embed_svc.transcribe(data)products = _retriever_svc.search_by_text(transcribed_text)response = _agent_svc.respond(transcribed_text, input_type="audio", products=products)Note: input_type=”audio” is passed through so Gemma responds with TTS output, but the retrieval uses the ASR transcription as a text query. This is the correct architecture — Whisper audio embeddings are used for the audio_waveform vector slot during ingestion (encoding what each product “sounds like” when spoken), but live voice queries go through ASR first because the Whisper encoder output for a customer’s voice would not reliably match the stored product audio embeddings.Dual-Mode Voice Processing: ASR vs. Acoustic SearchFor voice inputs, the system maintains a dual-path capability. During ingestion, we generate pyttsx3 voice waveforms representing what a product ‘sounds’ like, saving them in the audio_waveform slot via Whisper embeddings. However, for live queries, the /query/audio endpoint prioritizes transcription accuracy by running Whisper ASR first to convert customer speech to clean text, before querying the MiniLM text database.Image/Barcode ScanPoint the camera at a product barcode or package. The system takes a frame, runs it through the CLIP vision encoder, and searches the barcode_visual vector slot. This requires real product images to have been ingested — the placeholder vectors will return low-quality results.Admin DashboardShows live stock status for all products with toggle controls. Uses the PATCH /products/{product_id}/stock endpoint and real-time WebSocket updates so any change reflects immediately across all connected kiosk screens.Real-Time Sync & WebSocket OrchestrationTo keep inventory sync’d instantly across terminals, main.py implements a /ws/kiosk WebSocket endpoint. When an admin toggles stock status, it triggers the PATCH /products/{product_id}/stock endpoint. Instead of modifying or re-generating neural embeddings (which would take time), the backend uses Qdrant’s set_payload API to update the ‘stock_status’ flag in the vector metadata instantly. This change is broadcasted via WebSocket to all connected kiosk browsers, updating the search listings in real time.Step 6 — Running It Yourself# Clone and set up# Download Gemma 4 via Ollamapython3.11 download_model.pyOpen localhost:3000. Type “vegan protein source” or “something for kids breakfast” or “keto friendly fat” and wait a few seconds for Gemma to respond. Because we use Gemma 4 12B served locally via Ollama (highly optimized GGUF quantization), responses are generated in under 5–10 seconds.The health endpoint tells you when the server is ready:curl localhost:8000/health# {"status":"ok","models_loaded":true,"qdrant_ok":true}Design Decisions Worth ExaminingCLIP instead of a generative model for embeddings.The original project used a generative vision-language model as a retriever. Generative models are not trained for embedding similarity — they are trained to predict the next token. CLIP is trained contrastively: it explicitly pulls matching image-text pairs together in the same vector space and pushes non-matching pairs apart. For semantic search, that is exactly the right objective. The switch from a 3B generative model to a 600MB CLIP model made retrieval dramatically better and dramatically faster.2. Four named vectors instead of one.Qdrant supports named vector slots on a single point. Each product has four embeddings: barcode_visual (CLIP image), voice_query (CLIP text of name + description), nutrition_pdf (CLIP text of nutritional details), audio_waveform (Whisper encoder of TTS-generated audio). This means a single query against Qdrant — regardless of input modality — always returns the same product metadata. No joins, no secondary lookups.3. Gemma reasons over pre-fetched products, not raw queries.The agent receives a formatted context block listing the top-3 retrieved products with names, prices, aisle numbers, tags, and descriptions. It is explicitly told to base its answer only on that context. This grounds the response in your actual inventory and prevents hallucinated product names or made-up aisles.4. Single file lock for Qdrant Edge.Only one process can write to the shard at a time. The design uses Qdrant Edge exclusively during ingestion and read-only during serving. If you need to update the catalogue without taking the server down, the right approach is to ingest into a shadow shard and hot-swap the storage path.What’s NextThe project already works, but there are still a few obvious places to make it faster, cleaner, and more practical.The biggest gap right now is inference speed on consumer hardware. Gemma 3 4B in float32 on MPS is too slow for a real kiosk. The two fixes are:CUDA + 4-bit NF4 quantisation: The code already supports this. GEMMA_LOAD_IN_4BIT is set to True automatically when a CUDA GPU is detected. On an RTX 3080 or better you would get sub-10-second responses.Smaller model: Gemma 3 1B or Phi-3-mini at 3.8B would respond faster on MPS. The RAG context is short (under 500 tokens) so a smaller model handles it well.Other extensions worth building:● Real product images: Drop {product_id}.jpg files into data/images/ and re-run ingest.py. Barcode/image search will immediately start returning semantically meaningful results.● Multi-store support: The schema already has a store_id field. Adding a store filter to Qdrant queries would let you run one server instance across multiple locations with isolated inventories.● Streaming responses: FastAPI supports Server-Sent Events and Gemma supports streaming generation. Adding streaming would let the UI display the recommendation word by word instead of waiting for the full response — much better kiosk UX.Numbers for People Who Like NumbersComponentMemory / FootprintSwitching to Ollama cut the baseline memory from 17 GB to 9 GB, making it lightweight enough to run on a base MacBook Air. On a machine with 24GB+ it runs comfortably. A GPU machine with 4-bit Gemma drops the model footprint to ~2.5 GB.Offline AI Is the Right Choice for RetailEvery customer interaction at a supermarket kiosk is sensitive. Purchase history, dietary restrictions, health queries — none of that should leave the store. Running the entire AI stack locally means there is nothing to leak, no API calls to log, no third-party to trust. Qdrant Edge made the vector database part of this trivially easy. CLIP made the semantic search part accurate. Gemma made the natural language generation part possible without a cloud account.The three together turn a grocery kiosk into something that actually understands what the customer is looking for — and can explain, in friendly spoken-style language, exactly where to find it. The milk is in Aisle 3. It costs ₹68. And the system got there without touching the internet once.If you want to try it yourself, the full implementation is on GitHub. Fork it, swap the product catalogue for your own data, and see what breaks. That’s the point.References● Qdrant Edge Documentation: https://qdrant.tech/documentation/edge/● CLIP Paper (Radford et al., 2021): https://arxiv.org/abs/2103.00020● CLIP ViT-B/32 Model Card: https://huggingface.co/openai/clip-vit-base-patch32● Gemma 3 4B Model Card: https://huggingface.co/google/gemma-3-4b-it● Whisper-base Model Card: https://huggingface.co/openai/whisper-base● FastAPI Documentation: https://fastapi.tiangolo.com/How to Build a Smart Cart Kiosk That Doesn’t Need the Cloud (CLIP + Qdrant Edge + Gemma) was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.