API 엔드포인트 (embed·rerank·predict)

API 엔드포인트 (embed·rerank·predict)

TEI는 프로덕션용 HTTP 추론 서버로, 세 가지 주요 엔드포인트를 제공해요. 모두 OpenAI 호환 래퍼인 /v1/embeddings로도 사용할 수 있어서 기존 RAG 파이프라인에 드롭인으로 들어갈 수 있어요.

/embed — dense 임베딩

단일 텍스트를 보내면 float 벡터를 반환해요.

curl 127.0.0.1:8080/embed \
    -X POST \
    -d '{"inputs":"What is Deep Learning?"}' \
    -H 'Content-Type: application/json'

여러 입력을 배치로 보낼 수도 있어요.

curl 127.0.0.1:8080/embed \
    -X POST \
    -d '{"inputs":["Today is a nice day", "I like you"]}' \
    -H 'Content-Type: application/json'

/rerank — 리랭킹 (크로스-인코더)

리랭커는 쿼리와 텍스트 사이의 유사도를 점수로 매기는, 클래스가 하나인 시퀀스 분류 모델이에요. RAG 파이프라인의 다운스트림 성능을 높이는 데 쓰여요.

curl 127.0.0.1:8080/rerank \
    -X POST \
    -d '{"query":"What is Deep Learning?", "texts": ["Deep Learning is not...", "Deep learning is..."], "raw_scores": false}' \
    -H 'Content-Type: application/json'

BAAI/bge-reranker-large 같은 리랭커 모델을 배포해 사용할 수 있어요.

/predict — 시퀀스 분류

클래식 시퀀스 분류 모델의 경우 /predict로 클래스 확률을 얻어요. 예를 들어 감정 분석 모델은 이렇게 사용해요.

curl 127.0.0.1:8080/predict \
    -X POST \
    -d '{"inputs":"I like you."}' \
    -H 'Content-Type: application/json'

시퀀스 분류 배칭은 입력을 중첩 배열로 보내요.

curl 127.0.0.1:8080/predict \
    -X POST \
    -d '{"inputs":[["I like you."], ["I hate pineapples"]]}' \
    -H 'Content-Type: application/json'

더 알아보기