Merge branch 'main' into update-version-v1.4.0

This commit is contained in:
Clément Renault 2023-08-28 15:08:59 +02:00 committed by GitHub
commit af0f6f0bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 21 deletions

4
Cargo.lock generated
View File

@ -699,9 +699,9 @@ dependencies = [
[[package]] [[package]]
name = "charabia" name = "charabia"
version = "0.8.2" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57aa1b4a8dda126c03ebf2f7e31d16cfc8781c2fe80dedd1a33459efc3e07578" checksum = "098219a776307414866165a03a9cc68c1578764fe3616fe979e1c280790ddd73"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"cow-utils", "cow-utils",

View File

@ -680,6 +680,7 @@ fn compute_semantic_score(query: &[f32], vectors: Value) -> milli::Result<Option
.map_err(InternalError::SerdeJson)?; .map_err(InternalError::SerdeJson)?;
Ok(vectors Ok(vectors
.into_iter() .into_iter()
.flatten()
.map(|v| OrderedFloat(dot_product_similarity(query, &v))) .map(|v| OrderedFloat(dot_product_similarity(query, &v)))
.max() .max()
.map(OrderedFloat::into_inner)) .map(OrderedFloat::into_inner))

View File

@ -17,7 +17,7 @@ bincode = "1.3.3"
bstr = "1.4.0" bstr = "1.4.0"
bytemuck = { version = "1.13.1", features = ["extern_crate_alloc"] } bytemuck = { version = "1.13.1", features = ["extern_crate_alloc"] }
byteorder = "1.4.3" byteorder = "1.4.3"
charabia = { version = "0.8.2", default-features = false } charabia = { version = "0.8.3", default-features = false }
concat-arrays = "0.1.2" concat-arrays = "0.1.2"
crossbeam-channel = "0.5.8" crossbeam-channel = "0.5.8"
deserr = { version = "0.6.0", features = ["actix-web"]} deserr = { version = "0.6.0", features = ["actix-web"]}

View File

@ -293,15 +293,15 @@ pub fn normalize_facet(original: &str) -> String {
#[derive(serde::Serialize, serde::Deserialize, Debug)] #[derive(serde::Serialize, serde::Deserialize, Debug)]
#[serde(transparent)] #[serde(transparent)]
pub struct VectorOrArrayOfVectors { pub struct VectorOrArrayOfVectors {
#[serde(with = "either::serde_untagged")] #[serde(with = "either::serde_untagged_optional")]
inner: either::Either<Vec<f32>, Vec<Vec<f32>>>, inner: Option<either::Either<Vec<f32>, Vec<Vec<f32>>>>,
} }
impl VectorOrArrayOfVectors { impl VectorOrArrayOfVectors {
pub fn into_array_of_vectors(self) -> Vec<Vec<f32>> { pub fn into_array_of_vectors(self) -> Option<Vec<Vec<f32>>> {
match self.inner { match self.inner? {
either::Either::Left(vector) => vec![vector], either::Either::Left(vector) => Some(vec![vector]),
either::Either::Right(vectors) => vectors, either::Either::Right(vectors) => Some(vectors),
} }
} }
} }

View File

@ -91,11 +91,12 @@ pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>(
/// Update the universes accordingly and inform the logger. /// Update the universes accordingly and inform the logger.
macro_rules! back { macro_rules! back {
() => { () => {
assert!( // FIXME: temporarily disabled assert: see <https://github.com/meilisearch/meilisearch/pull/4013>
ranking_rule_universes[cur_ranking_rule_index].is_empty(), // assert!(
"The ranking rule {} did not sort its bucket exhaustively", // ranking_rule_universes[cur_ranking_rule_index].is_empty(),
ranking_rules[cur_ranking_rule_index].id() // "The ranking rule {} did not sort its bucket exhaustively",
); // ranking_rules[cur_ranking_rule_index].id()
// );
logger.end_iteration_ranking_rule( logger.end_iteration_ranking_rule(
cur_ranking_rule_index, cur_ranking_rule_index,
ranking_rules[cur_ranking_rule_index].as_ref(), ranking_rules[cur_ranking_rule_index].as_ref(),

View File

@ -35,7 +35,7 @@ pub fn extract_vector_points<R: io::Read + io::Seek>(
// lazily get it when needed // lazily get it when needed
let document_id = || -> Value { let document_id = || -> Value {
let document_id = obkv.get(primary_key_id).unwrap(); let document_id = obkv.get(primary_key_id).unwrap();
serde_json::from_slice(document_id).unwrap() from_slice(document_id).unwrap()
}; };
// first we retrieve the _vectors field // first we retrieve the _vectors field
@ -52,12 +52,14 @@ pub fn extract_vector_points<R: io::Read + io::Seek>(
} }
}; };
for (i, vector) in vectors.into_iter().enumerate().take(u16::MAX as usize) { if let Some(vectors) = vectors {
let index = u16::try_from(i).unwrap(); for (i, vector) in vectors.into_iter().enumerate().take(u16::MAX as usize) {
let mut key = docid_bytes.to_vec(); let index = u16::try_from(i).unwrap();
key.extend_from_slice(&index.to_be_bytes()); let mut key = docid_bytes.to_vec();
let bytes = cast_slice(&vector); key.extend_from_slice(&index.to_be_bytes());
writer.insert(key, bytes)?; let bytes = cast_slice(&vector);
writer.insert(key, bytes)?;
}
} }
} }
// else => the `_vectors` object was `null`, there is nothing to do // else => the `_vectors` object was `null`, there is nothing to do