Sentence Similarity
sentence-transformers
ONNX
Safetensors
bert
feature-extraction
Generated from Trainer
dataset_size:1290285
loss:TemperatureScaledCosineSimilarityLoss
Eval Results (legacy)
text-embeddings-inference
Instructions to use Aikoa/trait-embeddings-1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Aikoa/trait-embeddings-1 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Aikoa/trait-embeddings-1") sentences = [ "garden area", "minimalistisk design", "grönområde i närheten", "vaaleat puusävyt" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Download Dockerfile from Aikoa/trait-embeddings-1: direct link, hf CLI and curl.
- Browser
- Download file 2.28 kB
-
https://huggingface.co/Aikoa/trait-embeddings-1/resolve/main/Dockerfile
- Command line
-
hf download hf://Aikoa/trait-embeddings-1/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/Aikoa/trait-embeddings-1/resolve/main/Dockerfile
2.28 kB
| FROM python:3.12-slim as builder | |
| # Install build dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create and activate virtual environment | |
| RUN python -m venv /opt/venv | |
| ENV PATH="/opt/venv/bin:$PATH" | |
| WORKDIR /app | |
| # Copy and install requirements | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Final stage | |
| FROM python:3.12-slim | |
| # Install runtime dependencies and security updates | |
| RUN apt-get update && apt-get upgrade -y && \ | |
| apt-get install -y \ | |
| curl \ | |
| tini \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy virtual environment from builder | |
| COPY --from=builder /opt/venv /opt/venv | |
| ENV PATH="/opt/venv/bin:$PATH" | |
| WORKDIR /app | |
| # Create model directory and copy model files | |
| RUN mkdir -p /app/model | |
| COPY config_sentence_transformers.json config.json model.safetensors modules.json sentence_bert_config.json special_tokens_map.json tokenizer_config.json tokenizer.json unigram.json /app/model/ | |
| RUN mkdir -p /app/model/1_Pooling | |
| COPY 1_Pooling/config.json /app/model/1_Pooling/config.json | |
| # Copy application code | |
| COPY app.py . | |
| COPY requirements.txt . | |
| # Verify model files exist | |
| RUN python -c "import os; \ | |
| assert os.path.exists('/app/model/model.safetensors'), 'Model file not found'; \ | |
| assert os.path.exists('/app/model/config.json'), 'Config file not found'; \ | |
| print('Model files verified successfully')" | |
| # Runtime configuration for Cloud Run | |
| ENV PORT=8080 | |
| ENV WORKERS=2 | |
| ENV WORKER_TIMEOUT=300 | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PYTORCH_NUM_THREADS=4 | |
| # Set Python environment | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONPATH=/app | |
| # Non-root user for security | |
| RUN useradd -r -u 1000 appuser && \ | |
| chown -R appuser:appuser /app | |
| USER appuser | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ | |
| CMD curl -f http://localhost:${PORT}/health || exit 1 | |
| # Expose the port | |
| EXPOSE ${PORT} | |
| # Use tini as init system | |
| ENTRYPOINT ["/usr/bin/tini", "--"] | |
| # Use uvicorn with multiple workers for better concurrency | |
| CMD exec uvicorn \ | |
| app:app \ | |
| --host 0.0.0.0 \ | |
| --port ${PORT} \ | |
| --workers ${WORKERS} \ | |
| --timeout-keep-alive 65 \ | |
| --log-level info \ | |
| --proxy-headers \ | |
| --forwarded-allow-ips '*' \ | |
| --no-access-log | |