Skip to content

Feature: compression for index files #597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 of 3 tasks
liquidcarbon opened this issue Apr 23, 2025 · 0 comments
Open
2 of 3 tasks

Feature: compression for index files #597

liquidcarbon opened this issue Apr 23, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@liquidcarbon
Copy link

liquidcarbon commented Apr 23, 2025

Describe what you are looking for

It appears that Parquet is doing something clever when compressing vectors, resulting in rather small file sizes for sparse and low-cardinality vectors:

import numpy as np
import pandas as pd
from usearch.index import Index, MetricKind

np.random.seed(42)
file_pq = "test10Kx1024uint8.parquet"
file_usearch = "test10Kx1024uint8.usearch"

max_value = 4
N = 10_000

df = pd.DataFrame({
    "vec": [v for v in np.random.randint(max_value, size=(N, 1024), dtype=np.uint8)]
})
df.to_parquet(file_pq, compression="snappy")

index = Index(ndim=1024, dtype="i8", metric=MetricKind.L2sq)
index.add(df.index, np.stack(df.vec.values))
index.save(file_usearch)

#!stat --printf '%s %n\n' test*
#
# max_value = 256:
# 10266482 test10Kx1024uint8.parquet
# 11725264 test10Kx1024uint8.usearch
#
# max_value = 4:
#  2584703 test10Kx1024uint8.parquet
# 11725264 test10Kx1024uint8.usearch

Is there an opportunity to tweak the storage format to make storage more efficient?
Maybe by leveraging Parquet + writing extra attributes necessary for the index to work?

Can you contribute to the implementation?

  • I can contribute

Is your feature request specific to a certain interface?

It applies to everything

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@liquidcarbon liquidcarbon added the enhancement New feature or request label Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant