예제 #1
0
 def embed_sentence(sentence: str,
                    pooling_operation,
                    layers: str = '1',
                    use_scalar_mix: bool = False) -> Sentence:
     embeddings = XLMEmbeddings(pretrained_model_name_or_path=xlm_model,
                                layers=layers,
                                pooling_operation=pooling_operation,
                                use_scalar_mix=use_scalar_mix)
     flair_sentence = Sentence(sentence)
     embeddings.embed(flair_sentence)
     return flair_sentence
예제 #2
0
    def embed_sentence(
        sentence: str,
        pooling_operation,
        layers: str = "1",
        use_scalar_mix: bool = False,
    ) -> Sentence:
        embeddings = XLMEmbeddings(
            model=xlm_model,
            layers=layers,
            pooling_operation=pooling_operation,
            use_scalar_mix=use_scalar_mix,
        )
        flair_sentence = Sentence(sentence)
        embeddings.embed(flair_sentence)

        return flair_sentence