Describe the bug
The documentation for the similarity_search and similarity_search_by_vector methods in the Langchain::Vectorsearch::Hnswlib class incorrectly states that the methods return results in the format [[id1, distance1], [id2, distance2]]. However, the actual return format from the underlying hnswlib library is [[id1, id2], [distance1, distance2]], where IDs and distances are provided as separate arrays.
Expected behavior
The documentation should accurately reflect the return format as [[id1, id2], [distance1, distance2]] to match the actual behavior of the hnswlib library's search_knn method.
Describe the bug The documentation for the
similarity_search
andsimilarity_search_by_vector
methods in theLangchain::Vectorsearch::Hnswlib
class incorrectly states that the methods return results in the format[[id1, distance1], [id2, distance2]]
. However, the actual return format from the underlyinghnswlib
library is[[id1, id2], [distance1, distance2]]
, where IDs and distances are provided as separate arrays.https://github.com/patterns-ai-core/langchainrb/blob/656ca14c6294bcb1e06e4e691bd0132781d22d67/lib/langchain/vectorsearch/hnswlib.rb#L80
https://github.com/patterns-ai-core/langchainrb/blob/656ca14c6294bcb1e06e4e691bd0132781d22d67/lib/langchain/vectorsearch/hnswlib.rb#L61
Return type mentioned in
Hnswlib
gemhttps://github.com/yoshoku/hnswlib.rb/blob/7b85e43f4542a60758d63027ed09dd6be80ea6f4/ext/hnswlib/dummy.rb#L222
To Reproduce
Langchain::Vectorsearch::Hnswlib
instance.similarity_search
method.Expected behavior The documentation should accurately reflect the return format as [[id1, id2], [distance1, distance2]] to match the actual behavior of the hnswlib library's search_knn method.