Class LateInteractionField

All Implemented Interfaces:
IndexableField

public class LateInteractionField extends BinaryDocValuesField
A field for storing multi-vector values for late interaction models.

The value is stored as a binary payload, and can be retrieved using decode(BytesRef). Multi-vectors are expected to have the same dimension for each composing token vector. This is stored along with the token vectors in the first 4 bytes of the payload.

Note: This field does not ensure consistency in token vector dimensions for values across documents.

  • Constructor Details

    • LateInteractionField

      public LateInteractionField(String name, float[][] value)
      Creates a new LateInteractionField from the provided multi-vector matrix.
      Parameters:
      name - field name
      value - multi-vector value
  • Method Details

    • setValue

      public void setValue(float[][] value)
      Set multi-vector value for the field.

      Value should not be null or empty. Composing token vectors for provided multi-vector value should have the same dimension.

    • getValue

      public float[][] getValue()
      Returns the multi-vector value stored in this field
    • encode

      public static BytesRef encode(float[][] value)
      Encodes provided multi-vector matrix into a BytesRef that can be stored in the LateInteractionField.

      Composing token vectors for the multi-vector are expected to have the same dimension, which is stored along with the token vectors in the first 4 bytes of the payload. Use decode(BytesRef) to retrieve the multi-vector.

      Parameters:
      value - Multi-Vector to encode
      Returns:
      BytesRef representation for provided multi-vector
    • decode

      public static float[][] decode(BytesRef payload)
      Decodes provided BytesRef into a multi-vector matrix.

      The token vectors are expected to have the same dimension, which is stored along with the token vectors in the first 4 bytes of the payload. Meant to be used as a counterpart to encode(float[][])

      Parameters:
      payload - to decode into multi-vector value
      Returns:
      decoded multi-vector value