Spaces:
Build error
Build error
wjm55
Update README to reflect changes in embedding response handling and adjust example usage
2e11453
metadata
title: Vector Endpoint
emoji: π
colorFrom: red
colorTo: indigo
sdk: docker
pinned: false
Vector Endpoint
A simple API that converts text into vector embeddings using the LaBSE sentence transformer model.
API Reference
Endpoint
POST /vectorize
Request Format
{
"text": "Your text to be vectorized"
}
Response Format
{
"embedding": [0.123, 0.456, ...] // Vector representation of your text
}
Usage Examples
cURL
curl -X 'POST' \
'https://placingholocaust-vector-endpoint.hf.space/vectorize' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"text": "This is a text"
}'
Python
import requests
import json
url = "https://placingholocaust-vector-endpoint.hf.space/vectorize"
headers = {
"accept": "application/json",
"Content-Type": "application/json"
}
data = {
"text": "This is a text"
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
print(f"Embedding length: {len(result)}")
print(f"First few values: {result[:5]}")
JavaScript
// Using fetch
async function getEmbedding(text) {
const response = await fetch(
"https://placingholocaust-vector-endpoint.hf.space/vectorize",
{
method: "POST",
headers: {
"accept": "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({ text })
}
);
const data = await response.json();
return data
}
// Example usage
getEmbedding("This is a text")
.then(embedding => {
console.log(`Embedding length: ${embedding.length}`);
console.log(`First few values: ${embedding.slice(0, 5)}`);
})
.catch(error => console.error("Error:", error));
Model Information
This endpoint uses the sentence-transformers/LaBSE model, which produces 768-dimensional embeddings that capture semantic meaning of text across multiple languages.