import requests
DEEPINFRA_TOKEN = "$DEEPINFRA_TOKEN"
MODEL = "cross-encoder/ms-marco-MiniLM-L-12-v2"
response = requests.post(
f"https://api.deepinfra.com/v1/inference/{MODEL}",
headers={
"Authorization": f"Bearer {DEEPINFRA_TOKEN}",
"Content-Type": "application/json",
},
json={
"query": "What is the capital of France?",
"documents": [
"Paris is the capital and most populous city of France.",
"Berlin is the capital of Germany.",
"The Eiffel Tower is located in Paris.",
"France is a country in Western Europe.",
],
},
)
result = response.json()
for item in result["scores"]:
print(item)