DLT(Data Load Tool) 연동

DLT(Data Load Tool) 연동 (dlt)

DLT는 Data Load Tool의 약자로, Python 스크립트에 추가해서 다양하고 종종 지저분한 데이터 소스들을 잘 구조화된 라이브 데이터셋으로 로드할 수 있게 해 주는 오픈소스 라이브러리예요. DLT-Qdrant 통합을 사용하면 이제 DLT의 destination(목적지) 으로 Qdrant를 선택해서 데이터를 로드할 수 있게 되죠.

출처: Qdrant 공식 문서 — dlt

DLT가 제공하는 것들

  • 자동화된 유지보수 — 스키마 추론(schema inference), 알림, 짧은 선언형 코드 덕분에 유지보수가 단순해져요.
  • Python이 실행되는 곳 어디서든 — Airflow, 서버리스 함수, 노트북 등에서 실행돼요. 마이크로 규모든 대규모 인프라든 모두에 맞게 확장되죠.
  • 사용자 친화적인 선언형 인터페이스 — 초보자에게는 진입 장벽을 없애주고, 시니어 전문가에게는 더 강력한 도구가 되어줘요.

사용법 (Usage)

시작하려면 dltqdrant extra와 함께 설치해야 해요.

pip install "dlt[qdrant]"

DLT secrets 파일에 destination을 설정해요. 기본적으로 파일은 ~/.dlt/secrets.toml에 위치해 있어요. 다음 섹션을 secrets 파일에 추가하면 됩니다.

[destination.qdrant.credentials]
location = "https://your-qdrant-url"
api_key = "your-qdrant-api-key"

location은 기본적으로 http://localhost:6333으로 설정되고, api_key는 정의되지 않으면 로컬 Qdrant 인스턴스의 기본값을 그대로 사용해요. DLT 설정에 대한 더 자세한 내용은 여기에서 확인할 수 있어요.

이제 데이터의 source를 정의해 볼게요.

import dlt
from dlt.destinations.qdrant import qdrant_adapter

movies = [
    {
        "title": "Blade Runner",
        "year": 1982,
        "description": "The film is about a dystopian vision of the future that combines noir elements with sci-fi imagery.",
    },
    {
        "title": "Ghost in the Shell",
        "year": 1995,
        "description": "The film is about a cyborg policewoman and her partner who set out to find the main culprit behind brain hacking, the Puppet Master.",
    },
    {
        "title": "The Matrix",
        "year": 1999,
        "description": "The movie is set in the 22nd century and tells the story of a computer hacker who joins an underground group fighting the powerful computers that rule the earth.",
    },
]

파이프라인을 정의해요.

pipeline = dlt.pipeline(
    pipeline_name="movies",
    destination="qdrant",
    dataset_name="movies_dataset",
)

파이프라인을 실행하죠.

info = pipeline.run(qdrant_adapter(movies, embed=["title", "description"]))

이제 데이터가 Qdrant에 로드되었어요.

중요한 포인트: 데이터가 로드된 뒤 벡터 검색을 사용하려면, Qdrant가 임베딩을 생성해야 하는 필드를 지정해야 해요. 이 작업은 데이터(또는 DLT resource)를 qdrant_adapter 함수로 감싸면서 수행됩니다.

Write Disposition

DLT의 write disposition은 데이터를 destination에 어떻게 쓸지 정의해요. Qdrant destination은 모든 write disposition을 지원합니다.

DLT Sync

Qdrant destination은 DLT state의 동기화를 지원해요.

다음 단계 (Next steps)

  • Qdrant DLT destination에 대한 종합 문서는 여기에서 확인할 수 있어요.
  • 소스 코드

더 알아보기 (Learn more)