* Make `npm run docs` fail if there are any warnings. This will catch items missing from the API reference. * Add a check in our CI to make sure `npm run dos` runs without warnings and doesn't generate any new files (indicating it might be out-of-date. * Hide constructors that aren't user facing. * Remove unused enum `WriteMode`. Closes #2068
4.9 KiB
@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()
new TextEmbeddingFunction<M>(): TextEmbeddingFunction<M>
Returns
Inherited from
Methods
computeQueryEmbeddings()
computeQueryEmbeddings(data): Promise<number[] | Float32Array | Float64Array>
Compute the embeddings for a single query
Parameters
- data:
string
Returns
Promise<number[] | Float32Array | Float64Array>
Overrides
EmbeddingFunction.computeQueryEmbeddings
computeSourceEmbeddings()
computeSourceEmbeddings(data): Promise<number[][] | Float32Array[] | Float64Array[]>
Creates a vector representation for the given values.
Parameters
- data:
string[]
Returns
Promise<number[][] | Float32Array[] | Float64Array[]>
Overrides
EmbeddingFunction.computeSourceEmbeddings
embeddingDataType()
embeddingDataType(): Float<Floats>
The datatype of the embeddings
Returns
Float<Floats>
Overrides
EmbeddingFunction.embeddingDataType
generateEmbeddings()
abstract generateEmbeddings(texts, ...args): Promise<number[][] | Float32Array[] | Float64Array[]>
Parameters
-
texts:
string[] -
...args:
any[]
Returns
Promise<number[][] | Float32Array[] | Float64Array[]>
init()?
optional init(): Promise<void>
Returns
Promise<void>
Inherited from
ndims()
ndims(): undefined | number
The number of dimensions of the embeddings
Returns
undefined | number
Inherited from
sourceField()
sourceField(): [DataType<Type, any>, Map<string, EmbeddingFunction<any, FunctionOptions>>]
sourceField is used in combination with LanceSchema to provide a declarative data model
Returns
[DataType<Type, any>, Map<string, EmbeddingFunction<any, FunctionOptions>>]
See
Overrides
toJSON()
abstract toJSON(): Partial<M>
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>>> The options for the field
Returns
[DataType<Type, any>, Map<string, EmbeddingFunction<any, FunctionOptions>>]