@lancedb/lancedb β’ Docs
@lancedb/lancedb / embedding / TextEmbeddingFunction
Class: abstract
TextEmbeddingFunction<M>
an abstract class for implementing embedding functions that take text as input
Extends
EmbeddingFunction
<string
,M
>
Type Parameters
β’ M extends FunctionOptions
= FunctionOptions
Constructors
new TextEmbeddingFunction()
Returns
Inherited from
Methods
computeQueryEmbeddings()
Compute the embeddings for a single query
Parameters
- data:
string
Returns
Promise
<number
[] | Float32Array
| Float64Array
>
Overrides
EmbeddingFunction
.computeQueryEmbeddings
computeSourceEmbeddings()
Creates a vector representation for the given values.
Parameters
- data:
string
[]
Returns
Promise
<number
[][] | Float32Array
[] | Float64Array
[]>
Overrides
EmbeddingFunction
.computeSourceEmbeddings
embeddingDataType()
The datatype of the embeddings
Returns
Float
<Floats
>
Overrides
EmbeddingFunction
.embeddingDataType
generateEmbeddings()
Parameters
-
texts:
string
[] -
...args:
any
[]
Returns
Promise
<number
[][] | Float32Array
[] | Float64Array
[]>
init()?
Returns
Promise
<void
>
Inherited from
ndims()
The number of dimensions of the embeddings
Returns
undefined
| number
Inherited from
sourceField()
sourceField is used in combination with LanceSchema
to provide a declarative data model
Returns
[DataType
<Type
, any
>, Map
<string
, EmbeddingFunction
<any
, FunctionOptions
>>]
See
lancedb.LanceSchema
Overrides
toJSON()
Convert the embedding function to a JSON object It is used to serialize the embedding function to the schema It's important that any object returned by this method contains all the necessary information to recreate the embedding function
It should return the same object that was passed to the constructor If it does not, the embedding function will not be able to be recreated, or could be recreated incorrectly
Returns
Partial
<M
>
Example
class MyEmbeddingFunction extends EmbeddingFunction {
constructor(options: {model: string, timeout: number}) {
super();
this.model = options.model;
this.timeout = options.timeout;
}
toJSON() {
return {
model: this.model,
timeout: this.timeout,
};
}
Inherited from
vectorField()
vectorField(optionsOrDatatype?): [DataType<Type, any>, Map<string, EmbeddingFunction<any, FunctionOptions>>]
vectorField is used in combination with LanceSchema
to provide a declarative data model
Parameters
- optionsOrDatatype?:
DataType
<Type
,any
> |Partial
<FieldOptions
<DataType
<Type
,any
>>>
Returns
[DataType
<Type
, any
>, Map
<string
, EmbeddingFunction
<any
, FunctionOptions
>>]
See
lancedb.LanceSchema