임베딩 제공업체를 선택할 때, 필요와 선호도에 따라 고려할 수 있는 여러 요소가 있습니다:
Anthropic은 자체 임베딩 모델을 제공하지 않습니다. 위의 모든 고려사항을 포괄하는 다양한 옵션과 기능을 갖춘 임베딩 제공업체 중 하나는 Voyage AI입니다.
Voyage AI는 최첨단 임베딩 모델을 만들며, 금융 및 의료와 같은 특정 산업 도메인을 위한 맞춤형 모델이나 개별 고객을 위한 맞춤 파인튜닝 모델을 제공합니다.
이 가이드의 나머지 부분은 Voyage AI에 대한 것이지만, 특정 사용 사례에 가장 적합한 것을 찾기 위해 다양한 임베딩 벤더를 평가하시기를 권장합니다.
Voyage는 다음 텍스트 임베딩 모델 사용을 권장합니다:
| 모델 | 컨텍스트 길이 | 임베딩 차원 | 설명 |
|---|---|---|---|
voyage-3-large | 32,000 | 1024 (기본값), 256, 512, 2048 | 최고의 범용 및 다국어 검색 품질. 자세한 내용은 블로그 포스트를 참조하세요. |
voyage-3.5 | 32,000 | 1024 (기본값), 256, 512, 2048 | 범용 및 다국어 검색 품질에 최적화. 자세한 내용은 블로그 포스트를 참조하세요. |
voyage-3.5-lite | 32,000 | 1024 (기본값), 256, 512, 2048 | 지연 시간 및 비용에 최적화. 자세한 내용은 블로그 포스트를 참조하세요. |
voyage-code-3 | 32,000 | 1024 (기본값), 256, 512, 2048 | 코드 검색에 최적화. 자세한 내용은 블로그 포스트를 참조하세요. |
voyage-finance-2 | 32,000 | 1024 | 금융 검색 및 RAG에 최적화. 자세한 내용은 블로그 포스트를 참조하세요. |
voyage-law-2 | 16,000 | 1024 | 법률 및 긴 컨텍스트 검색과 RAG에 최적화. 모든 도메인에서 성능이 향상되었습니다. 자세한 내용은 블로그 포스트를 참조하세요. |
추가로, 다음 멀티모달 임베딩 모델이 권장됩니다:
| 모델 | 컨텍스트 길이 | 임베딩 차원 | 설명 |
|---|---|---|---|
voyage-multimodal-3 | 32000 | 1024 | PDF 스크린샷, 슬라이드, 표, 그림 등과 같은 텍스트와 콘텐츠가 풍부한 이미지를 인터리빙하여 벡터화할 수 있는 풍부한 멀티모달 임베딩 모델. 자세한 내용은 블로그 포스트를 참조하세요. |
어떤 텍스트 임베딩 모델을 사용할지 결정하는 데 도움이 필요하신가요? FAQ를 확인하세요.
Voyage 임베딩에 접근하려면:
export VOYAGE_API_KEY="<your secret key>"아래에 설명된 대로 공식 voyageai Python 패키지 또는 HTTP 요청을 사용하여 임베딩을 얻을 수 있습니다.
voyageai 패키지는 다음 명령어로 설치할 수 있습니다:
pip install -U voyageai그런 다음, 클라이언트 객체를 생성하고 텍스트 임베딩을 시작할 수 있습니다:
import voyageai
vo = voyageai.Client()
# This will automatically use the environment variable VOYAGE_API_KEY.
# Alternatively, you can use vo = voyageai.Client(api_key="<your secret key>")
texts = ["Sample text 1", "Sample text 2"]
result = vo.embed(texts, model="voyage-3.5", input_type="document")
print(result.embeddings[0])
print(result.embeddings[1])result.embeddings는 각각 1024개의 부동소수점 숫자를 포함하는 두 개의 임베딩 벡터 리스트가 됩니다. 위 코드를 실행하면 두 임베딩이 화면에 출력됩니다:
[-0.013131560757756233, 0.019828535616397858, ...] # embedding for "Sample text 1"
[-0.0069352793507277966, 0.020878976210951805, ...] # embedding for "Sample text 2"임베딩을 생성할 때, embed() 함수에 몇 가지 다른 인수를 지정할 수 있습니다.
Voyage Python 패키지에 대한 자세한 정보는 Voyage 문서를 참조하세요.
Voyage HTTP API를 요청하여 임베딩을 얻을 수도 있습니다. 예를 들어, 터미널에서 curl 명령어를 통해 HTTP 요청을 보낼 수 있습니다:
curl https://api.voyageai.com/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VOYAGE_API_KEY" \
-d '{
"input": ["Sample text 1", "Sample text 2"],
"model": "voyage-3.5"
}'받게 되는 응답은 임베딩과 토큰 사용량을 포함하는 JSON 객체입니다:
{
"object": "list",
"data": [
{
"embedding": [-0.013131560757756233, 0.019828535616397858, ...],
"index": 0
},
{
"embedding": [-0.0069352793507277966, 0.020878976210951805, ...],
"index": 1
}
],
"model": "voyage-3.5",
"usage": {
"total_tokens": 10
}
}
Voyage HTTP API에 대한 자세한 정보는 Voyage 문서를 참조하세요.
Voyage 임베딩은 AWS Marketplace에서 사용할 수 있습니다. AWS에서 Voyage에 접근하는 방법에 대한 안내는 여기에서 확인할 수 있습니다.
이제 임베딩을 얻는 방법을 알았으니, 간단한 예제를 살펴보겠습니다.
검색할 6개의 문서로 구성된 작은 코퍼스가 있다고 가정해 봅시다
documents = [
"The Mediterranean diet emphasizes fish, olive oil, and vegetables, believed to reduce chronic diseases.",
"Photosynthesis in plants converts light energy into glucose and produces essential oxygen.",
"20th-century innovations, from radios to smartphones, centered on electronic advancements.",
"Rivers provide water, irrigation, and habitat for aquatic species, vital for ecosystems.",
"Apple's conference call to discuss fourth fiscal quarter results and business updates is scheduled for Thursday, November 2, 2023 at 2:00 p.m. PT / 5:00 p.m. ET.",
"Shakespeare's works, like 'Hamlet' and 'A Midsummer Night's Dream,' endure in literature."
]
먼저 Voyage를 사용하여 각 문서를 임베딩 벡터로 변환합니다
import voyageai
vo = voyageai.Client()
# Embed the documents
doc_embds = vo.embed(
documents, model="voyage-3.5", input_type="document"
).embeddings임베딩을 통해 벡터 공간에서 의미 검색/검색을 수행할 수 있습니다. 예제 쿼리가 주어지면,
query = "When is Apple's conference call scheduled?"이를 임베딩으로 변환하고, 임베딩 공간에서의 거리를 기반으로 가장 관련성 높은 문서를 찾기 위해 최근접 이웃 검색을 수행합니다.
import numpy as np
# Embed the query
query_embd = vo.embed(
[query], model="voyage-3.5", input_type="query"
).embeddings[0]
# Compute the similarity
# Voyage embeddings are normalized to length 1, therefore dot-product
# and cosine similarity are the same.
similarities = np.dot(doc_embds, query_embd)
retrieved_id = np.argmax(similarities)
print(documents[retrieved_id])문서와 쿼리를 임베딩할 때 각각 input_type="document"와 input_type="query"를 사용한다는 점에 유의하세요. 자세한 사양은 여기에서 확인할 수 있습니다.
출력은 5번째 문서가 되며, 이는 실제로 쿼리와 가장 관련성이 높은 문서입니다:
Apple's conference call to discuss fourth fiscal quarter results and business updates is scheduled for Thursday, November 2, 2023 at 2:00 p.m. PT / 5:00 p.m. ET.벡터 데이터베이스를 포함한 임베딩으로 RAG를 수행하는 방법에 대한 자세한 쿡북 세트를 찾고 계시다면, RAG 쿡북을 확인하세요.
최신 가격 세부 정보는 Voyage의 가격 페이지를 방문하세요.
Was this page helpful?