참고
Automated Embedding is in Preview for mongot in Kubernetes cluster. The feature and corresponding documentation might change at any time during the Preview period. To learn more, see Preview Features.
이 페이지에서는 벡터 검색의 Kubernetes 배포에서 자동 임베딩을 구성하는 방법을 설명합니다. 벡터 검색의 자동 임베딩 기능은 인덱스 시점에 텍스트 데이터에 대한 벡터 임베딩을 생성하고 쿼리 시점에 쿼리 텍스트에 대한 벡터 임베딩을 생성합니다. 따라서 애플리케이션에서 별도의 임베딩 파이프라인을 유지할 필요가 없습니다.
This tutorial is for developers who are building semantic search or RAG features and want mongot to manage embeddings.
자동화된 임베딩의 기능
자동 임베딩이 없으면 애플리케이션이 수행해야 할 작업은 다음과 같습니다.
삽입 또는 업데이트하는 각 문서에 대한 임베딩을 생성합니다.
컬렉션의 문서와 함께 임베딩을 저장합니다.
동일한 모델을 사용하여 쿼리 시점에 모든 쿼리에 대한 임베딩을 생성합니다.
쿼리 임베딩을
$vectorSearch에 제출합니다.
자동 임베딩을 사용하면 mongot 프로세스가 1, 2, 3 단계를 처리합니다. 애플리케이션:
텍스트 필드에
autoEmbed필드 유형을 사용하여 벡터 검색 인덱스를 구성합니다.문서를 일반적으로 삽입하고 업데이트합니다. 그 다음
mongot은 텍스트 필드를 읽고 구성된 임베딩 모델을 통해 임베딩을 생성하여 저장합니다.미리 계산된 임베딩이 아닌 쿼리 텍스트로
$vectorSearch쿼리를 실행합니다. 그리고mongot은 쿼리 텍스트에 대한 임베딩을 생성합니다.
지원되는 임베딩 제공자
자체 관리형 mongot 자동 임베딩은 Voyage AI 임베딩 모델과 통합됩니다.
모델 | 설명 |
|---|---|
| 비용에 민감한 대용량 애플리케이션. |
| 권장하는 옵션입니다. 일반 텍스트 검색을 위한 균형 잡힌 성능. |
| 복잡한 시맨틱 관계에 대한 정확도를 극대화합니다. |
| 코드 검색 및 기술 문서화에 전문화되어 있습니다. |
You incur costs for embedding generation. To learn more, see Manage Billing for Automated Embedding.
전제 조건
mongotKubernetes 배포서버에서 1.70.1 이상을 사용합니다.MongoDB 8.3 이상.
Two Voyage AI API keys.
Use two separate keys, one for index-time embedding generation and one for query-time. Separate keys isolate query workload from indexing workload and allow independent rate-limit accounting. To learn more, see Rate Limits.
mongot에서 임베딩 엔드포인트로의 외부 네트워크 액세스The default endpoint is
https://ai.mongodb.com/v1/embeddings, which proxies Voyage AI with MongoDB-managed billing, for keys generated using the Atlas UI. You can also usehttps://api.voyageai.com/v1/embeddingsfor direct Voyage AI access if you generated the API key directly from Voyage AI.
Generate Voyage AI API Keys
You can generate Voyage AI API keys through either of the following paths:
(Recommended) Through your Atlas account. Atlas provides API key management with built-in rate-limit configuration. The keys are not tied to an Atlas cluster. To learn more, see Manage API Keys.
Through Voyage AI directly at voyageai.com.
두 개의 키를 생성하고 이름을 명확히 지정합니다. 예시: mongot-prod-index, mongot-prod-query 보안 비밀 저장에 키를 저장합니다.
Configure mongot for Automated Embedding
두 키를 모두 포함하는 쿠버네티스 시크릿 생성:
kubectl create secret generic voyage-api-keys \ --from-literal=indexing-key=<your-index-key> \ --from-literal=query-key=<your-query-key> \ --namespace=<your-namespace>
MongoDBSearch 사용자 지정 리소스에서 참조합니다.
apiVersion: mongodb.com/v1 kind: MongoDBSearch metadata: name: mdbs spec: # ... autoEmbedding: embeddingModelAPIKeySecret: name: voyage-api-keys
필요에 따라 mongot 이 사용하는 임베딩 엔드포인트를 재정의하도록 spec.autoEmbedding.providerEndpoint 을 설정합니다. 이 필드를 생략하면 mongot 는 내장 기본 엔드포인트인 https://ai.mongodb.com/v1/embeddings을 사용합니다. 자세히 알아보려면 MongoDBSearch 리소스 사양을 참조하세요.
자동화된 임베딩 인덱스 만들기
After you configure mongot with your Voyage AI API keys, define a Vector Search index that uses the autoEmbed field type. The index definition specifies which text field mongot embeds, which model it uses, the indexing method, quantization, and other parameters. To learn more about the autoEmbed index definition, see MongoDB Vector Search Index Fields.
kubectl exec --context "${K8S_CTX}" -n "${MDB_NS}" mongodb-tools-pod -- \ mongosh --quiet "${MDB_CONNECTION_STRING}" \ --eval "use sample_mflix" \ --eval 'db.movies.createSearchIndex("vector_auto_embed_index", "vectorSearch", { "fields": [ { "type": "autoEmbed", "modality": "text", "path": "plot", "model": "'"${EMBEDDING_MODEL}"'", "numDimensions": 1024, "similarity": "cosine", "quantization": "scalar", "indexingMethod": "hnsw", "hnswOptions": { "maxEdges": 16, "numEdgeCandidates": 200 } } ] });'
다음 표에서는 autoEmbed 인덱스 정의 필드에 대해 설명합니다.
필드 | 목적 |
|---|---|
| 자동 임베딩을 위한 필드를 표시합니다. |
| 데이터 모달리티. |
| 컬렉션에 임베딩할 필드입니다. |
| The Voyage AI model name. The model must be one that your API key has access to. |
| 임베딩 벡터의 차원 수입니다. 지원되는 차원은 모델에 따라 결정됩니다. |
| 벡터 검색에 사용할 유사성 함수입니다. 지원되는 함수는 |
| 사용할 인덱싱 방법입니다. 지원되는 방법은 |
| (선택 사항) HNSW 인덱스 옵션입니다. |
| (선택 사항) 사용할 양자화 유형. 지원되는 유형은 |
동일한 인덱스에 autoEmbed 필드와 filter 필드를 혼합할 수 있습니다. 동일한 경로에 autoEmbed 와 원시 벡터 필드를 혼합할 수 없습니다.
자동 임베딩 쿼리 실행
미리 계산된 임베딩이 아닌 쿼리 텍스트를 제출합니다. mongot 가 사용자를 위해 쿼리 임베딩을 생성합니다.
kubectl exec --context "${K8S_CTX}" -n "${MDB_NS}" mongodb-tools-pod -- \ mongosh --quiet "${MDB_CONNECTION_STRING}" \ --eval "use sample_mflix" \ --eval 'db.movies.aggregate([ { $vectorSearch: { index: "vector_auto_embed_index", path: "plot", query: "spy thriller", numCandidates: 150, limit: 10 } }, { $project: { _id: 0, plot: 1, title: 1, score: { $meta: "vectorSearchScore" } } }]);'
To learn more, see Run Vector Search ANN and ENN Queries.
임베딩 저장
mongot Kubernetes 클러스터의 전용 내부 데이터베이스에 임베딩을 유지합니다. mongot 은 소스 컬렉션에 임베딩을 저장하지 않습니다. mongot 은 소스 텍스트에서 임베딩을 다시 생성할 수 있으며, 임베딩 생성에 대한 요금이 부과됩니다.
Changes to the embedding model, output dimensions, or quantization trigger a full re-embedding of the affected index. You incur charges for the regeneration. To learn more, see When mongot Regenerates Embeddings.
To learn more, see Generated Embeddings Collection.
When mongot Regenerates Embeddings
mongot 다음 중 하나라도 발생하면 autoEmbed 필드에 대한 임베딩을 다시 생성합니다.
문서를 삽입합니다.
문서에서 임베딩된 필드를 변경합니다.
mongot은 change streams를 통해 변경 사항을 감지합니다.인덱스 정의에서 임베딩 모델을 변경합니다.
임베딩 출력 차원 또는 데이터 유형을 변경합니다.
텍스트 필드 경로를 변경합니다.
마지막 세 항목 중 하나라도 변경하면 mongot 은(는) 전체 인덱스를 처음부터 다시 빌드합니다. 대규모 컬렉션의 경우 재구축 비용이 많이 발생할 수 있습니다. 모델 변경을 신중하게 계획하십시오.
비용 및 속도 제한
MongoDB는 모델 특정 요금으로 백만 토큰당 부과합니다. 인덱싱 비용은 컬렉션의 인덱스 필드의 총 텍스트 볼륨에 비례합니다. 쿼리 비용은 쿼리 텍스트 볼륨에 비례합니다.
If you use the Voyage AI API key that you created using your Atlas account, you can view API key usage and rate limits in the Atlas UI. To learn more, see Manage Billing for the Embedding and Reranking API. If you use keys created directly from Voyage AI, you must monitor your usage and rate limits in the Voyage AI dashboard.
Voyage AI 측 제한 서비스 오류는 mongot 로그에 나타나며 해당 인덱스에 실패한 문서 지표기로 표시됩니다. 이러한 오류로 인덱스가 비활성화되지는 않지만 새 문서 인덱싱이 지연될 수 있습니다.
실패 모드
증상 | 가능한 원인 |
|---|---|
인덱스가 수분 동안 |
|
인덱싱 지연이 간호적으로 나타납니다. | Voyage AI 측 속도 제한. 속도 제한을 늘리거나 인덱싱 시간 임베딩 부하를 줄이세요. |
인덱스에 대한 쿼리는 임베딩을 언급하는 오류를 반환합니다. | The query API key is invalid or expired. Verify the contents of |
인덱스에 대한 모든 쿼리는 빈 결과를 반환합니다. | 인덱스가 다시 빌드되어 여전히 코퍼스를 다시 임베딩하고 있을 수 있습니다. |
제한 사항
미리 보기 상태. 자동 임베딩이 일반적으로 사용가능해지기 전에 설정 형상, 지원되는 모델 및 기본 엔드포인트가 변경될 수 있습니다.
필드당 하나의 임베딩 모델. 혼합 모델 인덱스는 지원되지 않습니다.
임베딩 모델 페일오버가 없습니다. Voyage AI 엔드포인트에 액세스할 수 없는 경우, 새 문서의 인덱싱이 중단됩니다.