Skip to main content

seyk_embed/
lib.rs

1//! Lightweight task-aware embedding interfaces, independent of search and runtimes.
2pub mod diagnostics;
3mod embedder;
4mod embedding;
5mod error;
6pub mod quant;
7pub use embedder::{Embedder, EmbeddingRequest, ModelIdentity, ResourceInput, VideoFrame};
8pub use embedding::{Dimension, Embedding, cosine_similarity, dot_product, normalize};
9pub use error::{Error, Result};
10use serde::{Deserialize, Serialize};
11
12/// The kind of content a resource holds.
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
14#[serde(rename_all = "lowercase")]
15#[non_exhaustive]
16pub enum Modality {
17    /// Container metadata, never an embedding input.
18    Document,
19    Text,
20    Image,
21    Audio,
22    Video,
23}
24
25impl std::fmt::Display for Modality {
26    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27        f.write_str(match self {
28            Modality::Document => "document",
29            Modality::Text => "text",
30            Modality::Image => "image",
31            Modality::Audio => "audio",
32            Modality::Video => "video",
33        })
34    }
35}
36
37/// The purpose of an embedding. Each backend documents its supported mapping.
38/// These are embedding tasks, never instructions to generate answers or summaries.
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
40#[non_exhaustive]
41pub enum EmbeddingTask {
42    SearchQuery,
43    SearchDocument,
44    Classification,
45    Clustering,
46    CodeRetrieval,
47    FactChecking,
48    QuestionAnswering,
49    SentenceSimilarity,
50}