objective comparison of embedding models for your use case

Recently, I got to the point in a project, of looking into TypeSense as an option for embedding hosting for search. Prior, I was working with one particular embedding model, all-mpnet-base-v2, which intuitively and anecdotally performed decently well for my retrieval task. But yea that was the problem, my information was anecdotal and cherry-picked. But when I started looking into TypeSense, I noticed my model of choice was not in the list, https://huggingface....

January 11, 2025 · (updated January 20, 2025) · 3 min · 592 words · Michal Piekarczyk

postgis and the order by cosine distance

a bit tricky, not super intuitive in the docs, but I finally found how to builf a typesense query to do what I had previously done with postgres, that is, first constrain by postgis distance and then order by cosine distance. with a text_embedding column that embeds a text column, and lat lng available as well, flattened on the same collection, it is possible to query like so, { "q": query, "query_by": "text_embedding", "filter_by": f"location:({lat}, {lng}, {radius_km} km)", "sort_by": "_vector_distance:asc", "exclude_fields": "text_embedding", 'page': 1, 'per_page': 100 }

December 28, 2024 · (updated January 21, 2025) · 1 min · 87 words · Michal Piekarczyk

other interesting topics on postgres and kubernetes

Have not covered yet, a few other cool topics. Can go into more detail later, but, for now some highlights. Runtime embeddings to save money At one point in a recent postgres pgvector retrieval project, a really cool epiphany was, w.r.t. indexing in pgvector both a concatenated blob of items and granular items, that it is not necessary to also embed the low level items because they can be embedded at runtime and it is not that time consuming....

December 1, 2024 · (updated February 15, 2025) · 6 min · 1076 words · Michal Piekarczyk

embedding and pgvector query speedup

Wow, I found a very silly issue that was holding back this query. The data is a langchain embedding table of items associated with places, as well as a second table with those place addresses along with their longitude, latitude. Also, as I had a slower query, executed through sqlalchemy, like from sqlalchemy.sql import text with foo.engine.connect() as conn: data = {"vector": [0.06014461815357208, 0.07383278757333755, 0.010295705869793892, -0.058833882212638855,], "longitude": "", "latitude": ""} sql = """ """ statement = text(sql) # TODO also parameterize the `limit 10` ?...

November 9, 2024 · (updated November 18, 2024) · 4 min · 832 words · Michal Piekarczyk

odd prompt?

looked at someone’s fun project, https://www.npmjs.com/package/@rhettlunn/is-odd-ai That uses GPT 3.5 to see if a number is odd, for fun. My friend was asking has anyone evaluated this, so hmm i took a quick look. https://github.com/rhettlunn/is-odd-ai/blob/main/index.js Spotted two interesting things. Prompt injection attack not sure if i just made that up, but like a SQL injection , the code that places user input into the prompt asking about oddness, doesn’t type check if it is a number, and doesn’t therefore have any way of knowing will someone attempt to insert some text that will cause GPT to escape its sandbox....

November 6, 2024 · (updated November 8, 2024) · 2 min · 223 words · Michal Piekarczyk