Perplexity 임베딩
Perplexity 임베딩 (Embeddings)
Perplexity의 pplx-embed 임베딩 모델을 LiteLLM에서 사용하는 방법을 알아봐요. 웹 규모의 텍스트 검색용 임베딩 모델을 지원해요.
출처: 문서
본문
LiteLLM은 웹 규모의 텍스트 검색을 위한 Perplexity의 pplx-embed 임베딩 모델을 지원해요.
API 키
# env variable
os.environ['PERPLEXITYAI_API_KEY']
임베딩 사용 예시
from litellm import embedding
import os
os.environ['PERPLEXITYAI_API_KEY'] = ""
response = embedding(
model="perplexity/pplx-embed-v1-0.6b",
input=["good morning from litellm"],
)
print(response)
Proxy 설정
config.yaml:
model_list:
- model_name: pplx-embed-v1-0.6b
litellm_params:
model: perplexity/pplx-embed-v1-0.6b
api_key: os.environ/PERPLEXITYAI_API_KEY
- model_name: pplx-embed-v1-4b
litellm_params:
model: perplexity/pplx-embed-v1-4b
api_key: os.environ/PERPLEXITYAI_API_KEY
Proxy 시작:
litellm --config /path/to/config.yaml
테스트:
curl http://0.0.0.0:4000/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ***" \
-d '{
"model": "pplx-embed-v1-0.6b",
"input": ["good morning from litellm"]
}'
지원 파라미터
Perplexity embeddings는 다음 선택 파라미터를 지원해요:
| 파라미터 | 타입 | 설명 |
|---|---|---|
dimensions |
int | 출력 임베딩 차원. 0.6b 모델은 128–1024, 4b 모델은 128–2560. 기본값은 최댓값. |
encoding_format |
string | "base64_int8" (기본값) 또는 "base64_binary" (압축 출력용) |
파라미터 사용 예시
from litellm import embedding
import os
os.environ['PERPLEXITYAI_API_KEY'] = ""
response = embedding(
model="perplexity/pplx-embed-v1-4b",
input=["Your text here"],
dimensions=512,
)
print(f"Embedding dimensions: {len(response.data[0]['embedding'])}")
curl http://0.0.0.0:4000/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ***" \
-d '{
"model": "pplx-embed-v1-4b",
"input": ["Your text here"],
"dimensions": 512
}'
지원 모델
Perplexity Embddings 문서에 있는 모든 모델을 지원하며, model=perplexity/를 사용해요.
| 모델명 | 차원 | 최대 토큰 | 가격 (1M 토큰당) | 호출 |
|---|---|---|---|---|
pplx-embed-v1-0.6b |
1024 | 32K | $0.004 | embedding(model="perplexity/pplx-embed-v1-0.6b", input) |
pplx-embed-v1-4b |
2560 | 32K | $0.03 | embedding(model="perplexity/pplx-embed-v1-4b", input) |
주요 사양
- 요청당 최대 텍스트 수: 512
- 입력당 최대 토큰: 32,768
- 결합 요청 한도: 120,000 토큰
- Matryoshka 차원 축소 — 더 빠른 검색과 저장 공간 절감을 위해 차원을 128+로 줄일 수 있어요
- 명령 프롬프트 불필요 — 텍스트를 직접 임베딩해요
- 비정규화 임베딩 — 비교 시 코사인 유사도를 사용해요
더 알아보기 (Learn more)
- Perplexity Embeddings 공식 문서
- LiteLLM 임베딩 API