vector-endpoint / README.md
wjm55
Update README to reflect changes in embedding response handling and adjust example usage
2e11453
---
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](https://huggingface.co/sentence-transformers/LaBSE) sentence transformer model.
## API Reference
### Endpoint
```
POST /vectorize
```
### Request Format
```json
{
"text": "Your text to be vectorized"
}
```
### Response Format
```json
{
"embedding": [0.123, 0.456, ...] // Vector representation of your text
}
```
## Usage Examples
### cURL
```bash
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
```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
```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](https://huggingface.co/sentence-transformers/LaBSE) model, which produces 768-dimensional embeddings that capture semantic meaning of text across multiple languages.