The data module provides functions to create specialized data types for vectors, sparse vectors, matrices, and typed lists.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/topk-io/topk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
When upserting documents with vector or matrix data, you can use Python’s native types (lists, dicts) or specialized constructors from thedata module for explicit type control.
Classes
List
Represents typed lists and vectors in TopK. Created by vector and list constructor functions.SparseVector
Represents sparse vectors in TopK. Created by sparse vector constructor functions.Matrix
Represents matrices (multi-vector fields) in TopK. Created by thematrix() constructor.
Dense Vectors
f8_vector()
Create an 8-bit float vector.List of float values for the vector.
An 8-bit float vector.
f16_vector()
Create a 16-bit float vector.List of float values for the vector.
A 16-bit float vector.
f32_vector()
Create a 32-bit float vector. This is an alias forf32_list().
List of float values for the vector.
A 32-bit float vector.
u8_vector()
Create an 8-bit unsigned integer vector. This is an alias foru8_list().
List of integer values (0-255) for the vector.
An 8-bit unsigned integer vector.
i8_vector()
Create an 8-bit signed integer vector.List of integer values (-128 to 127) for the vector.
An 8-bit signed integer vector.
binary_vector()
Create a binary vector.List of binary values (0 or 1).
A binary vector.
Sparse Vectors
f32_sparse_vector()
Create a 32-bit float sparse vector.Sparse vectors use u32 dimension indices to support dictionaries of up to 2^32 - 1 terms.
Dictionary mapping dimension indices to float values.
A 32-bit float sparse vector.
u8_sparse_vector()
Create an 8-bit unsigned integer sparse vector.Dictionary mapping dimension indices to integer values (0-255).
An 8-bit unsigned integer sparse vector.
Other Data Types
bytes()
Create a bytes data object.Either a list of byte values (0-255) or a Python bytes object.
A bytes data object.
Typed Lists
u32_list()
Create a list of 32-bit unsigned integers.List of unsigned integer values.
A list of 32-bit unsigned integers.
i32_list()
Create a list of 32-bit signed integers.List of signed integer values.
A list of 32-bit signed integers.
i64_list()
Create a list of 64-bit signed integers.List of signed 64-bit integer values.
A list of 64-bit signed integers.
f32_list()
Create a list of 32-bit floating point numbers.List of float values.
A list of 32-bit floats.
f64_list()
Create a list of 64-bit floating point numbers.List of float values.
A list of 64-bit floats.
string_list()
Create a list of strings.List of string values.
A list of strings.
Matrix
matrix()
Create a matrix (multi-vector field) for use with multi-vector indexes. Thevalues parameter can be:
- List of lists: Defaults to f32, or specify
value_typeexplicitly - Numpy array: Type inferred from array’s dtype (float32, float16, uint8, int8)
The matrix values. Can be a list of lists or a numpy array.
The data type for matrix elements. Required when using list of lists (unless you want default f32). Ignored when using numpy arrays (type inferred from dtype).Options:
"f32"- 32-bit float (default)"f16"- 16-bit float"f8"- 8-bit float"u8"- 8-bit unsigned integer"i8"- 8-bit signed integer
A matrix object.