Spaces:
Build error
Build error
File size: 2,092 Bytes
67ad3cd df0e186 2e11453 df0e186 2e11453 df0e186 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
---
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.
|