-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat(vector store): lancedb #33
Merged
+5,787
−489
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
9d7cbb7
feat: start implementing VectorStore trait for lancedb
marieaurore123 1d9fd64
refactor: create wrapper for vec<DocumentEmbeddings> for from/tryfrom…
marieaurore123 e9d18c5
feat: implement add_documents on VectorStore trait
marieaurore123 d3c7f9a
feat: implement search by id for VectorStore trait
marieaurore123 7be1f85
feat: implement get_document method of VectorStore trait
marieaurore123 168f53e
feat: start implementing top_n_from_query for trait VectorStoreIndex
marieaurore123 27c6bda
Merge branch 'main' into feat(vector-store)/lancedb
marieaurore123 1e52e6a
docs: add doc string to mongodb search params struct
marieaurore123 bb5c767
docs: Add doc strings to utility methods
marieaurore123 b788cd5
feat: implement ANN search example
marieaurore123 d62bbbf
refactor: conversions from arrow types to primitive types
marieaurore123 22b43ba
feat: add vector_search_s3_ann example
marieaurore123 ad45690
feat: create enum for embedding models
marieaurore123 9cba7a1
Merge branch 'main' into feat(vector-store)/lancedb
marieaurore123 e22d778
ci: makes the protoc compiler available on github workflows
marieaurore123 4debc0e
fix: reduce opanai generated content in ANN examples
marieaurore123 7b71aa1
feat: add indexes and tables for simple search
marieaurore123 e63d5a1
style: cargo fmt
marieaurore123 4d28f61
refactor: remove associated type on VectorStoreIndex trait
marieaurore123 0bcf5a3
refactor: use constants instead of enum for model names
marieaurore123 2f5844d
fix: make PR requested changes
marieaurore123 2436ca3
Merge branch 'main' into feat(vector-store)/lancedb
marieaurore123 dfe32e2
fix: make PR requested changes
marieaurore123 5644a1d
style: cargo clippy
marieaurore123 6fede36
feat: implement deserialization for any recordbatch returned from lan…
marieaurore123 4a22b15
feat: finish implementing deserialiser for record batch
marieaurore123 ff85fa5
refactor: remove print statement
marieaurore123 57d8287
Merge branch 'main' into feat(vector-store)/lancedb
marieaurore123 70802b3
refactor: update rig core version on lancedb crate, remove implementa…
marieaurore123 313cf14
Merge branch 'main' into feat(vector-store)/lancedb
marieaurore123 205f0c7
feat: merge all arrow columns into JSON document in deserializer
marieaurore123 921b313
feat: replace document embeddings with serde json value
marieaurore123 0050925
feat: update examples to use new version of VectorStoreIndex trait
marieaurore123 4a6a87d
docs: add doc strings
marieaurore123 ec44d4a
fix: fix bug in deserializing type run end
marieaurore123 edae694
docs: add example docstring
marieaurore123 9c3eb0e
fix: mongodb vector search - use num_candidates from search params
marieaurore123 3eef745
fix(lancedb): replace VectorStoreIndexDyn with VectorStoreIndex in ex…
marieaurore123 f0840fb
Merge branch 'main' into feat(vector-store)/lancedb
marieaurore123 27435e4
fix: make PR changes pt I
marieaurore123 b55e86e
fix: make PR changes Pt II
marieaurore123 cc5a328
fix(ci): install protobuf-compiler in test job
marieaurore123 9a310cb
fix: update lancedb examples test data
marieaurore123 9b09639
refactor: lance db examples
marieaurore123 d5dc56a
style: cargo fmt
marieaurore123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading status checks…
feat: update examples to use new version of VectorStoreIndex trait
- rig-surrealdb-v0.1.0
- rig-sqlite-v0.1.5
- rig-sqlite-v0.1.4
- rig-sqlite-v0.1.3
- rig-sqlite-v0.1.2
- rig-sqlite-v0.1.1
- rig-sqlite-v0.1.0
- rig-qdrant-v0.1.8
- rig-qdrant-v0.1.7
- rig-qdrant-v0.1.6
- rig-qdrant-v0.1.5
- rig-qdrant-v0.1.4
- rig-qdrant-v0.1.3
- rig-qdrant-v0.1.2
- rig-qdrant-v0.1.1
- rig-qdrant-v0.1.0
- rig-postgres-v0.1.3
- rig-postgres-v0.1.2
- rig-postgres-v0.1.1
- rig-postgres-v0.1.0
- rig-neo4j-v0.2.5
- rig-neo4j-v0.2.4
- rig-neo4j-v0.2.3
- rig-neo4j-v0.2.2
- rig-neo4j-v0.2.1
- rig-neo4j-v0.2.0
- rig-neo4j-v0.1.2
- rig-neo4j-v0.1.1
- rig-neo4j-v0.1.0
- rig-mongodb-v0.2.5
- rig-mongodb-v0.2.4
- rig-mongodb-v0.2.3
- rig-mongodb-v0.2.2
- rig-mongodb-v0.2.1
- rig-mongodb-v0.2.0
- rig-mongodb-v0.1.5
- rig-mongodb-v0.1.4
- rig-mongodb-v0.1.3
- rig-lancedb-v0.2.5
- rig-lancedb-v0.2.4
- rig-lancedb-v0.2.3
- rig-lancedb-v0.2.2
- rig-lancedb-v0.2.1
- rig-lancedb-v0.2.0
- rig-lancedb-v0.1.2
- rig-lancedb-v0.1.1
- rig-lancedb-v0.1.0
- rig-fastembed-v0.1.1
- rig-eternalai-v0.2.1
- rig-eternalai-v0.2.0
- rig-eternalai-v0.1.0
- rig-derive-v0.1.0
- rig-core-v0.9.0
- rig-core-v0.8.0
- rig-core-v0.7.0
- rig-core-v0.6.1
- rig-core-v0.6.0
- rig-core-v0.5.0
- rig-core-v0.4.1
- rig-core-v0.4.0
- rig-core-v0.3.0
commit 005092522daef6532cc94b2e8afef6fc254a376c
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use std::sync::Arc; | ||
|
||
use arrow_array::{types::Float64Type, ArrayRef, FixedSizeListArray, RecordBatch, StringArray}; | ||
use lancedb::arrow::arrow_schema::{DataType, Field, Fields, Schema}; | ||
use rig::embeddings::DocumentEmbeddings; | ||
|
||
// Schema of table in LanceDB. | ||
pub fn schema(dims: usize) -> Schema { | ||
Schema::new(Fields::from(vec![ | ||
Field::new("id", DataType::Utf8, false), | ||
Field::new("content", DataType::Utf8, false), | ||
Field::new( | ||
"embedding", | ||
DataType::FixedSizeList( | ||
Arc::new(Field::new("item", DataType::Float64, true)), | ||
dims as i32, | ||
), | ||
false, | ||
), | ||
])) | ||
} | ||
|
||
// Convert DocumentEmbeddings objects to a RecordBatch. | ||
pub fn as_record_batch( | ||
records: Vec<DocumentEmbeddings>, | ||
dims: usize, | ||
) -> Result<RecordBatch, lancedb::arrow::arrow_schema::ArrowError> { | ||
let id = StringArray::from_iter_values( | ||
records | ||
.iter() | ||
.flat_map(|record| (0..record.embeddings.len()).map(|i| format!("{}-{i}", record.id))) | ||
.collect::<Vec<_>>(), | ||
); | ||
|
||
let content = StringArray::from_iter_values( | ||
records | ||
.iter() | ||
.flat_map(|record| { | ||
record | ||
.embeddings | ||
.iter() | ||
.map(|embedding| embedding.document.clone()) | ||
}) | ||
.collect::<Vec<_>>(), | ||
); | ||
|
||
let embedding = FixedSizeListArray::from_iter_primitive::<Float64Type, _, _>( | ||
records | ||
.into_iter() | ||
.flat_map(|record| { | ||
record | ||
.embeddings | ||
.into_iter() | ||
.map(|embedding| embedding.vec.into_iter().map(Some).collect::<Vec<_>>()) | ||
.map(Some) | ||
.collect::<Vec<_>>() | ||
}) | ||
.collect::<Vec<_>>(), | ||
dims as i32, | ||
); | ||
|
||
RecordBatch::try_from_iter(vec![ | ||
("id", Arc::new(id) as ArrayRef), | ||
("content", Arc::new(content) as ArrayRef), | ||
("embedding", Arc::new(embedding) as ArrayRef), | ||
]) | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove AI generated data in favor of repeated hardcoded data |
This file contains 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
This file contains 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove AI generated data in favor of repeated hardcoded data |
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The examples sometimes fail if
GPT-4o
doesnt generate valid JSON synthetic data. To make the examples more reliable (and simpler), I would just create a dummy definition and copy it 256 times