임베딩#

Xinference에서 텍스트 임베딩을 만드는 방법을 알아보세요.

Introduce#

텍스트 임베딩은 서로 다른 텍스트 간의 상관성을 정량화하는 데 사용됩니다. 이는 검색, 클러스터링, 추천, 이상 탐지, 다양성 측정 및 분류를 포함한 다양한 애플리케이션에 적용될 수 있습니다.

embedding은 부동소수점 숫자로 구성된 벡터입니다. 두 벡터 간의 근접성은 유사성을 나타내는 지표가 될 수 있습니다. 거리가 작을수록 관련성이 높고, 거리가 클수록 관련성이 낮음을 의미합니다.

Xinference에서 Embeddings API를 통해 모델을 임베딩하여 호출할 수 있습니다. Embeddings API는 OpenAI의 create embeddings API 를 모방합니다.

API 엔드포인트

OpenAI 호환 엔드포인트

Embeddings API

/v1/embeddings

지원되는 모델 목록#

:ref:`Xinference 내장 임베딩 모델 <models_embedding_index>`을 모두 확인할 수 있습니다.

빠른 시작#

cURL, OpenAI Client 또는 Xinference의 Python 클라이언트를 통해 Embeddings API를 시도할 수 있습니다.

curl -X 'POST' \
  'http://<XINFERENCE_HOST>:<XINFERENCE_PORT>/v1/embeddings' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "<MODEL_UID>",
    "input": "What is the capital of China?"
  }'

튜토리얼 노트북에서 embed 기능에 대한 더 많은 예제를 찾을 수 있습니다.

LangChain Streamlit 문서 대화

LangChain을 통해 임베딩 API를 사용하는 방법을 예제 하나로 배워보세요.

https://github.com/xorbitsai/inference/blob/main/examples/LangChain_Streamlit_Doc_Chat.py

FAQ#

LLM은 Xinference에서 Embeddings API를 지원합니까?#

No. Xinference doesn’t provide embed API for LLMs due to considerations of performance.

Embeddings API는 LangChain과의 통합 방법을 제공합니까?#

네, LangChain 관련 부분의 공식 Xinference 문서를 참고할 수 있습니다. 링크는 다음과 같습니다: Text Embedding Models: Xinference

Does Embeddings API support hrbrid model?#

Yes, you can use flag as the engine to deploy the model and call Embeddings API by setting the extra parameter return_parse=True which will return sparse vectors.