Home / Class/ AngularTwoDimensionalEmbeddings Class — langchain Architecture

AngularTwoDimensionalEmbeddings Class — langchain Architecture

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

Entity Profile

Dependency Diagram

graph TD
  bbd47f76_d825_e868_c481_441b9a41a376["AngularTwoDimensionalEmbeddings"]
  b1e4f760_c634_d3bf_ca9a_db7ab899cc4a["Embeddings"]
  bbd47f76_d825_e868_c481_441b9a41a376 -->|extends| b1e4f760_c634_d3bf_ca9a_db7ab899cc4a
  7329f2d2_fa41_f27b_f1da_ed27a7ea1af7["fake_embeddings.py"]
  bbd47f76_d825_e868_c481_441b9a41a376 -->|defined in| 7329f2d2_fa41_f27b_f1da_ed27a7ea1af7
  119760c2_93a9_f08e_4423_1af7744c75bd["embed_documents()"]
  bbd47f76_d825_e868_c481_441b9a41a376 -->|method| 119760c2_93a9_f08e_4423_1af7744c75bd
  76f25d73_04c2_6b9d_ccc7_c1b1d6d106d8["embed_query()"]
  bbd47f76_d825_e868_c481_441b9a41a376 -->|method| 76f25d73_04c2_6b9d_ccc7_c1b1d6d106d8

Relationship Graph

Source Code

libs/langchain/tests/integration_tests/cache/fake_embeddings.py lines 90–117

class AngularTwoDimensionalEmbeddings(Embeddings):
    """From angles (as strings in units of pi) to unit embedding vectors on a circle."""

    def embed_documents(self, texts: list[str]) -> list[list[float]]:
        """Make a list of texts into a list of embedding vectors."""
        return [self.embed_query(text) for text in texts]

    @override
    def embed_query(self, text: str) -> list[float]:
        """Embed query text.

        Convert input text to a 'vector' (list of floats).
        If the text is a number, use it as the angle for the
        unit vector in units of pi.
        Any other input text becomes the singular result [0, 0] !

        Args:
            text: Text to embed.

        Returns:
            Embedding.
        """
        try:
            angle = float(text)
            return [math.cos(angle * math.pi), math.sin(angle * math.pi)]
        except ValueError:
            # Assume: just test string, no attention is paid to values.
            return [0.0, 0.0]

Extends

Frequently Asked Questions

What is the AngularTwoDimensionalEmbeddings class?
AngularTwoDimensionalEmbeddings is a class in the langchain codebase, defined in libs/langchain/tests/integration_tests/cache/fake_embeddings.py.
Where is AngularTwoDimensionalEmbeddings defined?
AngularTwoDimensionalEmbeddings is defined in libs/langchain/tests/integration_tests/cache/fake_embeddings.py at line 90.
What does AngularTwoDimensionalEmbeddings extend?
AngularTwoDimensionalEmbeddings extends Embeddings.

Analyze Your Own Codebase

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

Try Supermodel Free