Blame view

embeddings/__init__.py 946 Bytes
7bfb9946   tangwang   向量化模块
1
2
  """
  Embeddings module.
be52af70   tangwang   first commit
3
  
7bfb9946   tangwang   向量化模块
4
  Important: keep package import lightweight.
be52af70   tangwang   first commit
5
  
7bfb9946   tangwang   向量化模块
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  Some callers do:
    - `from embeddings import BgeEncoder`
    - `from embeddings import CLIPImageEncoder`
  
  But the underlying implementations may import heavy optional deps (Pillow, torch, etc).
  To avoid importing those at package import time (and to allow the embedding service to boot
  without importing client code), we provide small lazy factories here.
  """
  
  
  class BgeEncoder(object):
      """Lazy factory for `embeddings.text_encoder.BgeEncoder`."""
  
      def __new__(cls, *args, **kwargs):
          from .text_encoder import BgeEncoder as _Real
  
          return _Real(*args, **kwargs)
  
  
  class CLIPImageEncoder(object):
      """Lazy factory for `embeddings.image_encoder.CLIPImageEncoder`."""
  
      def __new__(cls, *args, **kwargs):
          from .image_encoder import CLIPImageEncoder as _Real
  
          return _Real(*args, **kwargs)
  
  
  __all__ = ["BgeEncoder", "CLIPImageEncoder"]