Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
WEAVIATE_129: 1.29.8
WEAVIATE_130: 1.30.7
WEAVIATE_131: 1.31.0
WEAVIATE_132: 1.32.0-rc.1
WEAVIATE_132: 1.32.4-cdf9a3b

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
4 changes: 4 additions & 0 deletions src/collections/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
QuantizerConfig,
RQConfig,
SQConfig,
UncompressedConfig,
VectorIndexConfig,
VectorIndexConfigDynamic,
VectorIndexConfigFlat,
Expand Down Expand Up @@ -184,6 +185,9 @@ export class VectorIndex {
}

export class Quantizer {
static isUncompressed(config?: QuantizerConfig): config is UncompressedConfig {
return config?.type === 'none';
}
static isPQ(config?: QuantizerConfig): config is PQConfig {
return config?.type === 'pq';
}
Expand Down
6 changes: 5 additions & 1 deletion src/collections/config/types/vectorIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export type RQConfig = {
type: 'rq';
};

export type UncompressedConfig = {
type: 'none';
};

export type MultiVectorConfig = {
aggregation: 'maxSim' | string;
encoding?: MultiVectorEncodingConfig;
Expand Down Expand Up @@ -98,4 +102,4 @@ export type VectorIndexFilterStrategy = 'sweeping' | 'acorn';

export type VectorIndexConfig = VectorIndexConfigHNSW | VectorIndexConfigFlat | VectorIndexConfigDynamic;

export type QuantizerConfig = PQConfig | BQConfig | SQConfig | RQConfig;
export type QuantizerConfig = PQConfig | BQConfig | SQConfig | RQConfig | UncompressedConfig;
7 changes: 7 additions & 0 deletions src/collections/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
VectorizersConfigAdd,
VectorizersConfigCreate,
} from '../configure/types/index.js';
import { Quantizer } from '../index.js';
import {
BQConfig,
CollectionConfig,
Expand Down Expand Up @@ -179,6 +180,12 @@ export const parseVectorIndex = (module: ModuleConfig<VectorIndexType, VectorInd
multivector,
};
if (quantizer === undefined) return conf;
if (Quantizer.isUncompressed(quantizer)) {
return {
...conf,
skipDefaultQuantization: true,
};
}
if (QuantizerGuards.isBQCreate(quantizer)) {
const { type, ...quant } = quantizer;
return {
Expand Down
15 changes: 15 additions & 0 deletions src/collections/configure/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ describe('Unit testing of the configure & reconfigure factory classes', () => {
});
});

it('should create an hnsw VectorIndexConfig type with "none" quantizer', () => {
const config = configure.vectorIndex.hnsw({
quantizer: configure.vectorIndex.quantizer.none(),
});
expect(config).toEqual<ModuleConfig<'hnsw', VectorIndexConfigHNSWCreate>>({
name: 'hnsw',
config: {
quantizer: {
type: 'none',
},
type: 'hnsw',
},
});
});

it('should create an hnsw VectorIndexConfig type with multivector enabled', () => {
const config = configure.vectorIndex.hnsw({
multiVector: configure.vectorIndex.multiVector.multiVector({ aggregation: 'maxSim' }),
Expand Down
9 changes: 9 additions & 0 deletions src/collections/configure/vectorIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ModuleConfig,
PQEncoderDistribution,
PQEncoderType,
UncompressedConfig,
VectorIndexFilterStrategy,
} from '../config/types/index.js';
import {
Expand Down Expand Up @@ -149,6 +150,14 @@ const configure = {
* Define the quantizer configuration to use when creating a vector index.
*/
quantizer: {
/**
* Create an object of type `UncomplressedConfig` to skip default vector quantization.
*
* @returns {BQConfigCreate} The object of type `BQConfigCreate`.
*/
none: (): UncompressedConfig => {
return { type: 'none' };
},
/**
* Create an object of type `BQConfigCreate` to be used when defining the quantizer configuration of a vector index.
*
Expand Down
40 changes: 40 additions & 0 deletions src/collections/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { requireAtLeast } from '../../test/version';
import weaviate, { WeaviateClient } from '../index';
import {
CollectionConfigCreate,
Expand Down Expand Up @@ -656,6 +657,45 @@ describe('Testing of the collections.create method', () => {
).toEqual(true);
});

requireAtLeast(1, 32, 0).describe('uncompressed vectors', () => {
it('should be able to create a collection with uncompressed default vector', async () => {
const collectionName = 'TestCollectionUncompressedVector';

await contextionary.collections.create({
name: collectionName,
vectorizers: weaviate.configure.vectors.text2VecContextionary({
vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({
quantizer: weaviate.configure.vectorIndex.quantizer.none(),
}),
}),
});

const collection = await contextionary.collections.export(collectionName);

expect((collection.vectorizers.default.indexConfig as VectorIndexConfigHNSW).quantizer).toBeUndefined();
});

it('should be able to create a collection with uncompressed named vector', async () => {
const collectionName = 'TestCollectionUncompressedVectorNamed';

await contextionary.collections.create({
name: collectionName,
vectorizers: weaviate.configure.vectors.text2VecContextionary({
name: 'custom_vec',
vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({
quantizer: weaviate.configure.vectorIndex.quantizer.none(),
}),
}),
});

const collection = await contextionary.collections.export(collectionName);

expect(
(collection.vectorizers.custom_vec.indexConfig as VectorIndexConfigHNSW).quantizer
).toBeUndefined();
});
});

it('should be able to create a collection with an openai vectorizer with configure.vectors', async () => {
const collectionName = 'TestCollectionOpenAIVectorizerWithConfigureVectorizer';
const response = await openai.collections
Expand Down
Loading