Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/collections/config/types/vectorIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ export type PQConfig = {

export type RQConfig = {
bits?: number;
/** Whether to center vectors before rotation (centered RQ4). Requires Weaviate 1.39.2+. */
centering?: boolean;
rescoreLimit?: number;
trainingLimit?: number;
type: 'rq';
};

Expand Down
3 changes: 3 additions & 0 deletions src/collections/configure/types/vectorIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export type RQConfigCreate = QuantizerRecursivePartial<RQConfig>;

export type RQConfigUpdate = {
bit?: number;
/** Whether to center vectors before rotation (centered RQ4). Requires Weaviate 1.39.2+. */
centering?: boolean;
rescoreLimit?: number;
trainingLimit?: number;
type: 'rq';
};

Expand Down
30 changes: 30 additions & 0 deletions src/collections/configure/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,36 @@ describe('Unit testing of the configure & reconfigure factory classes', () => {
});
});

it('should create the correct RQConfigCreate type with all values including centering', () => {
const quantizer = configure.vectorIndex.quantizer.rq({
bits: 4,
centering: true,
rescoreLimit: 500,
trainingLimit: 1000,
});
expect(quantizer).toEqual({
bits: 4,
centering: true,
rescoreLimit: 500,
trainingLimit: 1000,
type: 'rq',
});
});

it('should create the correct RQConfigUpdate type with all values including centering', () => {
const quantizer = reconfigure.vectorIndex.quantizer.rq({
centering: false,
rescoreLimit: 750,
trainingLimit: 2000,
});
expect(quantizer).toEqual({
centering: false,
rescoreLimit: 750,
trainingLimit: 2000,
type: 'rq',
});
});

it('should create the correct hfresh VectorIndexConfig type with defaults', () => {
const config = configure.vectorIndex.hfresh({ quantizer: configure.vectorIndex.quantizer.rq() });
expect(config).toEqual<ModuleConfig<'hfresh', VectorIndexConfigHFreshCreate | undefined>>({
Expand Down
19 changes: 17 additions & 2 deletions src/collections/configure/vectorIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,22 @@ const configure = {
* Create an object of type `RQConfigCreate` to be used when defining the quantizer configuration of a vector index.
*
* @param {number} [options.bits] Number of bits to user per vector element.
* @param {boolean} [options.centering] Whether to center vectors before rotation (centered RQ4). Requires Weaviate 1.39.2+.
* @param {number} [options.rescoreLimit] The rescore limit. Default is 1000.
* @param {number} [options.trainingLimit] The training limit.
* @returns {RQConfigCreate} The object of type `RQConfigCreate`.
*/
rq: (options?: { bits?: number; rescoreLimit?: number }): RQConfigCreate => {
rq: (options?: {
bits?: number;
centering?: boolean;
rescoreLimit?: number;
trainingLimit?: number;
}): RQConfigCreate => {
return {
bits: options?.bits,
centering: options?.centering,
rescoreLimit: options?.rescoreLimit,
trainingLimit: options?.trainingLimit,
type: 'rq',
};
},
Expand Down Expand Up @@ -374,10 +383,16 @@ const reconfigure = {
* NOTE: If the vector index already has a quantizer configured, you cannot change its quantizer type; only its values.
* So if you want to change the quantizer type, you must recreate the collection.
*
* @param {boolean} [options.centering] Whether to center vectors before rotation (centered RQ4). Requires Weaviate 1.39.2+.
* @param {number} [options.rescoreLimit] The new rescore limit.
* @param {number} [options.trainingLimit] The new training limit.
* @returns {RQConfigUpdate} The configuration object.
*/
rq: (options?: { rescoreLimit?: number }): RQConfigUpdate => {
rq: (options?: {
centering?: boolean;
rescoreLimit?: number;
trainingLimit?: number;
}): RQConfigUpdate => {
return {
...options,
type: 'rq',
Expand Down