Search and ranking
Semantic search with 32, 16, 8 and 4-bit vectors
Embeddings live in a contiguous vector column in the file, and avaliar computes the cosine against the query and returns the k closest rows.
· jsonW 1.3.11
The problem
Semantic search usually requires a vector database next to the main database. The same record ends up living in two places, with two permission systems and two copies to keep in sync.
How jsonW solves it
The vector is a type of the format: vf32[n], vf16[n], vq8[n] and vq4[n], stored contiguously in the file. avaliar … cosseno compares the query with the whole column and returns the k nearest rows, with the full row next to each score.
$ wjsw avaliar prod.jsw cosseno vet "1,0,0.2,0.1" 2
0.9869597291884717 2 {id:3,produto:"Chá verde",…,vet:vf16[0.7998046875,0,0.300048828125,0.0999755859375],…}
0.9681576829495052 0 {id:1,produto:"Café especial",…}
Real output. The value 0.8 stored as vf16 comes back as 0.7998046875: half precision keeps about three decimal digits.
Where it is
In the tool, wjsw avaliar … cosseno, and in the SDKs. When vector accuracy matters, use vf32; vq8 and vq4 trade precision for size. Producing the embedding is still your model's job; jsonW stores and compares.