Facebook AI Similarity Search (FAISS)는 밀집 벡터의 효율적인 유사도 검색 및 클러스터링을 위한 라이브러리입니다. RAM에 맞지 않을 수 있는 크기를 포함하여 모든 크기의 벡터 집합에서 검색하는 알고리즘을 포함합니다. 또한 평가 및 매개변수 튜닝을 위한 지원 코드도 포함되어 있습니다. The FAISS Library 논문을 참조하세요.FAISS 문서는 이 페이지에서 찾을 수 있습니다. 이 노트북은
FAISS vector database와 관련된 기능을 사용하는 방법을 보여줍니다. 이 통합에 특화된 기능을 보여줄 것입니다. 이 내용을 살펴본 후, 관련 사용 사례 페이지를 탐색하여 이 vectorstore를 더 큰 chain의 일부로 사용하는 방법을 배우는 것이 유용할 수 있습니다.
Setup
이 통합은langchain-community 패키지에 포함되어 있습니다. 또한 faiss 패키지 자체도 설치해야 합니다. 다음과 같이 설치할 수 있습니다:
GPU 지원 버전을 사용하려면 faiss-gpu를 설치할 수도 있습니다.
Initialization
Manage vector store
Add items to vector store
Delete items from vector store
Query vector store
vector store가 생성되고 관련 문서가 추가되면, chain이나 agent를 실행하는 동안 쿼리하고 싶을 것입니다.Query directly
Similarity search
metadata에 대한 필터링과 함께 간단한 유사도 검색을 수행하는 방법은 다음과 같습니다:$eq(equals)$neq(not equals)$gt(greater than)$lt(less than)$gte(greater than or equal)$lte(less than or equal)$in(membership in list)$nin(not in list)$and(all conditions must match)$or(any condition must match)$not(negation of condition)
Similarity search with score
score와 함께 검색할 수도 있습니다:Other search methods
FAISS vector store를 검색하는 다양한 다른 방법이 있습니다. 이러한 메서드의 전체 목록은 API Reference를 참조하세요.Query by turning into retriever
vector store를 retriever로 변환하여 chain에서 더 쉽게 사용할 수도 있습니다.Usage for retrieval-augmented generation
retrieval-augmented generation (RAG)을 위해 이 vector store를 사용하는 방법에 대한 가이드는 다음 섹션을 참조하세요:Saving and loading
FAISS index를 저장하고 로드할 수도 있습니다. 이는 사용할 때마다 다시 생성할 필요가 없어 유용합니다.Merging
두 개의 FAISS vectorstore를 병합할 수도 있습니다.API reference
모든FAISS vector store 기능 및 구성에 대한 자세한 문서는 API reference를 참조하세요: python.langchain.com/api_reference/community/vectorstores/langchain_community.vectorstores.faiss.FAISS.html
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.