Hub documentation
벡터 유사도 검색 수행
단일 로그인(SSO) 감사 로그 스토리지 리전 비공개 데이터셋용 Data Studio 리소스 그룹(액세스 제어) 고급 컴퓨트 옵션 고급 보안 토큰 관리 서비스 계정 발행자 분석 게이팅 그룹 컬렉션 네트워크 보안 다운로드 분석 속도 제한 블로그 글
PRO 플랜 리포지토리 레포지토리 시작하기 저장소 설정 저장 용량 제한 스토리지 백엔드(Xet) 로컬 캐시 Pull Requests & Discussions 알림 컬렉션 Webhooks GitHub Actions 노트북 다음 단계 라이선스
모델 모델 허브 모델 카드 평가 결과 리더보드 데이터 게이트된 모델 모델 업로드 모델 다운로드 통합 라이브러리 모델 위젯 모델 추론 모델 다운로드 통계 모델 릴리스 체크리스트 하드웨어 로컬 앱 자주 묻는 질문 고급 주제
데이터셋 Datasets 개요 Dataset Cards 게이트된 데이터셋 데이터셋 업로드 데이터셋 업로드 (LLM용) 데이터셋 다운로드 스트리밍 데이터셋 통합 라이브러리
Spaces Argilla Daft Dask 데이터셋 Data Designer Distilabel DuckDB Embedding Atlas fenic FiftyOne Lance Pandas Polars Spark WebDataset Zephon
Data Studio Agent Traces 데이터셋 다운로드 통계 Spaces 개요 Spaces GPU 업그레이드 Spaces ZeroGPU Spaces Dev Mode Spaces 디스크 사용량 및 저장소 Spaces 사용자 지정 도메인 MCP 서버로 사용 가능한 Spaces Spaces를 에이전트 도구로 API 엔드포인트로 사용하는 Spaces Gradio Spaces Streamlit Spaces Static HTML Spaces Docker Spaces Space 임베드하기 Docker로 Spaces 실행 Spaces 구성 참조 HF로 로그인 버튼 주요 Spaces Spaces 변경 이력 고급 주제
Storage Buckets new 컨테이너 이미지 new Jobs Jobs 개요 빠른 시작 Pricing and Billing 작업 관리 구성 Docker 이미지 사용 모델 서빙 모델 학습 예제 및 튜토리얼 대규모 데이터셋 처리 Schedule Jobs Webhook 자동화 참고
에이전트 에이전트 개요 AI 에이전트를 위한 Hugging Face CLI Hugging Face MCP 서버 Hugging Face Agent Skills HF SDK를 사용하여 에이전트 구축하기 llama.cpp를 활용한 로컬 에이전트 에이전트 라이브러리 세션 추적 형식
기타 벡터 유사도 검색 수행
Fixed-Length Arrays 기능은 DuckDB 버전 0.10.0에 추가되었습니다. 이를 통해 DuckDB 테이블에서 벡터 임베딩을 사용할 수 있어 데이터 분석이 더욱 강력해집니다.
또한, array_cosine_similarity 함수가 도입되었습니다. 이 함수는 두 벡터 사이의 각도의 코사인 값을 측정하여 유사도를 나타냅니다. 값이 1이면 완전히 일치하고, 0이면 수직이며, -1이면 완전히 반대 방향임을 의미합니다.
이 함수를 유사도 검색에 사용하는 방법을 살펴보겠습니다. 이 섹션에서는 DuckDB를 사용하여 유사도 검색을 수행하는 방법을 보여드립니다.
asoria/awesome-chatgpt-prompts-embeddings 데이터셋을 사용할 것입니다.
먼저, 데이터셋에서 몇 개의 레코드를 미리 살펴보겠습니다:
FROM 'hf://datasets/asoria/awesome-chatgpt-prompts-embeddings/data/*.parquet' SELECT act, prompt, len(embedding) as embed_len LIMIT 3;
┌──────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬───────────┐
│ act │ prompt │ embed_len │
│ varchar │ varchar │ int64 │
├──────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼───────────┤
│ Linux Terminal │ I want you to act as a linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output insid… │ 384 │
│ English Translator… │ I want you to act as an English translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer… │ 384 │
│ `position` Intervi… │ I want you to act as an interviewer. I will be the candidate and you will ask me the interview questions for the `position` position. I want you to only reply as the inte… │ 384 │
└──────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴───────────┘
다음으로, 유사도 검색에 사용할 임베딩을 선택해 보겠습니다:
FROM 'hf://datasets/asoria/awesome-chatgpt-prompts-embeddings/data/*.parquet' SELECT embedding WHERE act = 'Linux Terminal';
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ embedding │
│ float[] │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ [-0.020781303, -0.029143505, -0.0660217, -0.00932716, -0.02601602, -0.011426172, 0.06627567, 0.11941507, 0.0013917526, 0.012889079, 0.053234346, -0.07380514, 0.04871567, -0.043601237, -0.0025319182, 0.0448… │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
이제 선택한 임베딩을 사용하여 유사한 레코드를 찾아 보겠습니다:
SELECT act,
prompt,
array_cosine_similarity(embedding::float[384], (SELECT embedding FROM 'hf://datasets/asoria/awesome-chatgpt-prompts-embeddings/data/*.parquet' WHERE act = 'Linux Terminal')::float[384]) AS similarity
FROM 'hf://datasets/asoria/awesome-chatgpt-prompts-embeddings/data/*.parquet'
ORDER BY similarity DESC
LIMIT 3;
┌──────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬────────────┐
│ act │ prompt │ similarity │
│ varchar │ varchar │ float │
├──────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ Linux Terminal │ I want you to act as a linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output insi… │ 1.0 │
│ JavaScript Console │ I want you to act as a javascript console. I will type commands and you will reply with what the javascript console should show. I want you to only reply with the termin… │ 0.7599728 │
│ R programming Inte… │ I want you to act as a R interpreter. I'll type commands and you'll reply with what the terminal should show. I want you to only reply with the terminal output inside on… │ 0.7303775 │
└──────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────────┘
이것으로 끝입니다! DuckDB를 사용하여 벡터 유사도 검색을 성공적으로 수행했습니다.
Update on GitHub