Skip to main content

No project description provided

Project description

Easy Faiss

Easy Faiss is a package for creating vector indexes / knowledge base for LLM chatbots. This provides an easy-to-use alternative over using vector databases such as Pinecone or Weaviate.

Example script:

import easyfaiss as ef

model, tokenizer = ef.bert_setup()

data = [
    "Hello, how are you?",
    "What's the weather today?",
    "How does photosynthesis work?",
    "What's the capital of France?",
    "Tell me about the history of the Roman Empire.",
    "How can I improve my coding skills?",
    "What's the recipe for a classic margarita?",
    "Explain the theory of relativity.",
    "What's the population of Tokyo?",
    "How can I learn a new language quickly"
]

# create embeddings to store in index
embeddings = ef.create_embeddings(model=model, tokenizer=tokenizer, dataset=data)

# create a query vector to perform similarity search on the index
user_query = "What's the population in Tokyo, Japan?"
query_vector = ef.create_embeddings(model=model, tokenizer=tokenizer, dataset=[user_query])

# create the index
flat_index = ef.FlatIndex(name='demo')
flat_index.create_index(dimensions=768)
flat_index.update_index(embeddings=embeddings, dataset=data)

print(flat_index.details())

# perform similarity search
indices, distances = flat_index.similarity_search(query_vector=query_vector, k=3)

EasyFaiss currently provides 2 types of faiss indexes

FlatIndex:

  • Speed: This index is relatively slower for nearest neighbor search, especially as the number of vectors increases.
  • Scale: Suitable for smaller datasets with low to moderate memory requirements.
  • Accuracy: Provides exact nearest neighbor search, making it the most accurate option.

HNSWFlatIndex:

  • Speed: Hierarchical Navigable Small World (HNSW) allows for fast approximate nearest neighbor search, especially on large datasets.
  • Scale: Well-suited for large datasets, as it uses approximate nearest neighbor search, which makes it more memory-efficient.
  • Accuracy: Provides approximate results that might have a small trade-off in accuracy compared to FlatIndex.

The choice between these two index types depends on your specific use case:

  • Use FlatIndex when you have a relatively small dataset and need precise, exact nearest neighbor search.
  • Use HNSWFlatIndex when you have a larger dataset, and you can tolerate a small reduction in accuracy in exchange for faster search and lower memory requirements.

For FlatIndex, an upper limit for the number of vectors depends on the available memory, but it's typically suitable for a few thousand vectors (e.g., up to 10,000 or more, depending on the dimension of the vectors and available RAM). Beyond that, you might start experiencing memory limitations. HNSWFlatIndex is a good choice for larger datasets, including millions of vectors, provided you can accept the trade-offs in accuracy.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easyfaiss-0.1.4.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

easyfaiss-0.1.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file easyfaiss-0.1.4.tar.gz.

File metadata

  • Download URL: easyfaiss-0.1.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/6.2.0-35-generic

File hashes

Hashes for easyfaiss-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3dd2f13a94441a87eb975319d46aa2ae4ea71d8e68cf376278e2c1ebf52856e0
MD5 470ba76888e97d9f269f61e97b616c65
BLAKE2b-256 ff6e60938b9bcbf1ae7c16e53aff8784464b2ddd9b16c67ca7cb0a5cc8672b4f

See more details on using hashes here.

File details

Details for the file easyfaiss-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: easyfaiss-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/6.2.0-35-generic

File hashes

Hashes for easyfaiss-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 167fb9ab51b0208f1d1c7035b7d0159a9eb8b14624cefaa999a8f5c27efc8775
MD5 d1114c733197069835a9f942fd58ba1d
BLAKE2b-256 f294efe26c6e35c1cd095e9d817be26b39989238a6fee93624bf915957fd43ec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page