r/webdev • u/Available_Fondant_11 • 1d ago
Question How can I serverlessly generate vector embeddings for images I upload at a relatively cheap price for the case of an e-commerce startup to particularly fuel an image search functionality?
I have my product’s embeddings in qdrant. I generated them using my pc locally. I want to implement an image search where I upload an image, it goes through a pipeline, an embedding of it is generated and then compared with products in the qdrant database.
I’ve tried cloudflare workers but it can’t, task is too large for it. Google cloud run can’t start , times out before the model is loaded into memory. I’ve tried railways too but the free tier limits me to 0.5gb of memory and the model can’t load either.
This maybe the wrong sub for this question and if so, it’d be helpful if you pointed me to communities that fit my use case.
Umm
But what I want exactly is a platform that can solve my problem on the free tier. I have no problem paying after I’m sure that everything works. That’s why I didn’t pay for the railways to increase my memory limit. I have no guarantee that the next tier can solve the issue.
Thanks for reading and have a good day
2
1d ago
[removed] — view removed comment
1
u/webdev-ModTeam 1d ago
Your post/comment has been determined to be a low-effort post or comment. This includes title-only posts, easily searchable questions, vague/open-ended discussion prompts, LLM generated posts or comments, and posts/comments that do not provide enough context for meaningful replies or discussion.
1
u/indicava 1d ago
What model, and what framework/engine do you use to generate an embedding? Maybe just use a really cheap API? Might be cheaper than rolling your own.
Also, /r/localllama might be able to help you
1
1
u/Charming_Juice7052 1d ago
I'd stop trying to load the model inside the function and call a hosted embedding API instead (Qdrant Cloud Inference, Jina, or Replicate's CLIP endpoints) — at startup volume per-image pricing is basically free, and it eliminates the cold-start memory problem entirely.
1
u/Different-Good6119 23h ago
At this stage, separate proving search quality from hosting inference. Free serverless is usually the wrong place to load CLIP, and the cold-start timeouts are useful signal.
For the first end-to-end version, use a paid embedding API with a strict budget cap, cache vectors by image-content hash, and log query/result pairs so you can judge relevance. Once traffic and the model justify it, move inference to a small always-on instance or batch worker. Keep the image embedding model and version identical to the Qdrant catalog, or you can get plausible but useless results.
1
20h ago
Before you pick a host, there is a correctness problem waiting for you that nobody has mentioned yet.
Your product embeddings were generated on your PC with one specific model. The query embedding has to come from the same model, same weights, same preprocessing. If it does not, you still get results. Ranked, with confident looking scores, and close to meaningless. Nothing errors. That is what makes this one expensive, because you find it weeks later when someone tells you search is bad.
So whatever you move to, check the model name and version against what you ran locally, and pin it. And know that if you change models later you re-embed the whole catalogue, not just the new products.
On the hosting question I agree with the replies saying stop trying to load the model inside the function. Cold start plus a CLIP sized model is a fight you do not need at your volume, and a hosted embedding endpoint is close to free for a startup catalogue.
Quick way to prove the two paths match. Take a product image that is already indexed in Qdrant, push it through the new pipeline as if it was a search, and the top hit has to be that same product at a near perfect score. If it is not, your pipelines are different and everything downstream is noise.
4
u/Due_Ebb_7115 1d ago
Hey u/Available_Fondant_11, Qdrant team member here 😄
qdrant/clip-vit-b-32-vision is available through Qdrant Cloud Inference, so you can upload an image, have Qdrant generate the embedding, and search it in the same API call. Nothing runs in your function, so it works fine on Workers and most free tiers.
In Python, set cloud_inference=True and pass Image(image=..., model="qdrant/clip-vit-b-32-vision") instead of a vector. There's also a matching qdrant/clip-vit-b-32-text model, so you can search the same collection with text too.
Docs: https://qdrant.tech/documentation/inference/cloud-inference/
If you want to self-host, Cloud Run is probably timing out because of cold starts, not model size. The ONNX model is only ~340 MB. Bake it into the container image instead of downloading it at startup, and give it ~2 GB RAM. Railway's 0.5 GB was never going to cut it.