Skip to main content

Class: EmbeddingSimilarityClassifier<VALUE, CLUSTERS>

Classifies values based on their distance to the values from a set of clusters. When the distance is below a certain threshold, the value is classified as belonging to the cluster, and the cluster name is returned. Otherwise, the value is classified as null.

Type parameters

NameType
VALUEVALUE
CLUSTERSextends ValueCluster<VALUE, string>[]

Implements

Accessors

settingsForEvent

get settingsForEvent(): Partial<EmbeddingSimilarityClassifierSettings<VALUE, CLUSTERS>>

Returns settings that should be recorded in observability events. Security-related settings (e.g. API keys) should not be included here.

Returns

Partial<EmbeddingSimilarityClassifierSettings<VALUE, CLUSTERS>>

Implementation of

Classifier.settingsForEvent

Defined in

packages/modelfusion/src/model-function/classify/EmbeddingSimilarityClassifier.ts:129

Constructors

constructor

new EmbeddingSimilarityClassifier<VALUE, CLUSTERS>(settings): EmbeddingSimilarityClassifier<VALUE, CLUSTERS>

Type parameters

NameType
VALUEVALUE
CLUSTERSextends ValueCluster<VALUE, string>[]

Parameters

NameType
settingsEmbeddingSimilarityClassifierSettings<VALUE, CLUSTERS>

Returns

EmbeddingSimilarityClassifier<VALUE, CLUSTERS>

Defined in

packages/modelfusion/src/model-function/classify/EmbeddingSimilarityClassifier.ts:52

Methods

doClassify

doClassify(value, options): Promise<{ class: null | ClusterNames<CLUSTERS> ; rawResponse: undefined = undefined }>

Parameters

NameType
valueVALUE
optionsFunctionCallOptions

Returns

Promise<{ class: null | ClusterNames<CLUSTERS> ; rawResponse: undefined = undefined }>

Implementation of

Classifier.doClassify

Defined in

packages/modelfusion/src/model-function/classify/EmbeddingSimilarityClassifier.ts:90


getEmbeddings

getEmbeddings(options): Promise<{ clusterName: string ; clusterValue: VALUE ; embedding: Vector }[]>

Parameters

NameType
optionsFunctionCallOptions

Returns

Promise<{ clusterName: string ; clusterValue: VALUE ; embedding: Vector }[]>

Defined in

packages/modelfusion/src/model-function/classify/EmbeddingSimilarityClassifier.ts:58


withSettings

withSettings(additionalSettings): EmbeddingSimilarityClassifier<VALUE, CLUSTERS>

The withSettings method creates a new model with the same configuration as the original model, but with the specified settings changed.

Parameters

NameType
additionalSettingsPartial<EmbeddingSimilarityClassifierSettings<VALUE, CLUSTERS>>

Returns

EmbeddingSimilarityClassifier<VALUE, CLUSTERS>

Example

const model = new OpenAICompletionModel({
model: "gpt-3.5-turbo-instruct",
maxGenerationTokens: 500,
});

const modelWithMoreTokens = model.withSettings({
maxGenerationTokens: 1000,
});

Implementation of

Classifier.withSettings

Defined in

packages/modelfusion/src/model-function/classify/EmbeddingSimilarityClassifier.ts:148

Properties

modelInformation

Readonly modelInformation: Object

Type declaration

NameType
modelNamestring
providerstring

Implementation of

Classifier.modelInformation

Defined in

packages/modelfusion/src/model-function/classify/EmbeddingSimilarityClassifier.ts:39


settings

Readonly settings: EmbeddingSimilarityClassifierSettings<VALUE, CLUSTERS>

Implementation of

Classifier.settings

Defined in

packages/modelfusion/src/model-function/classify/EmbeddingSimilarityClassifier.ts:37