embedding-reader is a Python library designed for efficiently reading embeddings from various file formats, including HDF5, Parquet, JSON, TSV, and NumPy with memory mapping (mmap). It also provides functionality to download embeddings from Hugging Face datasets. The library focuses on performance and ease of use for large-scale embedding datasets. The current version is 1.8.1, and it maintains a regular release cadence, often with monthly or bi-monthly updates.
pip install embedding-readerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `EmbeddingReader` and read embeddings and their corresponding IDs from a file. It includes a setup for a dummy HDF5 file to make the example runnable. For actual use, replace `dummy_h5_path` with your local file path or a Hugging Face dataset identifier (e.g., `hf://facebook/dolly-v2-7b-embeddings`). Remember to specify the `embedding_column_name` and `id_column_name` if they differ from the defaults (`embedding` and `id` respectively).
Always prepend `hf://` for Hugging Face paths. For multi-config datasets, specify `dataset_name` and `subfolder` during `EmbeddingReader` initialization or ensure `path` points to a specific config.
Explicitly pass `dataset_name` and `subfolder` parameters to the `EmbeddingReader` constructor when dealing with Hugging Face datasets, especially those with multiple configurations or nested structures.
If automatic format detection fails, provide `file_format='hdf5'`, `file_format='parquet'`, etc., in the `EmbeddingReader` constructor.
When dealing with large .npy files, initialize `EmbeddingReader` with `mmap_mode='r'` (e.g., `EmbeddingReader(path='file.npy', mmap_mode='r')`).
Ensure the package is installed in your current Python environment using `pip install embedding-reader`.
Double-check the file path. Ensure it's absolute or relative to your current working directory. If it's a remote path, confirm network access and correct URI (e.g., `s3://`, `hf://`).
Rename the file with a supported extension (e.g., `.h5`, `.parquet`, `.npy`) or explicitly specify the `file_format` parameter during `EmbeddingReader` initialization (e.g., `EmbeddingReader(path='embeddings.dat', file_format='hdf5')`).
Inspect your HDF5/Parquet file to confirm the actual column names. Then, pass the correct names to the `EmbeddingReader` constructor: `EmbeddingReader(..., embedding_column_name='my_embeddings_key', id_column_name='doc_id')`.