I am facing errors when using my endpoint

I have deployed sentence-transformers/all-MiniLM-L6-v2 on an Azure instance and the endpoint does not work.

  1. I tested on the end point page itself and it threw an error “API Implementation Error: Invalid output: output must be of type Array”. I gathered from this error that maybe the output in not in an expected format but there is an output. So I thought let me check what the output format is. (screenshot 1)

  2. I ran the cURL code on an online cURL executor and this time I got a blank response. (screenshot 2)

Can someone please point out what I may be doing wrong here.

@sid-050175 Hello. Could you resolve your problem? I am having the exact same problem, using the same model for computing sentence similarity.

Hi, no I could not. Still trying to trouble shoot. I wrote to hugging face support but haven’t heard back from them yet. If you have any joy, please do tell me

Sid

I could solve it in the meantime. Funnily it only works when using programmatically, not from the UI.

from dotenv import load_dotenv

load_dotenv()
import os

import requests
from requests.adapters import HTTPAdapter


def get_similarity(string1, string2):
    API_URL = XXX

    headers = {
        "Authorization": f"Bearer {os.getenv('HF_API_KEY')}",
        "Content-Type": "application/json"
    }

    def query(payload):
        response = requests.post(API_URL, headers=headers, json=payload, timeout=5)
        return response.json()
        
    output = query({
        "inputs": {
            "source_sentence": string1,
            "sentences": [
                string2
            ]
        },
    })

    # print(output)

    return output

if __name__ =='__main__':
    output = get_similarity("I like apples", "I like oranges")
    print(output)

Thanks, will give it a shot

Sid