AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

벡터 검색을 위한 자동 임베딩 구성

참고

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.

자동 임베딩이 없으면 애플리케이션이 수행해야 할 작업은 다음과 같습니다.

  1. 삽입 또는 업데이트하는 각 문서에 대한 임베딩을 생성합니다.

  2. 컬렉션의 문서와 함께 임베딩을 저장합니다.

  3. 동일한 모델을 사용하여 쿼리 시점에 모든 쿼리에 대한 임베딩을 생성합니다.

  4. 쿼리 임베딩을 $vectorSearch에 제출합니다.

자동 임베딩을 사용하면 mongot 프로세스가 1, 2, 3 단계를 처리합니다. 애플리케이션:

  1. 텍스트 필드에 autoEmbed 필드 유형을 사용하여 벡터 검색 인덱스를 구성합니다.

  2. 문서를 일반적으로 삽입하고 업데이트합니다. 그 다음 mongot 은 텍스트 필드를 읽고 구성된 임베딩 모델을 통해 임베딩을 생성하여 저장합니다.

  3. 미리 계산된 임베딩이 아닌 쿼리 텍스트로 $vectorSearch 쿼리를 실행합니다. 그리고 mongot 은 쿼리 텍스트에 대한 임베딩을 생성합니다.

자체 관리형 mongot 자동 임베딩은 Voyage AI 임베딩 모델과 통합됩니다.

모델
설명

voyage-4-lite

비용에 민감한 대용량 애플리케이션.

voyage-4

권장하는 옵션입니다. 일반 텍스트 검색을 위한 균형 잡힌 성능.

voyage-4-large

복잡한 시맨틱 관계에 대한 정확도를 극대화합니다.

voyage-code-3

코드 검색 및 기술 문서화에 전문화되어 있습니다.

You incur costs for embedding generation. To learn more, see Manage Billing for Automated Embedding.

  • mongot Kubernetes 배포서버에서 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 use https://api.voyageai.com/v1/embeddings for direct Voyage AI access if you generated the API key directly from Voyage AI.

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 보안 비밀 저장에 키를 저장합니다.

두 키를 모두 포함하는 쿠버네티스 시크릿 생성:

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 인덱스 정의 필드에 대해 설명합니다.

필드
목적

type: "autoEmbed"

자동 임베딩을 위한 필드를 표시합니다.

modality: "text"

데이터 모달리티. text 만이 지원되는 모달리티입니다.

path

컬렉션에 임베딩할 필드입니다.

model

The Voyage AI model name. The model must be one that your API key has access to.

numDimensions

임베딩 벡터의 차원 수입니다. 지원되는 차원은 모델에 따라 결정됩니다.

similarity

벡터 검색에 사용할 유사성 함수입니다. 지원되는 함수는 cosine, dotProduct, euclidean입니다.

indexingMethod

사용할 인덱싱 방법입니다. 지원되는 방법은 flathnsw입니다.

hnswOptions

(선택 사항) HNSW 인덱스 옵션입니다. indexingMethodhnsw인 경우 필수입니다.

quantization

(선택 사항) 사용할 양자화 유형. 지원되는 유형은 float, scalar, binary, binaryNoRescore입니다.

동일한 인덱스에 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.

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 로그에 나타나며 해당 인덱스에 실패한 문서 지표기로 표시됩니다. 이러한 오류로 인덱스가 비활성화되지는 않지만 새 문서 인덱싱이 지연될 수 있습니다.

증상
가능한 원인

인덱스가 수분 동안 PENDING 상태로 유지됩니다.

mongot cannot reach the embedding endpoint, or the API key is invalid. Check mongot logs for HTTP errors against the embedding endpoint.

인덱싱 지연이 간호적으로 나타납니다.

Voyage AI 측 속도 제한. 속도 제한을 늘리거나 인덱싱 시간 임베딩 부하를 줄이세요.

인덱스에 대한 쿼리는 임베딩을 언급하는 오류를 반환합니다.

The query API key is invalid or expired. Verify the contents of queryKeyFile.

인덱스에 대한 모든 쿼리는 빈 결과를 반환합니다.

인덱스가 다시 빌드되어 여전히 코퍼스를 다시 임베딩하고 있을 수 있습니다. db.collection.getSearchIndexes()으로 인덱스 상태를 확인하세요.

  • 미리 보기 상태. 자동 임베딩이 일반적으로 사용가능해지기 전에 설정 형상, 지원되는 모델 및 기본 엔드포인트가 변경될 수 있습니다.

  • 필드당 하나의 임베딩 모델. 혼합 모델 인덱스는 지원되지 않습니다.

  • 임베딩 모델 페일오버가 없습니다. Voyage AI 엔드포인트에 액세스할 수 없는 경우, 새 문서의 인덱싱이 중단됩니다.