-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
398: implement experimental ai-powered search r=ahmednfwela a=memishood # Pull Request ## Related issue Fixes #369 ## What does this PR do? I've implemented all the required steps mentioned in the issue above. I made every effort to respect the existing project conventions. I hope this pull request will be helpful and add value to Meilisearch 💜 **PR:** I didn't uncomment vector search tests in search_tests.dart as I'm focused on embedders capability. ### Some technical points that I might have considered wrong in the pull-req - Ensure `semanticRatio` is between 0.0 and 1.0 - Throw exception when embedder source is not one of them: `openAi`, `huggingFace`, `userProvided`, `rest`, `ollama` **Any comment & feedback is appreciated!** ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: Emre Memis <[email protected]> Co-authored-by: ahmednfwela <[email protected]> Co-authored-by: Emre <[email protected]>
- Loading branch information
Showing
14 changed files
with
594 additions
and
51 deletions.
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
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
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
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,17 @@ | ||
class HybridSearch { | ||
final String embedder; | ||
final double semanticRatio; | ||
|
||
const HybridSearch({ | ||
required this.embedder, | ||
required this.semanticRatio, | ||
}) : assert( | ||
semanticRatio >= 0.0 && semanticRatio <= 1.0, | ||
"'semanticRatio' must be between 0.0 and 1.0", | ||
); | ||
|
||
Map<String, Object?> toMap() => { | ||
'embedder': embedder, | ||
'semanticRatio': semanticRatio, | ||
}; | ||
} |
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
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,31 @@ | ||
/// Describes the mean and sigma of distribution of embedding similarity in the embedding space. | ||
/// | ||
/// The intended use is to make the similarity score more comparable to the regular ranking score. | ||
/// This allows to correct effects where results are too "packed" around a certain value. | ||
class DistributionShift { | ||
/// Value where the results are "packed". | ||
/// Similarity scores are translated so that they are packed around 0.5 instead | ||
final double currentMean; | ||
|
||
/// standard deviation of a similarity score. | ||
/// | ||
/// Set below 0.4 to make the results less packed around the mean, and above 0.4 to make them more packed. | ||
final double currentSigma; | ||
|
||
DistributionShift({ | ||
required this.currentMean, | ||
required this.currentSigma, | ||
}); | ||
|
||
factory DistributionShift.fromMap(Map<String, Object?> map) { | ||
return DistributionShift( | ||
currentMean: map['current_mean'] as double, | ||
currentSigma: map['current_sigma'] as double, | ||
); | ||
} | ||
|
||
Map<String, Object?> toMap() => { | ||
'current_mean': currentMean, | ||
'current_sigma': currentSigma, | ||
}; | ||
} |
Oops, something went wrong.