Home / Class/ FakeEmbeddings Class — langchain Architecture

FakeEmbeddings Class — langchain Architecture

Architecture documentation for the FakeEmbeddings class in fake_embeddings.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  34c0ffc0_c9e8_1d62_04cc_97e3117a2d22["FakeEmbeddings"]
  b1e4f760_c634_d3bf_ca9a_db7ab899cc4a["Embeddings"]
  34c0ffc0_c9e8_1d62_04cc_97e3117a2d22 -->|extends| b1e4f760_c634_d3bf_ca9a_db7ab899cc4a
  137cdc23_3587_d3e6_41a8_782c05eb74a4["fake_embeddings.py"]
  34c0ffc0_c9e8_1d62_04cc_97e3117a2d22 -->|defined in| 137cdc23_3587_d3e6_41a8_782c05eb74a4
  60fce543_d0a8_8fd2_9f0d_08825daa878d["embed_documents()"]
  34c0ffc0_c9e8_1d62_04cc_97e3117a2d22 -->|method| 60fce543_d0a8_8fd2_9f0d_08825daa878d
  1b11e923_3ec6_7bc1_14cf_8ea88fc12e5f["aembed_documents()"]
  34c0ffc0_c9e8_1d62_04cc_97e3117a2d22 -->|method| 1b11e923_3ec6_7bc1_14cf_8ea88fc12e5f
  4caf2596_8581_9dd2_f837_bc008110f9f5["embed_query()"]
  34c0ffc0_c9e8_1d62_04cc_97e3117a2d22 -->|method| 4caf2596_8581_9dd2_f837_bc008110f9f5
  68fed06a_94f4_a876_760e_60f129ad673f["aembed_query()"]
  34c0ffc0_c9e8_1d62_04cc_97e3117a2d22 -->|method| 68fed06a_94f4_a876_760e_60f129ad673f

Relationship Graph

Source Code

libs/partners/chroma/tests/integration_tests/fake_embeddings.py lines 10–29

class FakeEmbeddings(Embeddings):
    """Fake embeddings functionality for testing."""

    def embed_documents(self, texts: list[str]) -> list[list[float]]:
        """Return simple embeddings.
        Embeddings encode each text as its index."""
        return [[1.0] * 9 + [float(i)] for i in range(len(texts))]

    async def aembed_documents(self, texts: list[str]) -> list[list[float]]:
        return self.embed_documents(texts)

    def embed_query(self, text: str) -> list[float]:
        """Return constant query embeddings.
        Embeddings are identical to embed_documents(texts)[0].
        Distance to each text will be that text's index,
        as it was passed to embed_documents."""
        return [1.0] * 9 + [0.0]

    async def aembed_query(self, text: str) -> list[float]:
        return self.embed_query(text)

Extends

Frequently Asked Questions

What is the FakeEmbeddings class?
FakeEmbeddings is a class in the langchain codebase, defined in libs/partners/chroma/tests/integration_tests/fake_embeddings.py.
Where is FakeEmbeddings defined?
FakeEmbeddings is defined in libs/partners/chroma/tests/integration_tests/fake_embeddings.py at line 10.
What does FakeEmbeddings extend?
FakeEmbeddings extends Embeddings.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free