xtrace_sdk.inference.embedding ============================== .. py:module:: xtrace_sdk.inference.embedding Classes ------- .. autoapisummary:: xtrace_sdk.inference.embedding.Embedding Module Contents --------------- .. py:class:: Embedding(provider, model_name, dim) This class provides an interface to generate embeddings using different providers. Supported providers include "ollama", "openai", and "sentence_transformer". It also includes methods to convert float embeddings to binary format. .. py:attribute:: dim .. py:attribute:: provider .. py:attribute:: url .. py:attribute:: model_name .. py:method:: __hash__() .. py:method:: __eq__(other) .. py:method:: embed(text) Generates an embedding for the given text using the specified provider. :param text: The input text to be embedded. :type text: str :return: A numpy array representing the embedding of the input text. :rtype: np.ndarray :raises ValueError: If the embedding dimension does not match the expected dimension. .. py:method:: float_2_bin(float_array) :staticmethod: Convert a list of floats to a list of binary integers, naive implementation, preserves dimension :param float_array: A numpy array or list of floats to be converted. :type float_array: np.ndarray or list[float] :return: A numpy array of binary integers (0s and 1s). :rtype: np.ndarray .. py:method:: sim_hash(float_array) .. py:method:: bin_embed(text) Generates a binary embedding for the given text. :param text: The input text to be embedded. :type text: str :return: A numpy array representing the binary embedding of the input text. :rtype: np.ndarray