@workglow/huggingface-transformers 0.2.35 → 0.2.36
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.
- package/dist/ai/common/HFT_Capabilities.d.ts +1 -1
- package/dist/ai/common/HFT_CapabilitySets.d.ts +2 -1
- package/dist/ai/common/HFT_CapabilitySets.d.ts.map +1 -1
- package/dist/ai/common/HFT_JobRunFns.d.ts.map +1 -1
- package/dist/ai/common/HFT_TextReranker.d.ts +42 -0
- package/dist/ai/common/HFT_TextReranker.d.ts.map +1 -0
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/runtime.d.ts +1 -0
- package/dist/ai/runtime.d.ts.map +1 -1
- package/dist/ai-runtime.js +62 -9
- package/dist/ai-runtime.js.map +6 -5
- package/dist/ai.js +52 -1
- package/dist/ai.js.map +6 -5
- package/package.json +11 -11
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Capability, ModelRecord } from "@workglow/ai/worker";
|
|
7
7
|
export declare const HFT_RUN_FN_SPECS: {
|
|
8
|
-
serves: ["image.background-removal"] | ["image.classification"] | ["image.embedding"] | ["image.object-detection"] | ["image.segmentation"] | ["image.to-text"] | ["model.count-tokens"] | ["model.download"] | ["model.download-remove"] | ["model.info"] | ["model.search"] | ["text.classification"] | ["text.embedding"] | ["text.fill-mask"] | ["text.generation"] | ["text.language-detection"] | ["text.ner"] | ["text.question-answering"] | ["text.rewriter"] | ["text.summary"] | ["text.translation"] | ["text.generation", "json-mode"] | ["text.generation", "tool-use"];
|
|
8
|
+
serves: ["image.background-removal"] | ["image.classification"] | ["image.embedding"] | ["image.object-detection"] | ["image.segmentation"] | ["image.to-text"] | ["model.count-tokens"] | ["model.download"] | ["model.download-remove"] | ["model.info"] | ["model.search"] | ["text.classification"] | ["text.embedding"] | ["text.fill-mask"] | ["text.generation"] | ["text.language-detection"] | ["text.ner"] | ["text.question-answering"] | ["text.reranking"] | ["text.rewriter"] | ["text.summary"] | ["text.translation"] | ["text.generation", "json-mode"] | ["text.generation", "tool-use"];
|
|
9
9
|
}[];
|
|
10
10
|
export declare function hftWorkerRunFnSpecs(): readonly {
|
|
11
11
|
readonly serves: readonly Capability[];
|
|
@@ -21,6 +21,7 @@ export declare const HFT_TEXT_QUESTION_ANSWERING: ["text.question-answering"];
|
|
|
21
21
|
export declare const HFT_TEXT_EMBEDDING: ["text.embedding"];
|
|
22
22
|
export declare const HFT_TEXT_CLASSIFICATION: ["text.classification"];
|
|
23
23
|
export declare const HFT_TEXT_LANGUAGE_DETECTION: ["text.language-detection"];
|
|
24
|
+
export declare const HFT_TEXT_RERANKING: ["text.reranking"];
|
|
24
25
|
export declare const HFT_TEXT_FILL_MASK: ["text.fill-mask"];
|
|
25
26
|
export declare const HFT_TEXT_NER: ["text.ner"];
|
|
26
27
|
export declare const HFT_IMAGE_CLASSIFICATION: ["image.classification"];
|
|
@@ -35,5 +36,5 @@ export declare const HFT_MODEL_DOWNLOAD: ["model.download"];
|
|
|
35
36
|
export declare const HFT_MODEL_SEARCH: ["model.search"];
|
|
36
37
|
export declare const HFT_MODEL_INFO: ["model.info"];
|
|
37
38
|
/** Aggregated list — for `workerRunFnSpecs()` derivation. Order MUST match `HFT_RUN_FNS`. */
|
|
38
|
-
export declare const HFT_CAPABILITY_SETS: readonly [["text.generation"], ["text.generation", "tool-use"], ["text.generation", "json-mode"], ["text.rewriter"], ["text.summary"], ["text.translation"], ["text.question-answering"], ["text.embedding"], ["text.classification"], ["text.language-detection"], ["text.fill-mask"], ["text.ner"], ["image.classification"], ["image.embedding"], ["image.segmentation"], ["image.to-text"], ["image.background-removal"], ["image.object-detection"], ["model.count-tokens"], ["model.download-remove"], ["model.download"], ["model.search"], ["model.info"]];
|
|
39
|
+
export declare const HFT_CAPABILITY_SETS: readonly [["text.generation"], ["text.generation", "tool-use"], ["text.generation", "json-mode"], ["text.rewriter"], ["text.summary"], ["text.translation"], ["text.question-answering"], ["text.embedding"], ["text.classification"], ["text.language-detection"], ["text.reranking"], ["text.fill-mask"], ["text.ner"], ["image.classification"], ["image.embedding"], ["image.segmentation"], ["image.to-text"], ["image.background-removal"], ["image.object-detection"], ["model.count-tokens"], ["model.download-remove"], ["model.download"], ["model.search"], ["model.info"]];
|
|
39
40
|
//# sourceMappingURL=HFT_CapabilitySets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFT_CapabilitySets.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_CapabilitySets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,qBAAsD,CAAC;AACvF,eAAO,MAAM,YAAY,iCAAkE,CAAC;AAC5F,eAAO,MAAM,aAAa,kCAAmE,CAAC;AAC9F,eAAO,MAAM,iBAAiB,mBAAoD,CAAC;AACnF,eAAO,MAAM,gBAAgB,kBAAmD,CAAC;AACjF,eAAO,MAAM,oBAAoB,sBAAuD,CAAC;AACzF,eAAO,MAAM,2BAA2B,6BAEP,CAAC;AAClC,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,uBAAuB,yBAA0D,CAAC;AAC/F,eAAO,MAAM,2BAA2B,6BAEP,CAAC;AAClC,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,YAAY,cAA+C,CAAC;AACzE,eAAO,MAAM,wBAAwB,0BAA2D,CAAC;AACjG,eAAO,MAAM,mBAAmB,qBAAsD,CAAC;AACvF,eAAO,MAAM,sBAAsB,wBAAyD,CAAC;AAC7F,eAAO,MAAM,iBAAiB,mBAAoD,CAAC;AACnF,eAAO,MAAM,4BAA4B,8BAER,CAAC;AAClC,eAAO,MAAM,0BAA0B,4BAEN,CAAC;AAClC,eAAO,MAAM,gBAAgB,wBAAyD,CAAC;AACvF,eAAO,MAAM,yBAAyB,2BAA4D,CAAC;AACnG,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,gBAAgB,kBAAmD,CAAC;AACjF,eAAO,MAAM,cAAc,gBAAiD,CAAC;AAE7E,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"HFT_CapabilitySets.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_CapabilitySets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,qBAAsD,CAAC;AACvF,eAAO,MAAM,YAAY,iCAAkE,CAAC;AAC5F,eAAO,MAAM,aAAa,kCAAmE,CAAC;AAC9F,eAAO,MAAM,iBAAiB,mBAAoD,CAAC;AACnF,eAAO,MAAM,gBAAgB,kBAAmD,CAAC;AACjF,eAAO,MAAM,oBAAoB,sBAAuD,CAAC;AACzF,eAAO,MAAM,2BAA2B,6BAEP,CAAC;AAClC,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,uBAAuB,yBAA0D,CAAC;AAC/F,eAAO,MAAM,2BAA2B,6BAEP,CAAC;AAClC,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,YAAY,cAA+C,CAAC;AACzE,eAAO,MAAM,wBAAwB,0BAA2D,CAAC;AACjG,eAAO,MAAM,mBAAmB,qBAAsD,CAAC;AACvF,eAAO,MAAM,sBAAsB,wBAAyD,CAAC;AAC7F,eAAO,MAAM,iBAAiB,mBAAoD,CAAC;AACnF,eAAO,MAAM,4BAA4B,8BAER,CAAC;AAClC,eAAO,MAAM,0BAA0B,4BAEN,CAAC;AAClC,eAAO,MAAM,gBAAgB,wBAAyD,CAAC;AACvF,eAAO,MAAM,yBAAyB,2BAA4D,CAAC;AACnG,eAAO,MAAM,kBAAkB,oBAAqD,CAAC;AACrF,eAAO,MAAM,gBAAgB,kBAAmD,CAAC;AACjF,eAAO,MAAM,cAAc,gBAAiD,CAAC;AAE7E,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,wjBAyBtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HFT_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,sBAAsB,EAEtB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"HFT_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,sBAAsB,EAEtB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AA2BtB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAkDvE;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,2BAA2B,CAE5D,GAAG,EAEH,GAAG,EACH,6BAA6B,CAC9B,EAyBA,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,MAAM,EAEN,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,6BAA6B,CAAC,CAGhE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderRunFn, TextRerankerTaskInput, TextRerankerTaskOutput } from "@workglow/ai";
|
|
7
|
+
import type { HfTransformersOnnxModelConfig } from "./HFT_ModelSchema";
|
|
8
|
+
/**
|
|
9
|
+
* Validate a transformers.js text-classification pipeline output and
|
|
10
|
+
* extract per-document scores. Each entry must be either a `{ score }`
|
|
11
|
+
* object or a non-empty array of such objects (transformers.js returns
|
|
12
|
+
* the array form when `top_k > 1`).
|
|
13
|
+
*
|
|
14
|
+
* Exported so the shape contract can be exercised in tests directly,
|
|
15
|
+
* without needing to spin up a real pipeline or mock the loader. Throws
|
|
16
|
+
* {@link KbRerankerOutputError} on mismatch — silently coercing to 0
|
|
17
|
+
* would hide real model config bugs.
|
|
18
|
+
*
|
|
19
|
+
* @param rawResults Whatever the pipeline call returned. Typed as
|
|
20
|
+
* `unknown` so the caller is forced through this validation.
|
|
21
|
+
* @param modelPath Used in the error message to point operators at the
|
|
22
|
+
* misconfigured model.
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateAndExtractRerankerScores(rawResults: unknown, modelPath: string | undefined): number[];
|
|
25
|
+
/**
|
|
26
|
+
* Cross-encoder reranker run-fn. Loads a `text-classification` pipeline
|
|
27
|
+
* (the way transformers.js exposes cross-encoder models like
|
|
28
|
+
* `Xenova/bge-reranker-base`) and scores each `[query, doc]` pair.
|
|
29
|
+
*
|
|
30
|
+
* Output `indices` is sorted best-first; `scores` is the per-document score
|
|
31
|
+
* in the original input order so callers can join back to their candidate
|
|
32
|
+
* list without re-sorting.
|
|
33
|
+
*
|
|
34
|
+
* Each pipeline result entry is validated at runtime via
|
|
35
|
+
* {@link validateAndExtractRerankerScores}: either a `{ score }` object or
|
|
36
|
+
* a non-empty array of such objects. On mismatch we throw
|
|
37
|
+
* {@link KbRerankerOutputError} with the model path and a truncated shape
|
|
38
|
+
* snippet — silently coercing missing scores to 0 would hide real model
|
|
39
|
+
* config bugs.
|
|
40
|
+
*/
|
|
41
|
+
export declare const HFT_TextReranker: AiProviderRunFn<TextRerankerTaskInput, TextRerankerTaskOutput, HfTransformersOnnxModelConfig>;
|
|
42
|
+
//# sourceMappingURL=HFT_TextReranker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HFT_TextReranker.d.ts","sourceRoot":"","sources":["../../../src/ai/common/HFT_TextReranker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAGnG,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AA8BvE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,OAAO,EACnB,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,MAAM,EAAE,CAqBV;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAC5C,qBAAqB,EACrB,sBAAsB,EACtB,6BAA6B,CAsC9B,CAAC"}
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export * from "./registerHuggingFaceTransformers";
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const _testOnly: {
|
|
17
17
|
readonly HFT_RUN_FN_SPECS: {
|
|
18
|
-
serves: ["image.background-removal"] | ["image.classification"] | ["image.embedding"] | ["image.object-detection"] | ["image.segmentation"] | ["image.to-text"] | ["model.count-tokens"] | ["model.download"] | ["model.download-remove"] | ["model.info"] | ["model.search"] | ["text.classification"] | ["text.embedding"] | ["text.fill-mask"] | ["text.generation"] | ["text.language-detection"] | ["text.ner"] | ["text.question-answering"] | ["text.rewriter"] | ["text.summary"] | ["text.translation"] | ["text.generation", "json-mode"] | ["text.generation", "tool-use"];
|
|
18
|
+
serves: ["image.background-removal"] | ["image.classification"] | ["image.embedding"] | ["image.object-detection"] | ["image.segmentation"] | ["image.to-text"] | ["model.count-tokens"] | ["model.download"] | ["model.download-remove"] | ["model.info"] | ["model.search"] | ["text.classification"] | ["text.embedding"] | ["text.fill-mask"] | ["text.generation"] | ["text.language-detection"] | ["text.ner"] | ["text.question-answering"] | ["text.reranking"] | ["text.rewriter"] | ["text.summary"] | ["text.translation"] | ["text.generation", "json-mode"] | ["text.generation", "tool-use"];
|
|
19
19
|
}[];
|
|
20
20
|
readonly HFT_RUN_FNS: readonly import("@workglow/ai").AiProviderRunFnRegistration<any, any, {
|
|
21
21
|
capabilities?: string[] | undefined;
|
package/dist/ai/runtime.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./common/HFT_Constants";
|
|
|
15
15
|
export * from "./common/HFT_ModelSchema";
|
|
16
16
|
export * from "./common/HFT_OnnxDtypes";
|
|
17
17
|
export * from "./common/HFT_Pipeline";
|
|
18
|
+
export * from "./common/HFT_TextReranker";
|
|
18
19
|
export * from "./common/HFT_ToolMarkup";
|
|
19
20
|
export * from "./registerHuggingFaceTransformersInline";
|
|
20
21
|
export * from "./registerHuggingFaceTransformersWorker";
|
package/dist/ai/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/ai/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAIH,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/ai/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAIH,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC"}
|
package/dist/ai-runtime.js
CHANGED
|
@@ -656,6 +656,54 @@ function parseOnnxQuantizations(params) {
|
|
|
656
656
|
});
|
|
657
657
|
}
|
|
658
658
|
|
|
659
|
+
// src/ai/common/HFT_TextReranker.ts
|
|
660
|
+
init_HFT_Pipeline();
|
|
661
|
+
import { KbRerankerOutputError } from "@workglow/ai";
|
|
662
|
+
import { getLogger as getLogger2 } from "@workglow/util/worker";
|
|
663
|
+
function isScored(v) {
|
|
664
|
+
return typeof v === "object" && v !== null && typeof v.score === "number";
|
|
665
|
+
}
|
|
666
|
+
function truncateShape(value) {
|
|
667
|
+
try {
|
|
668
|
+
const json = JSON.stringify(value);
|
|
669
|
+
if (typeof json !== "string")
|
|
670
|
+
return String(value);
|
|
671
|
+
return json.length > 200 ? `${json.slice(0, 200)}…` : json;
|
|
672
|
+
} catch {
|
|
673
|
+
return String(value);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
function validateAndExtractRerankerScores(rawResults, modelPath) {
|
|
677
|
+
if (!Array.isArray(rawResults)) {
|
|
678
|
+
throw new KbRerankerOutputError(`HFT_TextReranker: unexpected pipeline output shape for model ${modelPath}`, truncateShape(rawResults));
|
|
679
|
+
}
|
|
680
|
+
const scores = new Array(rawResults.length);
|
|
681
|
+
for (let i = 0;i < rawResults.length; i++) {
|
|
682
|
+
const entry = rawResults[i];
|
|
683
|
+
const candidate = Array.isArray(entry) ? entry[0] : entry;
|
|
684
|
+
if (!isScored(candidate)) {
|
|
685
|
+
throw new KbRerankerOutputError(`HFT_TextReranker: unexpected pipeline output shape for model ${modelPath}`, truncateShape(entry));
|
|
686
|
+
}
|
|
687
|
+
scores[i] = candidate.score;
|
|
688
|
+
}
|
|
689
|
+
return scores;
|
|
690
|
+
}
|
|
691
|
+
var HFT_TextReranker = async (input, model, signal, emit) => {
|
|
692
|
+
const logger = getLogger2();
|
|
693
|
+
const modelPath = model?.provider_config.model_path;
|
|
694
|
+
const timerLabel = `hft:TextReranker:${modelPath}`;
|
|
695
|
+
logger.time(timerLabel, { docs: input.documents.length });
|
|
696
|
+
const reranker = await getPipeline(model, emit, {}, signal);
|
|
697
|
+
const pairs = input.documents.map((doc) => ({ text: input.query, text_pair: doc }));
|
|
698
|
+
const callable = reranker;
|
|
699
|
+
const rawResults = await callable(pairs, { top_k: 1 });
|
|
700
|
+
const scores = validateAndExtractRerankerScores(rawResults, modelPath);
|
|
701
|
+
const indices = scores.map((score, idx) => ({ score, idx })).sort((a, b) => b.score - a.score).map((p) => p.idx);
|
|
702
|
+
const limited = typeof input.topK === "number" ? indices.slice(0, input.topK) : indices;
|
|
703
|
+
logger.timeEnd(timerLabel, { docs: input.documents.length });
|
|
704
|
+
emit({ type: "finish", data: { scores, indices: limited } });
|
|
705
|
+
};
|
|
706
|
+
|
|
659
707
|
// src/ai/common/HFT_ToolMarkup.ts
|
|
660
708
|
function createToolCallMarkupFilter(emit) {
|
|
661
709
|
const OPEN_TAG = "<tool_call>";
|
|
@@ -746,6 +794,7 @@ var HFT_TEXT_CLASSIFICATION = ["text.classification"];
|
|
|
746
794
|
var HFT_TEXT_LANGUAGE_DETECTION = [
|
|
747
795
|
"text.language-detection"
|
|
748
796
|
];
|
|
797
|
+
var HFT_TEXT_RERANKING = ["text.reranking"];
|
|
749
798
|
var HFT_TEXT_FILL_MASK = ["text.fill-mask"];
|
|
750
799
|
var HFT_TEXT_NER = ["text.ner"];
|
|
751
800
|
var HFT_IMAGE_CLASSIFICATION = ["image.classification"];
|
|
@@ -774,6 +823,7 @@ var HFT_CAPABILITY_SETS = [
|
|
|
774
823
|
HFT_TEXT_EMBEDDING,
|
|
775
824
|
HFT_TEXT_CLASSIFICATION,
|
|
776
825
|
HFT_TEXT_LANGUAGE_DETECTION,
|
|
826
|
+
HFT_TEXT_RERANKING,
|
|
777
827
|
HFT_TEXT_FILL_MASK,
|
|
778
828
|
HFT_TEXT_NER,
|
|
779
829
|
HFT_IMAGE_CLASSIFICATION,
|
|
@@ -1171,9 +1221,9 @@ var HFT_CountTokens_Preview = async (input, model) => {
|
|
|
1171
1221
|
|
|
1172
1222
|
// src/ai/common/HFT_Download.ts
|
|
1173
1223
|
init_HFT_Pipeline();
|
|
1174
|
-
import { getLogger as
|
|
1224
|
+
import { getLogger as getLogger3 } from "@workglow/util/worker";
|
|
1175
1225
|
var HFT_Download = async (input, model, signal, emit) => {
|
|
1176
|
-
const logger =
|
|
1226
|
+
const logger = getLogger3();
|
|
1177
1227
|
const timerLabel = `hft:Download:${model?.provider_config.model_path}`;
|
|
1178
1228
|
logger.time(timerLabel, { model: model?.provider_config.model_path });
|
|
1179
1229
|
await getPipeline(model, emit, {}, signal, 100);
|
|
@@ -1273,10 +1323,10 @@ var HFT_ImageClassification = async (input, model, signal, emit) => {
|
|
|
1273
1323
|
|
|
1274
1324
|
// src/ai/common/HFT_ImageEmbedding.ts
|
|
1275
1325
|
init_HFT_Pipeline();
|
|
1276
|
-
import { getLogger as
|
|
1326
|
+
import { getLogger as getLogger4 } from "@workglow/util/worker";
|
|
1277
1327
|
import { imageValueToBlob as imageValueToBlob3 } from "@workglow/ai/provider-utils";
|
|
1278
1328
|
var HFT_ImageEmbedding = async (input, model, signal, emit) => {
|
|
1279
|
-
const logger =
|
|
1329
|
+
const logger = getLogger4();
|
|
1280
1330
|
const timerLabel = `hft:ImageEmbedding:${model?.provider_config.model_path}`;
|
|
1281
1331
|
logger.time(timerLabel, { model: model?.provider_config.model_path });
|
|
1282
1332
|
const embedder = await getPipeline(model, emit, {}, signal);
|
|
@@ -1346,7 +1396,7 @@ var HFT_ImageToText = async (input, model, signal, emit) => {
|
|
|
1346
1396
|
};
|
|
1347
1397
|
|
|
1348
1398
|
// src/ai/common/HFT_ModelInfo.ts
|
|
1349
|
-
import { getLogger as
|
|
1399
|
+
import { getLogger as getLogger5 } from "@workglow/util/worker";
|
|
1350
1400
|
init_HFT_Pipeline();
|
|
1351
1401
|
var HFT_ModelInfo = async (input, model, _signal, emit) => {
|
|
1352
1402
|
if (input.detail === "dimensions") {
|
|
@@ -1383,7 +1433,7 @@ var HFT_ModelInfo = async (input, model, _signal, emit) => {
|
|
|
1383
1433
|
});
|
|
1384
1434
|
return;
|
|
1385
1435
|
}
|
|
1386
|
-
const logger =
|
|
1436
|
+
const logger = getLogger5();
|
|
1387
1437
|
const { ModelRegistry } = await loadTransformersSDK();
|
|
1388
1438
|
const timerLabel = `hft:ModelInfo:${model?.provider_config.model_path}`;
|
|
1389
1439
|
logger.time(timerLabel, { model: model?.provider_config.model_path });
|
|
@@ -1641,9 +1691,9 @@ var HFT_TextClassification = async (input, model, signal, emit) => {
|
|
|
1641
1691
|
|
|
1642
1692
|
// src/ai/common/HFT_TextEmbedding.ts
|
|
1643
1693
|
init_HFT_Pipeline();
|
|
1644
|
-
import { getLogger as
|
|
1694
|
+
import { getLogger as getLogger6 } from "@workglow/util/worker";
|
|
1645
1695
|
var HFT_TextEmbedding = async (input, model, signal, emit) => {
|
|
1646
|
-
const logger =
|
|
1696
|
+
const logger = getLogger6();
|
|
1647
1697
|
const uuid = crypto.randomUUID();
|
|
1648
1698
|
const timerLabel = `hft:TextEmbedding:${model?.provider_config.model_path}:${uuid}`;
|
|
1649
1699
|
logger.time(timerLabel, { model: model?.provider_config.model_path });
|
|
@@ -1865,6 +1915,7 @@ var HFT_RUN_FNS = [
|
|
|
1865
1915
|
{ serves: HFT_TEXT_EMBEDDING, runFn: HFT_TextEmbedding },
|
|
1866
1916
|
{ serves: HFT_TEXT_CLASSIFICATION, runFn: HFT_TextClassification },
|
|
1867
1917
|
{ serves: HFT_TEXT_LANGUAGE_DETECTION, runFn: HFT_TextLanguageDetection },
|
|
1918
|
+
{ serves: HFT_TEXT_RERANKING, runFn: HFT_TextReranker },
|
|
1868
1919
|
{ serves: HFT_TEXT_FILL_MASK, runFn: HFT_TextFillMask },
|
|
1869
1920
|
{ serves: HFT_TEXT_NER, runFn: HFT_TextNamedEntityRecognition },
|
|
1870
1921
|
{ serves: HFT_IMAGE_CLASSIFICATION, runFn: HFT_ImageClassification },
|
|
@@ -2091,6 +2142,7 @@ async function registerHuggingFaceTransformersWorker() {
|
|
|
2091
2142
|
await registerProviderWorker((ws) => new HuggingFaceTransformersProvider(HFT_RUN_FNS, HFT_PREVIEW_TASKS).registerOnWorkerServer(ws), "HuggingFaceTransformers");
|
|
2092
2143
|
}
|
|
2093
2144
|
export {
|
|
2145
|
+
validateAndExtractRerankerScores,
|
|
2094
2146
|
setHftSession,
|
|
2095
2147
|
setHftCacheDir,
|
|
2096
2148
|
removeCachedPipeline,
|
|
@@ -2116,7 +2168,8 @@ export {
|
|
|
2116
2168
|
HF_TRANSFORMERS_ONNX_GPU,
|
|
2117
2169
|
HF_TRANSFORMERS_ONNX_CPU,
|
|
2118
2170
|
HF_TRANSFORMERS_ONNX,
|
|
2171
|
+
HFT_TextReranker,
|
|
2119
2172
|
HFT_NULL_PROCESSOR_PREFIX
|
|
2120
2173
|
};
|
|
2121
2174
|
|
|
2122
|
-
//# debugId=
|
|
2175
|
+
//# debugId=13B5D715B9C2AB4A64756E2164756E21
|