-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
372 additions
and
299 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,4 +105,5 @@ texts | |
image.db | ||
images | ||
audio.db | ||
audio | ||
audio | ||
*_old.rs |
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 was deleted.
Oops, something went wrong.
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,36 @@ | ||
use crate::database::core::Database; | ||
use crate::distance::CosineDistance; | ||
use crate::model::audio::VitBasePatch16_224; | ||
|
||
/// The default distance metric for audio embeddings. | ||
pub type DefaultAudioMetric = CosineDistance; | ||
|
||
/// The default embedding model for audio embeddings. | ||
pub type DefaultAudioModel = VitBasePatch16_224; | ||
|
||
/// A parameter regarding insertion into the HNSW graph. Higher values result in more accurate search results at the expense of slower retrieval speeds. Cannot be changed after database creation. | ||
pub const DEFAULT_AUDIO_EF_CONSTRUCTION: usize = 400; | ||
|
||
/// The number of bi-directional links created for each node in the HNSW graph. Cannot be changed after database creation. Increases memory usage and decreases retrieval speed with higher values. | ||
pub const DEFAULT_AUDIO_M: usize = 12; | ||
|
||
/// The number of bi-directional links created for each node in the HNSW graph in the first layer. Cannot be changed after database creation. | ||
pub const DEFAULT_AUDIO_M0: usize = 24; | ||
|
||
/// A database containing sounds and their embeddings. | ||
pub type DefaultAudioDatabase = Database< | ||
DefaultAudioMetric, | ||
DefaultAudioModel, | ||
DEFAULT_AUDIO_EF_CONSTRUCTION, | ||
DEFAULT_AUDIO_M, | ||
DEFAULT_AUDIO_M0, | ||
>; | ||
|
||
/// Load the audio database from disk, or create it if it does not already exist. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A vector database for audio. | ||
pub fn create_or_load_database() -> Result<DefaultAudioDatabase, Box<dyn std::error::Error>> { | ||
DefaultAudioDatabase::create_or_load_database(DefaultAudioMetric {}, DefaultAudioModel {}) | ||
} |
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,36 @@ | ||
use crate::database::core::Database; | ||
use crate::distance::CosineDistance; | ||
use crate::model::image::VitBasePatch16_224; | ||
|
||
/// The default distance metric for image embeddings. | ||
pub type DefaultImageMetric = CosineDistance; | ||
|
||
/// The default embedding model for image embeddings. | ||
pub type DefaultImageModel = VitBasePatch16_224; | ||
|
||
/// A parameter regarding insertion into the HNSW graph. Higher values result in more accurate search results at the expense of slower retrieval speeds. Cannot be changed after database creation. | ||
pub const DEFAULT_IMAGE_EF_CONSTRUCTION: usize = 400; | ||
|
||
/// The number of bi-directional links created for each node in the HNSW graph. Cannot be changed after database creation. Increases memory usage and decreases retrieval speed with higher values. | ||
pub const DEFAULT_IMAGE_M: usize = 12; | ||
|
||
/// The number of bi-directional links created for each node in the HNSW graph in the first layer. Cannot be changed after database creation. | ||
pub const DEFAULT_IMAGE_M0: usize = 24; | ||
|
||
/// A database containing images and their embeddings. | ||
pub type DefaultImageDatabase = Database< | ||
DefaultImageMetric, | ||
DefaultImageModel, | ||
DEFAULT_IMAGE_EF_CONSTRUCTION, | ||
DEFAULT_IMAGE_M, | ||
DEFAULT_IMAGE_M0, | ||
>; | ||
|
||
/// Load the image database from disk, or create it if it does not already exist. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A vector database for images. | ||
pub fn create_or_load_database() -> Result<DefaultImageDatabase, Box<dyn std::error::Error>> { | ||
DefaultImageDatabase::create_or_load_database(DefaultImageMetric {}, DefaultImageModel {}) | ||
} |
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,6 @@ | ||
/// Default configuration for an audio database. | ||
pub mod audio; | ||
/// Default configuration for an image database. | ||
pub mod image; | ||
/// Default configuration for a text database. | ||
pub mod text; |
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,36 @@ | ||
use crate::database::core::Database; | ||
use crate::distance::L2SquaredDistance; | ||
use crate::model::text::BGESmallEn1_5; | ||
|
||
/// The default distance metric for text embeddings. | ||
pub type DefaultTextMetric = L2SquaredDistance; | ||
|
||
/// The default embedding model for text embeddings. | ||
pub type DefaultTextModel = BGESmallEn1_5; | ||
|
||
/// A parameter regarding insertion into the HNSW graph. Higher values result in more accurate search results at the expense of slower retrieval speeds. Cannot be changed after database creation. | ||
pub const DEFAULT_TEXT_EF_CONSTRUCTION: usize = 400; | ||
|
||
/// The number of bi-directional links created for each node in the HNSW graph. Cannot be changed after database creation. Increases memory usage and decreases retrieval speed with higher values. | ||
pub const DEFAULT_TEXT_M: usize = 12; | ||
|
||
/// The number of bi-directional links created for each node in the HNSW graph in the first layer. Cannot be changed after database creation. | ||
pub const DEFAULT_TEXT_M0: usize = 24; | ||
|
||
/// A database containing texts and their embeddings. | ||
pub type DefaultTextDatabase = Database< | ||
DefaultTextMetric, | ||
DefaultTextModel, | ||
DEFAULT_TEXT_EF_CONSTRUCTION, | ||
DEFAULT_TEXT_M, | ||
DEFAULT_TEXT_M0, | ||
>; | ||
|
||
/// Load the text database from disk, or create it if it does not already exist. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A vector database for text. | ||
pub fn create_or_load_database() -> Result<DefaultTextDatabase, Box<dyn std::error::Error>> { | ||
DefaultTextDatabase::create_or_load_database(DefaultTextMetric {}, DefaultTextModel {}) | ||
} |
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,5 @@ | ||
/// Core implementation of a database. | ||
pub mod core; | ||
#[cfg(feature = "default_db")] | ||
/// Default configurations of databases. | ||
pub mod default; |
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 was deleted.
Oops, something went wrong.
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.