Skip to content

Donwload and process INT8 datasets - #2

Open
r-devulap wants to merge 9 commits into
tlwillke:mainfrom
r-devulap:process-int8
Open

r-devulap wants to merge 9 commits into
tlwillke:mainfrom
r-devulap:process-int8

Conversation

@r-devulap

Copy link
Copy Markdown

Adds end-to-end support for processing INT8 quantized vector datasets into .bvecs format. This includes passthrough handling across normalization, deduplication, zero-removal, and splitting stages, .bvecs support in ground-truth k-NN calculations, and download/processing configurations for several INT8 datasets.

Key Changes

1. INT8 and .bvecs Support in the Pipeline

  • New bvecs_writer.py

    • Added a utility to export vectors directly to the standard .bvecs binary format:
      • Header dimension (d) stored as int32
      • Vector components stored as int8/uint8
  • Pipeline Passthrough Support

    • Updated processing.py and config.py to support:
      • INT8 dtype detection
      • Passthrough flags
      • .bvecs outputs
    • Updated the following processing stages to handle INT8 data without forced float conversions or unintended transformations:
      • fvecs_normalize.py
      • fvecs_remove_zeros.py
      • fvecs_deduplicator.py
      • fvecs_split.py
  • Ground Truth Stage

    • Updated knn_utils.py to load .bvecs datasets and compute ground-truth nearest neighbors.
  • Readers

    • Updated readers.py to correctly handle INT8 columns and formats.

2. New Dataset Download and Processing Configurations

MixedBread Large INT8

  • Added download configuration:
    • mich_embeddings_int8_mixed_bread_large_download.py
  • Added processing configuration:
    • mich_embeddings_int8_mixed_bread_large_proc.py

Wikipedia 2023-11 EN MXBAI INT8 (1M)

  • Added download configuration:
    • wikipedia_2023_11_en_mxbai_int8_download.py
  • Added processing configuration:
    • wikipedia_2023_11_en_mxbai_int8_1m_proc.py

Wiki Multilingual v3 INT8 (1M)

  • Added processing configuration:
    • wiki_multilingual_v3_int8_1m_proc.py

3. Dependencies and Tooling

  • Added requirements.txt listing required third-party dependencies:
    • huggingface_hub
    • pyarrow
    • scikit-learn
    • numpy

    - Add bvecs_writer.py: write/append/count for .bvecs (int8 per-vector
      with int32 dim header), the INT8 equivalent of fvecs_writer.py

    - readers.py: ParquetEmbeddingReader gains output_dtype param ('float32'
      or 'int8'); build_reader forwards it so parquet INT8 columns are read
      as np.int8 without any float cast

    - fvecs_remove_zeros.py: detect .bvecs suffix, read/write int8, cast to
      float32 only for norm computation

    - fvecs_normalize.py: detect .bvecs suffix; copy file through unchanged
      (INT8 vectors cannot be meaningfully normalized in-place); emits
      expected log lines so processing.py metadata parsing works

    - fvecs_deduplicator.py: add _vec_nbytes/_vec_fmt helpers; all reader,
      writer, merge, and presorted-dedup paths detect .bvecs and use d bytes
      per vector with 'b' struct format instead of 4*d/'f'

    - fvecs_split.py: read_dim_and_count gains is_bvecs param; main detects
      suffix and uses record_size = 4+dim instead of 4+4*dim

    - config.py: add SOURCE_INT8 flag (from dataset config, default False);
      all intermediate working-file paths use .bvecs extension when true

    - processing.py: import append_bvecs/count_bvecs; extraction uses
      append_bvecs when SOURCE_INT8; count_output_file handles .bvecs;
      final artifact rename uses correct extension
Add config for wikipedia-2023-11 multilingual-v3 INT8 dataset (1M base,
10k query, emb_int8 column, SOURCE_INT8=True, output to
/home/ubuntu/dataset_cache/int8-datasets/processed/)
- add read_bvecs(): reads int8 records (4+dim bytes each), upcasts to
  float32 for FAISS
- add write_bvecs(): clips float32 back to int8 for processed output files
- add _write_vectors(): dispatches to write_fvecs or write_bvecs by suffix
- read_vectors(): detect .bvecs extension and call read_bvecs
- all processed_base_out/processed_query_out writes go through
  _write_vectors so .bvecs paths are handled correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant