Skip to content

Commit

Permalink
fix: make sonar return numpy.ndarray
Browse files Browse the repository at this point in the history
  • Loading branch information
HLasse committed Aug 24, 2023
1 parent 58a62c9 commit b1db630
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/seb/seb_models/fairseq_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def encode(
results: list[SonarEncoderOutput] = list(iter(pipeline))

sentence_embeddings = torch.cat([x.sentence_embeddings for x in results], dim=0)
return sentence_embeddings
return sentence_embeddings.numpy()


def get_sonar_model(source_lang: str) -> SonarTextToEmbeddingModelPipeline:
Expand Down Expand Up @@ -145,3 +145,21 @@ def create_sonar_nn() -> SebModel:
loader=partial(get_sonar_model, source_lang="nno_Latn"),
meta=meta,
)



if __name__ == "__main__":
from seb.seb_models.hf_models import create_all_mini_lm_l6_v2


sonar = create_sonar_da()
st = create_all_mini_lm_l6_v2()

sents = ["Hej "* 60]

sonar_out = sonar.encode(sents)
st_out = st.encode(sents)

print(sonar_out.shape)
print(st_out.shape)
pass

0 comments on commit b1db630

Please sign in to comment.