# Sentence Embeddings using Transformers.jl

**URL:** <https://discourse.julialang.org/t/sentence-embeddings-using-transformers-jl/96611>\
**Category:** Machine Learning\
**Created:** [March 25, 2023, 10:06pm UTC](https://discourse.julialang.org/t/sentence-embeddings-using-transformers-jl/96611 "2023-03-25T22:06:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NAS](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nas/32/47432_2.png) [@NAS](https://discourse.julialang.org/u/NAS)\
**Post date:** [March 25, 2023, 10:06pm UTC](https://discourse.julialang.org/t/sentence-embeddings-using-transformers-jl/96611/1 "2023-03-25T22:06:42Z")

</div>

I’m trying to do sentence embeddings using a huggingface model similar to python example here: [sentence-transformers/all-MiniLM-L6-v2 · Hugging Face](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2).

So far I have this

```julia
using Transformers.HuggingFace
using Transformers.TextEncoders

sentTrans = hgf"sentence-transformers/all-MiniLM-L6-v2"

enc = sentTrans[1]
model = sentTrans[2]

sentences = [
    "This framework generates embeddings for each input sentence",
    "Sentences are passed as a list of string.",
    "The quick brown fox jumps over the lazy dog."
]

out = model(encode(enc,sentences))

```

`out[3]` is a 384 element vector for each sentence, which is what I expected to get, but the vectors don’t match what I get when I use the Python implementation.

I have a strong suspicion I’m just missing a step, looking for, and appreciative of, any guidance anyone may be able to offer.

Thanks.
