@lancedb/lancedb 0.13.0-beta.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Schema } from "../arrow";
|
|
2
2
|
import { EmbeddingFunction } from "./embedding_function";
|
|
3
3
|
export { EmbeddingFunction, TextEmbeddingFunction } from "./embedding_function";
|
|
4
|
-
export * from "./openai";
|
|
5
|
-
export * from "./transformers";
|
|
6
4
|
export * from "./registry";
|
|
7
5
|
/**
|
|
8
6
|
* Create a schema with embedding functions.
|
package/dist/embedding/index.js
CHANGED
|
@@ -35,9 +35,6 @@ const registry_1 = require("./registry");
|
|
|
35
35
|
var embedding_function_1 = require("./embedding_function");
|
|
36
36
|
Object.defineProperty(exports, "EmbeddingFunction", { enumerable: true, get: function () { return embedding_function_1.EmbeddingFunction; } });
|
|
37
37
|
Object.defineProperty(exports, "TextEmbeddingFunction", { enumerable: true, get: function () { return embedding_function_1.TextEmbeddingFunction; } });
|
|
38
|
-
// We need to explicitly export '*' so that the `register` decorator actually registers the class.
|
|
39
|
-
__exportStar(require("./openai"), exports);
|
|
40
|
-
__exportStar(require("./transformers"), exports);
|
|
41
38
|
__exportStar(require("./registry"), exports);
|
|
42
39
|
/**
|
|
43
40
|
* Create a schema with embedding functions.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type EmbeddingFunction, type EmbeddingFunctionConstructor } from "./embedding_function";
|
|
2
2
|
import "reflect-metadata";
|
|
3
|
-
import { OpenAIEmbeddingFunction } from "./openai";
|
|
4
|
-
import { TransformersEmbeddingFunction } from "./transformers";
|
|
5
3
|
type CreateReturnType<T> = T extends {
|
|
6
4
|
init: () => Promise<void>;
|
|
7
5
|
} ? Promise<T> : T;
|
|
@@ -27,8 +25,6 @@ export declare class EmbeddingFunctionRegistry {
|
|
|
27
25
|
* @throws Error if the function is already registered
|
|
28
26
|
*/
|
|
29
27
|
register<T extends EmbeddingFunctionConstructor = EmbeddingFunctionConstructor>(this: EmbeddingFunctionRegistry, alias?: string): (ctor: T) => any;
|
|
30
|
-
get(name: "openai"): EmbeddingFunctionCreate<OpenAIEmbeddingFunction>;
|
|
31
|
-
get(name: "huggingface"): EmbeddingFunctionCreate<TransformersEmbeddingFunction>;
|
|
32
28
|
get<T extends EmbeddingFunction<unknown>>(name: string): EmbeddingFunctionCreate<T> | undefined;
|
|
33
29
|
/**
|
|
34
30
|
* reset the registry to the initial state
|
|
@@ -66,17 +66,17 @@ let TransformersEmbeddingFunction = class TransformersEmbeddingFunction extends
|
|
|
66
66
|
try {
|
|
67
67
|
// SAFETY:
|
|
68
68
|
// since typescript transpiles `import` to `require`, we need to do this in an unsafe way
|
|
69
|
-
// We can't use `require` because `@
|
|
69
|
+
// We can't use `require` because `@huggingface/transformers` is an ESM module
|
|
70
70
|
// and we can't use `import` directly because typescript will transpile it to `require`.
|
|
71
71
|
// and we want to remain compatible with both ESM and CJS modules
|
|
72
72
|
// so we use `eval` to bypass typescript for this specific import.
|
|
73
|
-
transformers = await eval('import("@
|
|
73
|
+
transformers = await eval('import("@huggingface/transformers")');
|
|
74
74
|
}
|
|
75
75
|
catch (e) {
|
|
76
|
-
throw new Error(`error loading @
|
|
76
|
+
throw new Error(`error loading @huggingface/transformers\nReason: ${e}`);
|
|
77
77
|
}
|
|
78
78
|
try {
|
|
79
|
-
this.#model = await transformers.AutoModel.from_pretrained(this.#modelName);
|
|
79
|
+
this.#model = await transformers.AutoModel.from_pretrained(this.#modelName, { dtype: "fp32" });
|
|
80
80
|
}
|
|
81
81
|
catch (e) {
|
|
82
82
|
throw new Error(`error loading model ${this.#modelName}. Make sure you are using a wasm compatible model.\nReason: ${e}`);
|
|
@@ -95,7 +95,8 @@ let TransformersEmbeddingFunction = class TransformersEmbeddingFunction extends
|
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
97
|
const config = this.#model.config;
|
|
98
|
-
|
|
98
|
+
// biome-ignore lint/style/useNamingConvention: we don't control this name.
|
|
99
|
+
const ndims = config.hidden_size;
|
|
99
100
|
if (!ndims) {
|
|
100
101
|
throw new Error("hidden_size not found in model config, you may need to manually specify the embedding dimensions. ");
|
|
101
102
|
}
|
package/dist/native.d.ts
CHANGED
package/dist/query.d.ts
CHANGED
|
@@ -267,6 +267,7 @@ export declare class VectorQuery extends QueryBase<NativeVectorQuery> {
|
|
|
267
267
|
* calculate your recall to select an appropriate value for nprobes.
|
|
268
268
|
*/
|
|
269
269
|
bypassVectorIndex(): VectorQuery;
|
|
270
|
+
addQueryVector(vector: IntoVector): VectorQuery;
|
|
270
271
|
}
|
|
271
272
|
/** A builder for LanceDB queries. */
|
|
272
273
|
export declare class Query extends QueryBase<NativeQuery> {
|
|
@@ -309,4 +310,5 @@ export declare class Query extends QueryBase<NativeQuery> {
|
|
|
309
310
|
* a default `limit` of 10 will be used. @see {@link Query#limit}
|
|
310
311
|
*/
|
|
311
312
|
nearestTo(vector: IntoVector): VectorQuery;
|
|
313
|
+
nearestToText(query: string, columns?: string[]): Query;
|
|
312
314
|
}
|
package/dist/query.js
CHANGED
|
@@ -409,6 +409,41 @@ class VectorQuery extends QueryBase {
|
|
|
409
409
|
super.doCall((inner) => inner.bypassVectorIndex());
|
|
410
410
|
return this;
|
|
411
411
|
}
|
|
412
|
+
/*
|
|
413
|
+
* Add a query vector to the search
|
|
414
|
+
*
|
|
415
|
+
* This method can be called multiple times to add multiple query vectors
|
|
416
|
+
* to the search. If multiple query vectors are added, then they will be searched
|
|
417
|
+
* in parallel, and the results will be concatenated. A column called `query_index`
|
|
418
|
+
* will be added to indicate the index of the query vector that produced the result.
|
|
419
|
+
*
|
|
420
|
+
* Performance wise, this is equivalent to running multiple queries concurrently.
|
|
421
|
+
*/
|
|
422
|
+
addQueryVector(vector) {
|
|
423
|
+
if (vector instanceof Promise) {
|
|
424
|
+
const res = (async () => {
|
|
425
|
+
try {
|
|
426
|
+
const v = await vector;
|
|
427
|
+
const arr = Float32Array.from(v);
|
|
428
|
+
//
|
|
429
|
+
// biome-ignore lint/suspicious/noExplicitAny: we need to get the `inner`, but js has no package scoping
|
|
430
|
+
const value = this.addQueryVector(arr);
|
|
431
|
+
const inner = value.inner;
|
|
432
|
+
return inner;
|
|
433
|
+
}
|
|
434
|
+
catch (e) {
|
|
435
|
+
return Promise.reject(e);
|
|
436
|
+
}
|
|
437
|
+
})();
|
|
438
|
+
return new VectorQuery(res);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
super.doCall((inner) => {
|
|
442
|
+
inner.addQueryVector(Float32Array.from(vector));
|
|
443
|
+
});
|
|
444
|
+
return this;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
412
447
|
}
|
|
413
448
|
exports.VectorQuery = VectorQuery;
|
|
414
449
|
/** A builder for LanceDB queries. */
|
|
@@ -488,5 +523,9 @@ class Query extends QueryBase {
|
|
|
488
523
|
return new VectorQuery(vectorQuery);
|
|
489
524
|
}
|
|
490
525
|
}
|
|
526
|
+
nearestToText(query, columns) {
|
|
527
|
+
this.doCall((inner) => inner.fullTextSearch(query, columns));
|
|
528
|
+
return this;
|
|
529
|
+
}
|
|
491
530
|
}
|
|
492
531
|
exports.Query = Query;
|
package/package.json
CHANGED
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"vector database",
|
|
11
11
|
"ann"
|
|
12
12
|
],
|
|
13
|
-
"version": "0.13.0
|
|
13
|
+
"version": "0.13.0",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": "./dist/index.js",
|
|
17
|
-
"./embedding": "./dist/embedding/index.js"
|
|
17
|
+
"./embedding": "./dist/embedding/index.js",
|
|
18
|
+
"./embedding/openai": "./dist/embedding/openai.js",
|
|
19
|
+
"./embedding/transformers": "./dist/embedding/transformers.js"
|
|
18
20
|
},
|
|
19
21
|
"types": "dist/index.d.ts",
|
|
20
22
|
"napi": {
|
|
@@ -92,11 +94,11 @@
|
|
|
92
94
|
"reflect-metadata": "^0.2.2"
|
|
93
95
|
},
|
|
94
96
|
"optionalDependencies": {
|
|
95
|
-
"@lancedb/lancedb-darwin-arm64": "0.13.0
|
|
96
|
-
"@lancedb/lancedb-linux-arm64-gnu": "0.13.0
|
|
97
|
-
"@lancedb/lancedb-darwin-x64": "0.13.0
|
|
98
|
-
"@lancedb/lancedb-linux-x64-gnu": "0.13.0
|
|
99
|
-
"@lancedb/lancedb-win32-x64-msvc": "0.13.0
|
|
97
|
+
"@lancedb/lancedb-darwin-arm64": "0.13.0",
|
|
98
|
+
"@lancedb/lancedb-linux-arm64-gnu": "0.13.0",
|
|
99
|
+
"@lancedb/lancedb-darwin-x64": "0.13.0",
|
|
100
|
+
"@lancedb/lancedb-linux-x64-gnu": "0.13.0",
|
|
101
|
+
"@lancedb/lancedb-win32-x64-msvc": "0.13.0"
|
|
100
102
|
},
|
|
101
103
|
"peerDependencies": {
|
|
102
104
|
"apache-arrow": ">=13.0.0 <=17.0.0"
|