Skip to main content

Crate lc_embeddings

Crate lc_embeddings 

Source
Expand description

Embedding model implementations for LangChainRust.

Provides embedding generation via multiple backends:

  • OpenAI (text-embedding-ada-002, text-embedding-3-small/large)
  • DeepSeek
  • Qwen (Alibaba Cloud / DashScope)
  • Local: BagOfWordsEmbeddings (always available) and LocalEmbeddings (ONNX, feature-gated)
  • MockEmbeddings for testing

Modules§

openai_compat
Shared base class for OpenAI-compatible-protocol embedding clients (P1-5).

Structs§

BagOfWordsEmbeddings
Lightweight local embedding (word-frequency hash + L2 normalization)
CohereEmbeddings
Cohere embedding provider.
CohereEmbeddingsConfig
Cohere embedding configuration.
DeepSeekEmbeddingsConfig
Configuration for DeepSeek embeddings API.
MockEmbeddings
Mock embeddings for testing purposes.
OpenAIEmbeddings
OpenAI Embeddings client
OpenAIEmbeddingsConfig
OpenAI Embeddings configuration
QwenEmbeddingsConfig
Configuration for Qwen embeddings API.

Enums§

CohereEmbedInputType
Cohere embedding input type.
EmbeddingError
Embedding error type

Constants§

COHERE_EMBED_BASE_URL
Cohere API base URL.
COHERE_EMBED_MODEL
Default Cohere embedding model.
DEEPSEEK_EMBED_MODEL
Default embedding model for DeepSeek.
QWEN_EMBED_MODEL
Default embedding model for Qwen.

Traits§

Embeddings
Embedding model trait

Functions§

cosine_similarity
Compute cosine similarity between two vectors.
l2_normalize
In-place L2 normalization: scale vec to unit length.

Type Aliases§

DeepSeekEmbeddings
DeepSeek embeddings client for generating vector embeddings.
QwenEmbeddings
Qwen embeddings client for generating vector embeddings.