sparse_embeddings.py — langchain Source File
Architecture documentation for sparse_embeddings.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR aa6d3c0b_08ba_9711_9c2f_a65edbd1b33d["sparse_embeddings.py"] cccbe73e_4644_7211_4d55_e8fb133a8014["abc"] aa6d3c0b_08ba_9711_9c2f_a65edbd1b33d --> cccbe73e_4644_7211_4d55_e8fb133a8014 2971f9da_6393_a3e3_610e_ace3d35ee978["langchain_core.runnables.config"] aa6d3c0b_08ba_9711_9c2f_a65edbd1b33d --> 2971f9da_6393_a3e3_610e_ace3d35ee978 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] aa6d3c0b_08ba_9711_9c2f_a65edbd1b33d --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 style aa6d3c0b_08ba_9711_9c2f_a65edbd1b33d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from abc import ABC, abstractmethod
from langchain_core.runnables.config import run_in_executor
from pydantic import BaseModel, Field
class SparseVector(BaseModel, extra="forbid"):
"""Sparse vector structure."""
indices: list[int] = Field(..., description="indices must be unique")
values: list[float] = Field(
..., description="values and indices must be the same length"
)
class SparseEmbeddings(ABC):
"""An interface for sparse embedding models to use with Qdrant."""
@abstractmethod
def embed_documents(self, texts: list[str]) -> list[SparseVector]:
"""Embed search docs."""
@abstractmethod
def embed_query(self, text: str) -> SparseVector:
"""Embed query text."""
async def aembed_documents(self, texts: list[str]) -> list[SparseVector]:
"""Asynchronous Embed search docs."""
return await run_in_executor(None, self.embed_documents, texts)
async def aembed_query(self, text: str) -> SparseVector:
"""Asynchronous Embed query text."""
return await run_in_executor(None, self.embed_query, text)
Domain
Subdomains
Classes
Dependencies
- abc
- langchain_core.runnables.config
- pydantic
Source
Frequently Asked Questions
What does sparse_embeddings.py do?
sparse_embeddings.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What does sparse_embeddings.py depend on?
sparse_embeddings.py imports 3 module(s): abc, langchain_core.runnables.config, pydantic.
Where is sparse_embeddings.py in the architecture?
sparse_embeddings.py is located at libs/partners/qdrant/langchain_qdrant/sparse_embeddings.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/qdrant/langchain_qdrant).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free