pgvecto.rs의 Docker Pull :
VectorChord (VCHORD)는 확장 가능, 고성능 및 디스크 효율적인 벡터 유사성 검색을 위해 설계된 PostGRESQL 확장자이며 PGVECTO.RS의 후속 역할을합니다.
VectorChord를 사용하면 400,000 벡터를 $ 1에 저장할 수 있습니다. Pinecone의 최적화 된 스토리지에 비해 6 배 더 많은 벡터, PGVECTOR/PGVECTO.RS보다 동일한 가격 1 에 대해 6 배 더 많은 벡터를 저장할 수 있습니다. 추가 통찰력을 보려면 출시 블로그 게시물을 확인하십시오.
Vectorchord는 pgvecto.rs 및 pgvector에 비해 놀라운 개선 사항을 소개합니다.
성능 향상 : PGVECTOR의 HNSW 구현과 비교하여 최대 5 배 더 빠른 쿼리, 16 배 높은 인서트 처리량 및 16x 더 빠른 2 인덱스 빌드로 최적화 된 작업을 제공합니다.
? 저렴한 벡터 검색 : 32GB의 메모리를 사용하는 쿼리 100m 768 차원 벡터로, Top10 리콜@95%로 35ms P50 대기 시간을 달성하여 검색 품질이 높을수록 인프라 비용을 낮추는 데 도움이됩니다.
? 원활한 통합 : PGVECTOR 데이터 유형 및 구문과 완전히 호환하면서 상자에서 최적의 기본값을 제공합니다. 수동 매개 변수 튜닝이 필요하지 않습니다. 성능 향상을 위해 Vectorchord를 떨어 뜨리십시오.
? 외부 인덱스 빌드 : IVF를 활용하여 더 빠른 kmeans 클러스터링을 위해 외부로 인덱스 (예 : GPU)를 구축하여 Rabitq 3 압축과 결합하여 벡터를 효율적으로 저장하면서 자율 재고를 통해 검색 품질을 유지합니다.
? 긴 벡터 지원 : 최대 65,535 차원의 벡터를 저장 및 검색하여 텍스트-엠 베드 딩 -3-large와 같은 최고의 고차원 모델을 쉽게 사용할 수 있습니다.
새로운 사용자의 경우 Docker 이미지를 사용하여 신속하게 시작하는 것이 좋습니다.
docker run
--name vectorchord-demo
-e POSTGRES_PASSWORD=mysecretpassword
-p 5432:5432
-d tensorchord/vchord-postgres:pg17-v0.1.0 그런 다음 psql 명령 줄 도구를 사용하여 데이터베이스에 연결할 수 있습니다. 기본 사용자 이름은 postgres 이고 기본 비밀번호는 mysecretpassword 입니다.
psql -h localhost -p 5432 -U postgres확장이 활성화되도록 다음 SQL을 실행하십시오.
CREATE EXTENSION IF NOT EXISTS vchord CASCADE; 그리고 postgresql.conf 의 shared_preload_libraries 에 vchord.so 추가하십시오.
-- Add vchord and pgvector to shared_preload_libraries --
ALTER SYSTEM SET shared_preload_libraries = ' vchord.so ' ;Vectorchord Rabitq (vchordrq) 색인을 만들려면 다음 SQL을 사용할 수 있습니다.
-- Set residual_quantization to true and spherical_centroids to false for L2 distance --
CREATE INDEX ON gist_train USING vchordrq (embedding vector_l2_ops) WITH (options = $$
residual_quantization = true
[ build . internal ]
lists = [ 4096 ]
spherical_centroids = false
$$);
-- Set residual_quantization to false and spherical_centroids to true for cos/dot distance --
CREATE INDEX ON laion USING vchordrq (embedding vector_cos_ops) WITH (options = $$
residual_quantization = false
[ build . internal ]
lists = [ 4096 ]
spherical_centroids = true
$$);쿼리 문은 PGVector와 정확히 동일합니다. VectorChord는 필터 작동 및 vBase와 pgvecto.rs와 같은 조항을 지원합니다.
SELECT * FROM items ORDER BY embedding < - > ' [3,1,2] ' LIMIT 5 ;지원되는 거리 함수는 다음과 같습니다.
probes 및 epsilon 매개 변수를 조정하여 검색 성능을 미세 조정할 수 있습니다.
-- Set probes to control the number of lists scanned.
-- Recommended range: 3%–10% of the total `lists` value.
SET vchordrq . probes = 100 ;
-- Set epsilon to control the reranking precision.
-- Larger value means more rerank for higher recall rate.
-- Don't change it unless you only have limited memory.
-- Recommended range: 1.0–1.9. Default value is 1.9.
SET vchordrq . epsilon = 1 . 9 ;
-- vchordrq relies on a projection matrix to optimize performance.
-- Add your vector dimensions to the `prewarm_dim` list to reduce latency.
-- If this is not configured, the first query will have higher latency as the matrix is generated on demand.
-- Default value: '64,128,256,384,512,768,1024,1536'
-- Note: This setting requires a database restart to take effect.
ALTER SYSTEM SET vchordrq . prewarm_dim = ' 64,128,256,384,512,768,1024,1536 ' ;그리고 Postgres의 설정을 위해
-- If using SSDs, set `effective_io_concurrency` to 200 for faster disk I/O.
SET effective_io_concurrency = 200 ;
-- Disable JIT (Just-In-Time Compilation) as it offers minimal benefit (1–2%)
-- and adds overhead for single-query workloads.
SET jit = off;
-- Allocate at least 25% of total memory to `shared_buffers`.
-- For disk-heavy workloads, you can increase this to up to 90% of total memory. You may also want to disable swap with network storage to avoid io hang.
-- Note: A restart is required for this setting to take effect.
ALTER SYSTEM SET shared_buffers = ' 8GB ' ;인덱스를 예비하려면 다음 SQL을 사용할 수 있습니다. 제한된 메모리를 사용할 때 성능을 크게 향상시킵니다.
-- vchordrq_prewarm(index_name::regclass) to prewarm the index into the shared buffer
SELECT vchordrq_prewarm( ' gist_train_embedding_idx ' ::regclass) "인덱스 빌딩은 병렬화 될 수 있으며 외부 중심 사전 계산으로 총 시간은 주로 디스크 속도로 제한됩니다. 다음 설정을 사용하여 병렬 처리를 최적화하십시오.
-- Set this to the number of CPU cores available for parallel operations.
SET max_parallel_maintenance_workers = 8 ;
SET max_parallel_workers = 8 ;
-- Adjust the total number of worker processes.
-- Note: A restart is required for this setting to take effect.
ALTER SYSTEM SET max_worker_processes = 8 ; pg_stat_progress_create_index 보기를 쿼리하여 인덱싱 진행 상황을 확인할 수 있습니다.
SELECT phase, round( 100 . 0 * blocks_done / nullif(blocks_total, 0 ), 1 ) AS " % " FROM pg_stat_progress_create_index;Pure SQL과 달리 외부 인덱스 사전 계산은 먼저 외부 클러스터링을 수행하고 PostgreSQL 테이블에 중심을 삽입합니다. 더 복잡 할 수 있지만 더 큰 데이터 세트 (> 5m)에서 외부 빌드가 훨씬 빠릅니다.
시작하려면 faiss , scikit-learn 또는 기타 클러스터링 라이브러리를 사용하여 벡터 클러스터링을 수행해야합니다.
중심은 3 개의 열이있는 이름 테이블에 사전 설정해야합니다.
pgvector 벡터 유형의 표현그리고 예는 다음과 같습니다.
-- Create table of centroids
CREATE TABLE public .centroids (id integer NOT NULL UNIQUE, parent integer , vector vector( 768 ));
-- Insert centroids into it
INSERT INTO public . centroids (id, parent, vector) VALUES ( 1 , NULL , ' {0.1, 0.2, 0.3, ..., 0.768} ' );
INSERT INTO public . centroids (id, parent, vector) VALUES ( 2 , NULL , ' {0.4, 0.5, 0.6, ..., 0.768} ' );
INSERT INTO public . centroids (id, parent, vector) VALUES ( 3 , NULL , ' {0.7, 0.8, 0.9, ..., 0.768} ' );
-- ...
-- Create index using the centroid table
CREATE INDEX ON gist_train USING vchordrq (embedding vector_l2_ops) WITH (options = $$
[ build . external ]
table = ' public.centroids '
$$);워크 플로를 단순화하려면 외부 인덱스 사전 계산에 대한 엔드 투 엔드 스크립트를 제공합니다. 스크립트를 참조하십시오.
PGRX의 지시에 따라 PGRX를 설치하십시오.
cargo install --locked cargo-pgrx
cargo pgrx init --pg17 $( which pg_config ) # To init with system postgres, with pg_config in PATH
cargo pgrx install --release --sudo # To install the extension into the system postgres with sudo 이 소프트웨어는 이중 라이센스 모델에 따라 라이센스가 부여됩니다.
GNU Affero General Public License V3 (AGPLV3) :이 소프트웨어를 AGPLV3의 용어로 사용, 수정 및 배포 할 수 있습니다.
ELV2 (Elastic License V2) :이 소프트웨어를 특정 제한 사항이있는 탄성 라이센스 V2 에서이 소프트웨어를 사용, 수정 및 배포 할 수도 있습니다.
귀하의 요구에 따라 라이센스 중 하나를 선택할 수 있습니다. 우리는 상업적 협업이나 지원을 환영하므로 라이센스와 관련된 질문이나 요청이 있으면 [email protected]로 이메일을 보내주십시오.
768 차원 벡터와 95% 리콜이있는 미스 케일 벤치 마크를 기반으로합니다. ↩
768 차원 벡터가있는 미스 케일 벤치 마크를 기반으로합니다. 자세한 내용은 블로그 게시물을 확인하십시오. ↩
Gao, Jianyang 및 Cheng Long. "Rabitq : 근사한 이웃 검색에 대한 이론적 오류를 갖는 고차원 벡터를 정량화합니다." 데이터 관리에 대한 ACM의 절차 2.3 (2024) : 1-27. ↩