gemischtes_hack / README.md
Tim Loehr
HF Space: simplified Dockerfile for faster startup
76b352a
---
title: Gemischtes Hack Embeddings
emoji: 🎙️
colorFrom: gray
colorTo: yellow
sdk: docker
app_port: 7860
pinned: false
---
# Embedding Server for Gemischtes Hack
FastAPI server hosting `intfloat/multilingual-e5-small` embeddings model on Hugging Face Spaces.
## Setup
1. Create a new HF Space: https://huggingface.co/new-space
- Name: `gemischtes-hack-embed`
- License: MIT
- SDK: Docker
2. Clone this Space to your machine (or manually upload files)
3. The Docker container will:
- Install dependencies from `requirements.txt`
- Load the `multilingual-e5-small` model
- Expose FastAPI on port 7860
4. Once deployed, the Space URL will be available at:
`https://{your-username}-gemischtes-hack-embed.hf.space`
## API
### POST /embed
Generate embeddings for text.
```bash
curl -X POST https://{your-username}-gemischtes-hack-embed.hf.space/embed \
-H "Content-Type: application/json" \
-d '{"text": "Was ist Gemischtes Hack?"}'
```
Response:
```json
{
"embedding": [0.123, -0.456, ..., 0.789] // 384-dim vector
}
```
### GET /health
Check server status.
### GET /
View API info.
## Notes
- First request takes ~10-30 seconds (model loading + HF Spaces cold start)
- Subsequent requests take ~500ms
- Space auto-sleeps after 48 hours of inactivity
- Max 2 vCPU / 16 GB RAM (free tier)
## Integration
Update `web/src/lib/embed.ts`:
```typescript
const HF_SPACE_URL = "https://{your-username}-gemischtes-hack-embed.hf.space";
async function embedLocal(text: string): Promise<number[]> {
const response = await fetch(`${HF_SPACE_URL}/embed`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text }),
});
if (!response.ok) {
throw new Error(`Embed error: ${response.status}`);
}
const data = await response.json();
return data.embedding;
}
```