
    Wi                     F    d dl Zd dlmZ d dlmZ d dlmZ  G d de      Zy)    N)List)TextEmbedding)BaseEmbedderc                   Z     e Zd ZdZddef fdZd	dee   dedej                  fdZ
 xZS )
FastEmbedBackenda  FastEmbed embedding model.

    The FastEmbed embedding model used for generating sentence embeddings.

    Arguments:
        embedding_model: A FastEmbed embedding model

    Examples:
    To create a model, you can load in a string pointing to a supported
    FastEmbed model:

    ```python
    from bertopic.backend import FastEmbedBackend

    sentence_model = FastEmbedBackend("BAAI/bge-small-en-v1.5")
    ```
    embedding_modelc                     t         |           t        j                         D cg c]  }|d   	 }}t	        |t
              r||v rt        |      | _        y t        d      c c}w )Nmodel)
model_namezPlease select a correct FasteEmbed model: 
the model must be a string and must be supported. 
The supported TextEmbedding model list is here: https://qdrant.github.io/fastembed/examples/Supported_Models/)super__init__r   list_supported_models
isinstancestrr   
ValueError)selfr   msupported_models	__class__s       g/home/sietch6/trending-topics-pipeline/venv/lib/python3.12/site-packages/bertopic/backend/_fastembed.pyr   zFastEmbedBackend.__init__   sg    0=0S0S0UV1AgJVVos+CS0S#0O#LD @  Ws   A%	documentsverbosereturnc                 x    t        j                  t        | j                  j	                  ||                  }|S )a  Embed a list of n documents/words into an n-dimensional
        matrix of embeddings.

        Arguments:
            documents: A list of documents or words to be embedded
            verbose: Controls the verbosity of the process

        Returns:
            Document/words embeddings with shape (n, m) with `n` documents/words
            that each have an embeddings size of `m`
        )show_progress_bar)nparraylistr   embed)r   r   r   
embeddingss       r   r   zFastEmbedBackend.embed)   s4     XXd4#7#7#=#=i[b#=#cde
    )zBAAI/bge-small-en-v1.5)F)__name__
__module____qualname____doc__r   r   r   boolr   ndarrayr   __classcell__)r   s   @r   r   r      s6    $ tCy 4 BJJ r!   r   )	numpyr   typingr   	fastembedr   bertopic.backendr   r    r!   r   <module>r.      s      # ).| .r!   