Skip to content
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

Fallback to unaligned vectors if dimension not specified #2238

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions nucliadb_vectors/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::mem::size_of;

use nucliadb_core::protos::VectorIndexConfig;
use nucliadb_core::protos::{VectorSimilarity, VectorType as ProtoVectorType};
use nucliadb_core::tracing::warn;
use serde::{Deserialize, Serialize};

use crate::vector_types::*;
Expand Down Expand Up @@ -121,6 +122,10 @@ impl TryFrom<VectorIndexConfig> for VectorConfig {

fn try_from(proto: VectorIndexConfig) -> Result<Self, Self::Error> {
let vector_type = match (proto.vector_type(), proto.vector_dimension) {
(ProtoVectorType::DenseF32, Some(0)) => {
warn!("Trying to create a shard with dimension = 0. Falling back to unaligned vectors");
VectorType::DenseF32Unaligned
}
(ProtoVectorType::DenseF32, Some(dim)) => VectorType::DenseF32 {
dimension: dim as usize,
},
Expand Down
Loading