simonw / simonw/llm

Support embeddings that are not stored as 32 bit floats

Open
#1,122 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

design embeddings
Dominant language
Python
Stars
12.5k
Forks
998
Avg merge
3d 13h
Merged PRs (30d)
10

Description

From:

The new Mistral code embedding model has this option:

We also provide output_dtype and output_dimension parameters that allow you to control the type and dimensional size of your embeddings.

The accepted dtypes are:

  • float (default): A list of 32-bit (4-byte) single-precision floating-point numbers. Provides the highest precision and retrieval accuracy.
  • int8: A list of 8-bit (1-byte) integers ranging from -128 to 127.
  • uint8: A list of 8-bit (1-byte) integers ranging from 0 to 255.
  • binary: A list of 8-bit integers that represent bit-packed, quantized single-bit embedding values using the int8 type. The length of the returned list of integers is 1/8 of output_dimension. This type uses the offset binary method.
  • ubinary: Similar to binary, but uses the uint8 type for bit-packed, quantized single-bit embedding values.

LLM currently assumes embeddings are always stored as 33 bit floats. Need to make a change in core to get away from that assumption.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the core embedding storage path and identify where the current 32-bit float assumption is enforced. Define the required behavior for the listed output types and dimensions, then add coverage showing that embeddings using those representations can be stored and retrieved correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.