FastEmbed 퀵스타트 — 텍스트 임베딩 생성

FastEmbed 퀵스타트 — 텍스트 임베딩 생성

FastEmbed로 텍스트 임베딩을 몇 줄 만에 생성할 수 있어요. 기본 모델은 BAAI/bge-small-en-v1.5로 384차원 벡터를 만들어요.

설치

pip install fastembed

먼저 타입 힌트와 NumPy를 준비해요.

from typing import List
import numpy as np

기본 모델 로드

from fastembed import TextEmbedding

샘플 데이터 추가

documents: List[str] = [
    "FastEmbed is lighter than Transformers & Sentence-Transformers.",
    "FastEmbed is supported by and maintained by Qdrant.",
]

모델을 다운로드하고 초기화해요.

embedding_model = TextEmbedding()
print("The model BAAI/bge-small-en-v1.5 is ready to use.")

데이터 임베딩

embeddings_generator = embedding_model.embed(documents)
embeddings_list = list(embeddings_generator)
len(embeddings_list[0])   # 384

기본 모델은 384차원 벡터를 반환해요. 이렇게 생성한 벡터를 Qdrant에 넣어 의미 검색을 구성할 수 있어요.

더 알아보기 (Learn more)

출처: Qdrant FastEmbed 문서