
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
source code: https://github.com/mindthemath/nomic-api-rs
A fast Rust server for generating text and image embeddings using https://huggingface.co/nomic-ai/nomic-embed-text-v1.5 and https://huggingface.co/nomic-ai/nomic-embed-vision-v1.5 models via ONNX Runtime.
Pick either the cpu or gpu tag (adding --gpus all for the latter), and start the server with:
bashdocker run --rm -p 8080:8080 mindthemath/nomic-embed-v1.5:cpu
# Test curl -X POST localhost:8080/embed \ -H 'content-type: application/json' \ -d '{"input": "Hello world"}'
There are also :..-quantizeed variants of the images which ship with smaller model artifacts at the cost of reduced precision.
Interactive documentation available at /docs (Swagger UI).
GET /healthReturns health status and model availability.
Response:
json{ "status": "OK", "text_model": true, "vision_model": true }
GET /infoReturns server information including model paths and configuration.
Response:
json{ "averaging": "geometric", "load_cuda": false, "txt_model": "models/txt/model_quantized.onnx", "tokenizer": "models/txt/tokenizer.json", "img_model": "models/img/model_quantized.onnx" }
POST /embed (or /txt/embed)Generate embedding for a single text.
Request:
json{"input": "Hello world", "dim": 768}
input (required): Text to embeddim (optional): Embedding dimension (1-768). Defaults to 768. Supports https://huggingface.co/blog/matryoshka - use smaller dimensions for faster similarity search.Response:
json{ "embedding": [0.123, 0.456, ...], "tokens": 4, "time_ms": 12.34 }
Example with reduced dimension:
json{"input": "Hello world", "dim": 128}
Returns a 128-dimensional embedding (faster similarity search, slightly lower quality).
POST /batch (or /txt/batch)Generate embeddings for multiple texts.
Request:
json{"inputs": ["Hello world", "Goodbye world"], "dim": 8}
inputs (required): List of texts to embeddim (optional): Embedding dimension (1-768). Defaults to 768. Applied to all embeddings in the batch.Response:
json{ "embeddings": [[0.123, 0.456, ...], [0.789, -0.123, ...]], "tokens": [4, 5], "time_ms": 45.67 }
POST /img/embedGenerate embedding for a single image.
Request:
json{ "content": "https://example.com/image.jpg", "dim": 768 }
content (required): Image as URL, data URL (data:image/jpeg;base64,...), or raw base64dim (optional): Embedding dimension (1-768). Defaults to 768.Response:
json{ "embedding": [0.123, 0.456, ...], "time_ms": 89.12 }
Limits: Maximum 20MB per image (compressed). Supports JPEG, PNG, GIF, WebP, BMP, TIFF.
POST /img/batchGenerate embeddings for multiple images.
Request:
json{ "contents": [ "https://example.com/cat.jpg", "data:image/png;base64,iVBORw0KGgo..." ], "dim": 768 }
Response:
json{ "embeddings": [[0.123, ...], [0.789, ...]], "time_ms": 178.45 }
POST /img/statsExtract image statistics including EXIF metadata and color analysis.
Request:
json{ "content": "https://example.com/image.jpg", "averaging_method": "geometric" }
content (required): Image as URL, data URL (data:image/jpeg;base64,...), or raw base64averaging_method (optional): Color averaging method - arithmetic or geometric (defaults to AVERAGING env var or geometric)Response:
json{ "exif_data": { "Make": "Canon", "Model": "EOS 5D", "DateTime": "2024:01:01 12:00:00" }, "color_data": { "avg_color": { "rgb": [0.5, 0.3, 0.2], "hex": "#804d33", "method": "geometric" }, "dominant_color": { "rgb": [0.6, 0.4, 0.3], "hex": "#99664d" } }, "time_ms": 12.34 }
Limits: Maximum 20MB per image (compressed). Supports JPEG, PNG, GIF, WebP, BMP, TIFF.
GET /docsSwagger UI documentation page.
GET /openapi.jsonOpenAPI 3.1.0 schema.
| Variable | Default | Description |
|---|---|---|
PORT | 8080 | Server port |
MODEL | models/txt/model_quantized.onnx | Path to text ONNX model (fallback for TXT_MODEL) |
TXT_MODEL | models/txt/model_quantized.onnx | Path to text ONNX model |
TOKENIZER | models/txt/tokenizer.json | Path to tokenizer |
IMG_MODEL | models/img/model_quantized.onnx | Path to vision ONNX model |
USE_GPU | false | Enable GPU inference (1 or true) |
AVERAGING | geometric | Default averaging method for image color statistics: arithmetic or geometric |
DISABLE_CORS | false | Disable CORS entirely (1 or true) |
CORS_ORIGINS | (see below) | Comma-separated list of allowed origins |
By default, the server allows requests from localhost only (for local development):
http://localhost:3000 / http://localhost:8080http://127.0.0.1:3000 / http://127.0.0.1:8080Production deployment - set allowed origins explicitly:
bash# Allow specific origins (comma-separated, no wildcards) CORS_ORIGINS="https://example.com,https://app.example.com,https://api.example.com" ./nomic-serve # Docker docker run -p 8080:8080 \ -e CORS_ORIGINS="https://example.com,https://app.example.com" \ mindthemath/nomic-text-v1.5-rs:latest-cpu
Security notes:
CORS_ORIGINS is set but contains invalid values, falls back to localhost defaults (never permissive)Disable CORS entirely (allows all origins - use only for internal APIs):
bashDISABLE_CORS=1 ./nomic-serve
To modify the default allowed origins, edit DEFAULT_CORS_ORIGINS in src/main.rs.
The nomic-embed-text-v1.5 model supports Matryoshka embeddings - variable-dimension embeddings that maintain quality at reduced dimensions. Use the dim parameter to truncate embeddings for faster similarity search.
Benefits:
Recommended dimensions:
768 (default): Full quality, best for fine-grained tasks512: ~99% quality, good balance256: ~95% quality, faster search128: ~90% quality, very fast search64: ~85% quality, fastest searchExample:
bash# Full dimension (default) curl -X POST localhost:8080/embed \ -H 'content-type: application/json' \ -d '{"input": "Hello world"}' # Reduced dimension for faster search curl -X POST localhost:8080/embed \ -H 'content-type: application/json' \ -d '{"input": "Hello world", "dim": 128}'
Important: All embeddings in a batch use the same dim value. For consistent similarity search, always use the same dim for all embeddings you compare.
According to the https://static.nomic.ai/reports/2024_Nomic_Embed_Text_Technical_Report.pdf:
Note: The model architecture itself supports batching (proven by FP32 and PyTorch implementations). The interference is specific to ONNX quantized models.
For most embedding use cases (similarity search, clustering, RAG), embeddings need to be deterministic — the same text should always produce the same embedding. Cross-sample interference violates this:
embed("hello") alone → [0.123, 0.456, ...] embed("hello") + "world" → [0.089, 0.512, ...] # Different!
This could cause:
By processing each text individually (batch_size=1) with the quantized model, we guarantee:
If you need batching for text embeddings:
model.onnx instead of model_quantized.onnx)CPU inference: Standard C libraries (glibc, libstdc++). No GPU drivers or CUDA needed.
GPU inference: NVIDIA CUDA drivers and CUDA toolkit. The ***ary is built with CUDA support enabled by default (can be disabled by removing "cuda" feature from Cargo.toml).
Note: The --dns flags are recommended for image embedding endpoints (/img/embed, /img/batch) to ensure fast DNS resolution. Cloudflare DNS (1.1.1.1) is used for privacy and performance. Without DNS configuration, image URL fetching may be slow (10+ seconds) due to Docker's default DNS configuration.
Image Size (as shown by docker images):
model_quantized.onnx + tokenizer.json): 132MBmodel_quantized.onnx): 93MBdebian:bookworm-slim): 74.8MBmodel_quantized.onnx + tokenizer.json): 132MBmodel_quantized.onnx): 93MBnvidia/cuda:12.1.0-runtime-ubuntu22.04): 2.23GB-runtime variant is required (not -base) as it includes CUDA runtime libraries needed by ONNX Runtime's CUDA execution provider. The ONNX Runtime CUDA providers add significant size but are required for GPU inference.Note: The CPU Docker image includes both text and vision models for full multimodal support. The GPU image is significantly larger due to the CUDA runtime base image (~2.23GB) required for GPU inference.
Text Model:
Vision Model:
Both models share the same embedding space via contrastive training, enabling direct comparison of text and image embeddings.
License: Apache 2.0
MIT
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务