Can one get an embeddings from an inference API that computes Sentence Similarity?

Hi there,

I’m new to using Huggingface’s inference API and wanted to check if a model whose task is to return Sentence Similarity can return sentence embeddings instead.

For example, in this sentence-transformers model, the model task is to return sentence similarity. Instead, I would like to just get the embeddings of a list of sentences.

Is there an API parameter I can tweak to get this? Help would be very much appreciated! :slight_smile:

1 Like

Hi there!

Yes, you can compute sentence embeddings. Here is an example

import requests

API_URL = ""
headers = {"Authorization": "Bearer API_TOKEN"}

def query(payload):
	response =, headers=headers, json=payload)
	return response.json()

output = query({
    "inputs": ["this is a sentence", "this is another sentence"]
# Output is a list of 2 embeddings, each of 768 values.