Skip to content

Abstract

AbstractEmbeddingModel

Bases: ABC

Abstract class for embedding models.

Source code in src/embedding/abstract.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class AbstractEmbeddingModel(ABC):
    """
    Abstract class for embedding models.
    """

    def __init__(self, split_camel: bool = False):
        self._name = 'AbstractEmbeddingModel'
        self.model = None
        self._split_camel = split_camel

    @abstractmethod
    def get_embedding(self, text: str) -> numpy.ndarray:
        pass

    def split(self, name: str):
        if self._split_camel:
            return split_camelcase(name)
        return name.split(' ')