Catalog dense vector - #549
Draft
christinach wants to merge 6 commits into
Draft
Conversation
christinach
commented
May 28, 2026
| will be overridden by parameters in the request | ||
| --> | ||
| <lst name="defaults"> | ||
| <str name="defType">lucene</str> |
Member
Author
There was a problem hiding this comment.
needs defType lucene to work
christinach
commented
May 28, 2026
| users normally should not need to know about them. | ||
| --> | ||
| <fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/> | ||
| <fieldType name="knn_vector" class="solr.DenseVectorField" vectorDimension="3" similarityFunction="cosine" knnAlgorithm="hnsw" hnswMaxConnections="10" hnswBeamWidth="40" /> |
Member
Author
There was a problem hiding this comment.
vectorDimension= 3 is just for testing the knn query and the /semantic handler locally. It is not a realistic vector dimension.
The specific model by default creates vectors with dimensions 768.
In order to reduce the size of the vectors we would need to use a method like PCA which is also used in https://github.com/pulibrary/dedup-text-embeddings/blob/main/ipca_on_embeddings.py for a different purpose. Or train the model with a smaller size of vectors.
we encode the text_embeddings to binary with values between 127 and -127 This produces a vector with dimension 96. update the solr schema.xml to use vectorDimension="96" and similarityFunction="dot_product"
we generate float32 embeddings through the emebedding service use 384 dimensions which is the defualt diemsnion number for model all-MiniLM-L6-v2
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
related to pulibrary/dacs_handbook#351
Adds a new handler to use it in the catalog semantic search. It works with defType lucene.
The dense vector field uses the knn algorithm https://solr.apache.org/guide/solr/latest/query-guide/dense-vector-search.html#densevectorfield
https://solr.apache.org/guide/solr/latest/upgrade-notes/major-changes-in-solr-9.html#solr-9-0
The text embeddings were generated locally using pulibrary/dedup-text-embeddings#1 and the model 'multi-qa-mpnet-base-cos-v1'
To search using the knn index , solr expects a q param of
"{!knn f=text_embeddings topK=10}[0.010338805615901947,0.02806314453482628,0.020983939990401268]"and with solr9 we need to set the defType to lucene.http://localhost:61903/solr/orangelight-core-dev/select?defType=lucene&indent=true&q.op=OR&q=%7B!knn%20f%3Dtext_embeddings%20topK%3D10%7D%5B0.010338805615901947%2C0.02806314453482628%2C0.020983939990401268%5D&useParams=