@graphorin/embedder-transformersjs 0.6.0 → 0.6.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @graphorin/embedder-transformersjs
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#142](https://github.com/o-stepper/graphorin/pull/142) [`436d6ca`](https://github.com/o-stepper/graphorin/commit/436d6ca5ebbd16df094e915682d3915c279a8430) Thanks [@o-stepper](https://github.com/o-stepper)! - Version constants and version-bearing strings now derive from each package's manifest at build time (`VERSION = pkg.version`; writer ids, client/server info, OTLP framework attributes, build-info metrics interpolate it). No behavioral change at the current version: the rendered strings are byte-identical. A release bump no longer edits source; the new `check-version-consistency` gate fails any reintroduced hardcoded framework version.
8
+
9
+ - Updated dependencies [[`436d6ca`](https://github.com/o-stepper/graphorin/commit/436d6ca5ebbd16df094e915682d3915c279a8430)]:
10
+ - @graphorin/core@0.6.1
11
+
3
12
  ## 0.6.0
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -81,4 +81,4 @@ MIT © 2026 Oleksiy Stepurenko.
81
81
 
82
82
  ---
83
83
 
84
- **Project Graphorin** · v0.6.0 · MIT License · © 2026 Oleksiy Stepurenko · <https://github.com/o-stepper/graphorin>
84
+ **Project Graphorin** · v0.6.1 · MIT License · © 2026 Oleksiy Stepurenko · <https://github.com/o-stepper/graphorin>
package/dist/index.d.ts CHANGED
@@ -2,8 +2,7 @@ import { EmbedOptions, EmbedderProvider } from "@graphorin/core/contracts";
2
2
 
3
3
  //#region src/index.d.ts
4
4
 
5
- /** Canonical version constant. Mirrors the `package.json` version. */
6
- declare const VERSION = "0.6.0";
5
+ declare const VERSION: string;
7
6
  /**
8
7
  * Pooling strategy. Defaults to `'mean'` per the multilingual-e5 model
9
8
  * card.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src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BAkFX,oCAAA,CAAA;;;;;;;iBAsBA,SAAA;;;;;;;;;iBAYA,mBAAA"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { version } from "./package.js";
1
2
  import { createHash } from "node:crypto";
2
3
 
3
4
  //#region src/index.ts
@@ -11,8 +12,8 @@ import { createHash } from "node:crypto";
11
12
  *
12
13
  * @packageDocumentation
13
14
  */
14
- /** Canonical version constant. Mirrors the `package.json` version. */
15
- const VERSION = "0.6.0";
15
+ /** Canonical version constant, derived from `package.json` at build time. */
16
+ const VERSION = version;
16
17
  const DEFAULT_MODEL = "Xenova/multilingual-e5-base";
17
18
  const DEFAULT_DIM = 768;
18
19
  /**
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["#model","#pooling","#normalize","#revision","#cacheDir","#dtype","#device","#pipelineFactory","#taskPrefix","#resolvedDim","#getExtractor","out: Float32Array[]","#extractor","#loading","CACHED_PIPELINE_FACTORY: PipelineFactory | null","KNOWN_DIMS: ReadonlyMap<string, number>"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @graphorin/embedder-transformersjs - default in-process embedder.\n *\n * Wraps `@huggingface/transformers@^4.1.0` to produce dense embeddings\n * inside the Graphorin process. Default model\n * `Xenova/multilingual-e5-base` (768-dim, multilingual; DEC-130 /\n * ADR-025).\n *\n * @packageDocumentation\n */\n\nimport { createHash } from 'node:crypto';\nimport type { EmbedderProvider, EmbedOptions } from '@graphorin/core/contracts';\n\n/** Canonical version constant. Mirrors the `package.json` version. */\nexport const VERSION = '0.6.0';\n\n/**\n * Pooling strategy. Defaults to `'mean'` per the multilingual-e5 model\n * card.\n *\n * @stable\n */\nexport type Pooling = 'mean' | 'cls' | 'first_token' | 'eos' | 'last_token' | 'none';\n\n/**\n * Configuration accepted by {@link createTransformersJsEmbedder}.\n *\n * @stable\n */\nexport interface TransformersJsEmbedderOptions {\n /** Default `'Xenova/multilingual-e5-base'` (768-dim). */\n readonly model?: string;\n /** Default `'mean'`. */\n readonly pooling?: Pooling;\n /** Default `true`. */\n readonly normalize?: boolean;\n /** Optional model revision pin (`'main'` if unset). */\n readonly revision?: string;\n /**\n * Optional cache directory. When unset, the embedder honours\n * `process.env.GRAPHORIN_CACHE_DIR`, otherwise falls back to the\n * Hugging Face default (`os.homedir()/.cache/huggingface/hub`).\n */\n readonly cacheDir?: string;\n /**\n * Optional dtype hint (`'fp32' | 'fp16' | 'q8' | 'q4'`). When unset,\n * the runtime picks the model's recommended default.\n */\n readonly dtype?: string;\n /** Override device (`'cpu'`, `'webgpu'`, …). Default `'cpu'`. */\n readonly device?: string;\n /**\n * Override the underlying `pipeline` factory - used by the test\n * suite to inject a stub. Production callers should leave this\n * unset so the package lazily loads `@huggingface/transformers`.\n */\n readonly pipelineFactory?: PipelineFactory;\n /**\n * Optional dimensionality hint. When the caller knows the output\n * dimension up-front, it is included in the canonical id without\n * waiting for the first `embed()` call.\n */\n readonly dim?: number;\n /**\n * Disable the automatic E5 `query:` / `passage:` prefixing (PS-10). The\n * prefixes are applied by default for E5-family models (the multilingual-e5\n * default and any model whose id carries an `e5` token), because the E5 model\n * card requires them and omitting them measurably degrades retrieval. Set\n * this to `true` only if your inputs are already prefixed or you use a\n * non-standard E5 export. Toggling it changes the canonical `configHash`\n * (and thus the embedder id), which triggers a re-embedding migration.\n */\n readonly disableTaskPrefix?: boolean;\n}\n\n/**\n * Tiny structural shape of `@huggingface/transformers`' feature-\n * extraction pipeline used by this package. Declared inline so the\n * embedder does not import the heavy peer at build time.\n *\n * @internal\n */\nexport type FeatureExtractor = (\n texts: string | readonly string[],\n options?: { pooling?: Pooling; normalize?: boolean; signal?: AbortSignal },\n) => Promise<{\n data: Float32Array;\n dims: readonly number[];\n tolist?(): unknown;\n}>;\n\n/**\n * Pipeline-factory shape used for dependency injection in tests.\n *\n * @internal\n */\nexport type PipelineFactory = (\n task: 'feature-extraction',\n model: string,\n opts: { revision?: string; cache_dir?: string; dtype?: string; device?: string },\n) => Promise<FeatureExtractor>;\n\nconst DEFAULT_MODEL = 'Xenova/multilingual-e5-base';\nconst DEFAULT_DIM = 768;\n\n/**\n * Raised when the underlying transformer model cannot be loaded\n * (offline / corporate firewall / wrong cache dir).\n *\n * @stable\n */\nexport class EmbedderModelLoadError extends Error {\n override readonly name = 'EmbedderModelLoadError';\n}\n\n/**\n * Build a `TransformersJsEmbedder` instance. Lazy: the underlying\n * pipeline is constructed on the first `embed()` call so packaging\n * the embedder does not pay the model-load cost.\n *\n * @stable\n */\nexport function createTransformersJsEmbedder(\n options: TransformersJsEmbedderOptions = {},\n): TransformersJsEmbedder {\n return new TransformersJsEmbedder(options);\n}\n\n/**\n * `EmbedderProvider` implementation backed by `@huggingface/transformers`.\n *\n * @stable\n */\nexport class TransformersJsEmbedder implements EmbedderProvider {\n readonly #model: string;\n readonly #pooling: Pooling;\n readonly #normalize: boolean;\n readonly #revision: string | undefined;\n readonly #cacheDir: string | undefined;\n readonly #dtype: string | undefined;\n readonly #device: string | undefined;\n readonly #pipelineFactory: PipelineFactory | undefined;\n /** Whether to apply E5 `query:` / `passage:` prefixes (PS-10). */\n readonly #taskPrefix: boolean;\n #extractor: FeatureExtractor | null = null;\n #loading: Promise<FeatureExtractor> | null = null;\n #resolvedDim: number | null;\n\n constructor(options: TransformersJsEmbedderOptions) {\n this.#model = options.model ?? DEFAULT_MODEL;\n this.#pooling = options.pooling ?? 'mean';\n this.#normalize = options.normalize ?? true;\n this.#revision = options.revision;\n this.#cacheDir = options.cacheDir ?? process.env.GRAPHORIN_CACHE_DIR;\n this.#dtype = options.dtype;\n this.#device = options.device;\n this.#pipelineFactory = options.pipelineFactory;\n this.#resolvedDim = options.dim ?? guessDefaultDim(this.#model);\n this.#taskPrefix = isE5Model(this.#model) && options.disableTaskPrefix !== true;\n }\n\n id(): string {\n return `transformersjs:${this.#model}@${this.dim()}`;\n }\n\n /**\n * Output dimension - the explicit `dim` option, a known-model\n * default, or the width resolved from the first `embed()`.\n * periphery-05 (the PS-11 fix ported from the Ollama embedder):\n * throws for an unknown model with no `dim` hint instead of silently\n * assuming 768 - a wrong assumed width bakes a wrong-width id AND a\n * wrong-width vec0 table, and the id then CHANGES after the first\n * `embed()` resolves the truth, which `lock-on-first` reads as an\n * embedder swap.\n */\n dim(): number {\n if (this.#resolvedDim !== null) return this.#resolvedDim;\n throw new Error(\n `[graphorin/embedder-transformersjs] Unknown embedding width for model '${this.#model}'. ` +\n `Pass { dim: <width> } to createTransformersJsEmbedder(...) (or call embed() once before ` +\n `registration so the width is resolved from the model output).`,\n );\n }\n\n configHash(): string {\n return canonicalConfigHash({\n adapter: 'transformersjs',\n model: this.#model,\n pooling: this.#pooling,\n normalize: this.#normalize,\n revision: this.#revision ?? null,\n dtype: this.#dtype ?? null,\n device: this.#device ?? null,\n // PS-10: the prefix policy changes the embeddings, so it must change the\n // id. Only added when active (E5 + not disabled) so non-E5 ids - and the\n // historical hash of an E5 model with prefixing turned off - are stable.\n ...(this.#taskPrefix ? { taskPrefix: 'e5' as const } : {}),\n });\n }\n\n async embed(\n texts: ReadonlyArray<string>,\n opts: EmbedOptions = {},\n ): Promise<ReadonlyArray<Float32Array>> {\n if (texts.length === 0) return [];\n const extractor = await this.#getExtractor();\n // PS-10: E5 models require an asymmetric `query:` / `passage:` prefix.\n // Default to `passage` (the indexing role) when the caller doesn't specify.\n const inputs = this.#taskPrefix\n ? texts.map((t) => `${opts.taskType ?? 'passage'}: ${t}`)\n : [...texts];\n const result = await extractor(inputs, {\n pooling: this.#pooling,\n normalize: this.#normalize,\n ...(opts.signal !== undefined ? { signal: opts.signal } : {}),\n });\n const lastDim = result.dims[result.dims.length - 1] ?? this.#resolvedDim ?? DEFAULT_DIM;\n // periphery-05: a width already published (via `dim` option or a\n // prior embed) must not silently drift - the vec0 table and the\n // canonical id were derived from it.\n if (this.#resolvedDim !== null && lastDim !== this.#resolvedDim) {\n throw new Error(\n `[graphorin/embedder-transformersjs] Model '${this.#model}' produced ${lastDim}-dim ` +\n `vectors but the embedder is bound to ${this.#resolvedDim} - check the 'dim' option.`,\n );\n }\n if (this.#resolvedDim === null) {\n this.#resolvedDim = lastDim;\n }\n const dim = lastDim;\n const out: Float32Array[] = [];\n for (let i = 0; i < texts.length; i++) {\n const start = i * dim;\n out.push(result.data.slice(start, start + dim));\n }\n return out;\n }\n\n async #getExtractor(): Promise<FeatureExtractor> {\n if (this.#extractor !== null) return this.#extractor;\n if (this.#loading !== null) return this.#loading;\n const loader = this.#pipelineFactory ?? (await loadDefaultPipelineFactory());\n this.#loading = loader('feature-extraction', this.#model, {\n ...(this.#revision !== undefined ? { revision: this.#revision } : {}),\n ...(this.#cacheDir !== undefined ? { cache_dir: this.#cacheDir } : {}),\n ...(this.#dtype !== undefined ? { dtype: this.#dtype } : {}),\n ...(this.#device !== undefined ? { device: this.#device } : {}),\n })\n .then((pipe) => {\n this.#extractor = pipe;\n this.#loading = null;\n return pipe;\n })\n .catch((err) => {\n this.#loading = null;\n throw new EmbedderModelLoadError(\n `[graphorin/embedder-transformersjs] failed to load model '${this.#model}'. ` +\n 'See the offline-install guide for instructions on pre-downloading the model.',\n { cause: err },\n );\n });\n return this.#loading;\n }\n}\n\n/** @internal */\nlet CACHED_PIPELINE_FACTORY: PipelineFactory | null = null;\n\nasync function loadDefaultPipelineFactory(): Promise<PipelineFactory> {\n if (CACHED_PIPELINE_FACTORY !== null) return CACHED_PIPELINE_FACTORY;\n try {\n const mod = (await import('@huggingface/transformers')) as unknown as {\n pipeline: PipelineFactory;\n };\n CACHED_PIPELINE_FACTORY = mod.pipeline;\n return CACHED_PIPELINE_FACTORY;\n } catch (err) {\n throw new EmbedderModelLoadError(\n \"[graphorin/embedder-transformersjs] required peer '@huggingface/transformers' is not installed.\",\n { cause: err },\n );\n }\n}\n\n/** Test-only cache reset. */\nexport function _resetPipelineFactoryCacheForTesting(): void {\n CACHED_PIPELINE_FACTORY = null;\n}\n\nconst KNOWN_DIMS: ReadonlyMap<string, number> = new Map([\n ['Xenova/multilingual-e5-small', 384],\n ['Xenova/multilingual-e5-base', 768],\n ['Xenova/multilingual-e5-large', 1024],\n ['Xenova/bge-m3', 1024],\n ['onnx-community/all-MiniLM-L6-v2-ONNX', 384],\n]);\n\nfunction guessDefaultDim(model: string): number | null {\n return KNOWN_DIMS.get(model) ?? null;\n}\n\n/**\n * True when a model id belongs to the E5 family, which requires asymmetric\n * `query:` / `passage:` prefixes (PS-10). Matches an `e5` token bounded by a\n * path / dash / underscore so it covers `multilingual-e5-base`, `e5-large`,\n * `intfloat/e5-mistral`, etc. without false-matching unrelated names.\n */\nexport function isE5Model(model: string): boolean {\n return /(?:^|[/_-])e5(?:[/_-]|$)/i.test(model);\n}\n\n/**\n * Canonical-JSON deterministic hash of an embedder configuration.\n * Object keys are sorted lexicographically; primitives flow through as\n * `JSON.stringify` would render them. Used by the multi-table per-\n * embedder vec0 layout to tell drift apart from a true model swap.\n *\n * @stable\n */\nexport function canonicalConfigHash(config: unknown): string {\n const canonical = canonicalize(config);\n return createHash('sha256').update(canonical, 'utf8').digest('hex');\n}\n\nfunction canonicalize(value: unknown): string {\n if (value === null) return 'null';\n if (typeof value === 'boolean') return value ? 'true' : 'false';\n if (typeof value === 'number') return Number.isFinite(value) ? value.toString() : 'null';\n if (typeof value === 'string') return JSON.stringify(value);\n if (Array.isArray(value)) {\n return `[${value.map(canonicalize).join(',')}]`;\n }\n if (typeof value === 'object') {\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj).sort();\n return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalize(obj[k])}`).join(',')}}`;\n }\n return 'null';\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,UAAU;AAwFvB,MAAM,gBAAgB;AACtB,MAAM,cAAc;;;;;;;AAQpB,IAAa,yBAAb,cAA4C,MAAM;CAChD,AAAkB,OAAO;;;;;;;;;AAU3B,SAAgB,6BACd,UAAyC,EAAE,EACnB;AACxB,QAAO,IAAI,uBAAuB,QAAQ;;;;;;;AAQ5C,IAA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I,CAAC;;AAEvF,QAAO"}
1
+ {"version":3,"file":"index.js","names":["VERSION: string","pkg.version","#model","#pooling","#normalize","#revision","#cacheDir","#dtype","#device","#pipelineFactory","#taskPrefix","#resolvedDim","#getExtractor","out: Float32Array[]","#extractor","#loading","CACHED_PIPELINE_FACTORY: PipelineFactory | null","KNOWN_DIMS: ReadonlyMap<string, number>"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @graphorin/embedder-transformersjs - default in-process embedder.\n *\n * Wraps `@huggingface/transformers@^4.1.0` to produce dense embeddings\n * inside the Graphorin process. Default model\n * `Xenova/multilingual-e5-base` (768-dim, multilingual; DEC-130 /\n * ADR-025).\n *\n * @packageDocumentation\n */\n\nimport { createHash } from 'node:crypto';\nimport type { EmbedderProvider, EmbedOptions } from '@graphorin/core/contracts';\n\n/** Canonical version constant, derived from `package.json` at build time. */\nimport pkg from '../package.json' with { type: 'json' };\n\nexport const VERSION: string = pkg.version;\n\n/**\n * Pooling strategy. Defaults to `'mean'` per the multilingual-e5 model\n * card.\n *\n * @stable\n */\nexport type Pooling = 'mean' | 'cls' | 'first_token' | 'eos' | 'last_token' | 'none';\n\n/**\n * Configuration accepted by {@link createTransformersJsEmbedder}.\n *\n * @stable\n */\nexport interface TransformersJsEmbedderOptions {\n /** Default `'Xenova/multilingual-e5-base'` (768-dim). */\n readonly model?: string;\n /** Default `'mean'`. */\n readonly pooling?: Pooling;\n /** Default `true`. */\n readonly normalize?: boolean;\n /** Optional model revision pin (`'main'` if unset). */\n readonly revision?: string;\n /**\n * Optional cache directory. When unset, the embedder honours\n * `process.env.GRAPHORIN_CACHE_DIR`, otherwise falls back to the\n * Hugging Face default (`os.homedir()/.cache/huggingface/hub`).\n */\n readonly cacheDir?: string;\n /**\n * Optional dtype hint (`'fp32' | 'fp16' | 'q8' | 'q4'`). When unset,\n * the runtime picks the model's recommended default.\n */\n readonly dtype?: string;\n /** Override device (`'cpu'`, `'webgpu'`, …). Default `'cpu'`. */\n readonly device?: string;\n /**\n * Override the underlying `pipeline` factory - used by the test\n * suite to inject a stub. Production callers should leave this\n * unset so the package lazily loads `@huggingface/transformers`.\n */\n readonly pipelineFactory?: PipelineFactory;\n /**\n * Optional dimensionality hint. When the caller knows the output\n * dimension up-front, it is included in the canonical id without\n * waiting for the first `embed()` call.\n */\n readonly dim?: number;\n /**\n * Disable the automatic E5 `query:` / `passage:` prefixing (PS-10). The\n * prefixes are applied by default for E5-family models (the multilingual-e5\n * default and any model whose id carries an `e5` token), because the E5 model\n * card requires them and omitting them measurably degrades retrieval. Set\n * this to `true` only if your inputs are already prefixed or you use a\n * non-standard E5 export. Toggling it changes the canonical `configHash`\n * (and thus the embedder id), which triggers a re-embedding migration.\n */\n readonly disableTaskPrefix?: boolean;\n}\n\n/**\n * Tiny structural shape of `@huggingface/transformers`' feature-\n * extraction pipeline used by this package. Declared inline so the\n * embedder does not import the heavy peer at build time.\n *\n * @internal\n */\nexport type FeatureExtractor = (\n texts: string | readonly string[],\n options?: { pooling?: Pooling; normalize?: boolean; signal?: AbortSignal },\n) => Promise<{\n data: Float32Array;\n dims: readonly number[];\n tolist?(): unknown;\n}>;\n\n/**\n * Pipeline-factory shape used for dependency injection in tests.\n *\n * @internal\n */\nexport type PipelineFactory = (\n task: 'feature-extraction',\n model: string,\n opts: { revision?: string; cache_dir?: string; dtype?: string; device?: string },\n) => Promise<FeatureExtractor>;\n\nconst DEFAULT_MODEL = 'Xenova/multilingual-e5-base';\nconst DEFAULT_DIM = 768;\n\n/**\n * Raised when the underlying transformer model cannot be loaded\n * (offline / corporate firewall / wrong cache dir).\n *\n * @stable\n */\nexport class EmbedderModelLoadError extends Error {\n override readonly name = 'EmbedderModelLoadError';\n}\n\n/**\n * Build a `TransformersJsEmbedder` instance. Lazy: the underlying\n * pipeline is constructed on the first `embed()` call so packaging\n * the embedder does not pay the model-load cost.\n *\n * @stable\n */\nexport function createTransformersJsEmbedder(\n options: TransformersJsEmbedderOptions = {},\n): TransformersJsEmbedder {\n return new TransformersJsEmbedder(options);\n}\n\n/**\n * `EmbedderProvider` implementation backed by `@huggingface/transformers`.\n *\n * @stable\n */\nexport class TransformersJsEmbedder implements EmbedderProvider {\n readonly #model: string;\n readonly #pooling: Pooling;\n readonly #normalize: boolean;\n readonly #revision: string | undefined;\n readonly #cacheDir: string | undefined;\n readonly #dtype: string | undefined;\n readonly #device: string | undefined;\n readonly #pipelineFactory: PipelineFactory | undefined;\n /** Whether to apply E5 `query:` / `passage:` prefixes (PS-10). */\n readonly #taskPrefix: boolean;\n #extractor: FeatureExtractor | null = null;\n #loading: Promise<FeatureExtractor> | null = null;\n #resolvedDim: number | null;\n\n constructor(options: TransformersJsEmbedderOptions) {\n this.#model = options.model ?? DEFAULT_MODEL;\n this.#pooling = options.pooling ?? 'mean';\n this.#normalize = options.normalize ?? true;\n this.#revision = options.revision;\n this.#cacheDir = options.cacheDir ?? process.env.GRAPHORIN_CACHE_DIR;\n this.#dtype = options.dtype;\n this.#device = options.device;\n this.#pipelineFactory = options.pipelineFactory;\n this.#resolvedDim = options.dim ?? guessDefaultDim(this.#model);\n this.#taskPrefix = isE5Model(this.#model) && options.disableTaskPrefix !== true;\n }\n\n id(): string {\n return `transformersjs:${this.#model}@${this.dim()}`;\n }\n\n /**\n * Output dimension - the explicit `dim` option, a known-model\n * default, or the width resolved from the first `embed()`.\n * periphery-05 (the PS-11 fix ported from the Ollama embedder):\n * throws for an unknown model with no `dim` hint instead of silently\n * assuming 768 - a wrong assumed width bakes a wrong-width id AND a\n * wrong-width vec0 table, and the id then CHANGES after the first\n * `embed()` resolves the truth, which `lock-on-first` reads as an\n * embedder swap.\n */\n dim(): number {\n if (this.#resolvedDim !== null) return this.#resolvedDim;\n throw new Error(\n `[graphorin/embedder-transformersjs] Unknown embedding width for model '${this.#model}'. ` +\n `Pass { dim: <width> } to createTransformersJsEmbedder(...) (or call embed() once before ` +\n `registration so the width is resolved from the model output).`,\n );\n }\n\n configHash(): string {\n return canonicalConfigHash({\n adapter: 'transformersjs',\n model: this.#model,\n pooling: this.#pooling,\n normalize: this.#normalize,\n revision: this.#revision ?? null,\n dtype: this.#dtype ?? null,\n device: this.#device ?? null,\n // PS-10: the prefix policy changes the embeddings, so it must change the\n // id. Only added when active (E5 + not disabled) so non-E5 ids - and the\n // historical hash of an E5 model with prefixing turned off - are stable.\n ...(this.#taskPrefix ? { taskPrefix: 'e5' as const } : {}),\n });\n }\n\n async embed(\n texts: ReadonlyArray<string>,\n opts: EmbedOptions = {},\n ): Promise<ReadonlyArray<Float32Array>> {\n if (texts.length === 0) return [];\n const extractor = await this.#getExtractor();\n // PS-10: E5 models require an asymmetric `query:` / `passage:` prefix.\n // Default to `passage` (the indexing role) when the caller doesn't specify.\n const inputs = this.#taskPrefix\n ? texts.map((t) => `${opts.taskType ?? 'passage'}: ${t}`)\n : [...texts];\n const result = await extractor(inputs, {\n pooling: this.#pooling,\n normalize: this.#normalize,\n ...(opts.signal !== undefined ? { signal: opts.signal } : {}),\n });\n const lastDim = result.dims[result.dims.length - 1] ?? this.#resolvedDim ?? DEFAULT_DIM;\n // periphery-05: a width already published (via `dim` option or a\n // prior embed) must not silently drift - the vec0 table and the\n // canonical id were derived from it.\n if (this.#resolvedDim !== null && lastDim !== this.#resolvedDim) {\n throw new Error(\n `[graphorin/embedder-transformersjs] Model '${this.#model}' produced ${lastDim}-dim ` +\n `vectors but the embedder is bound to ${this.#resolvedDim} - check the 'dim' option.`,\n );\n }\n if (this.#resolvedDim === null) {\n this.#resolvedDim = lastDim;\n }\n const dim = lastDim;\n const out: Float32Array[] = [];\n for (let i = 0; i < texts.length; i++) {\n const start = i * dim;\n out.push(result.data.slice(start, start + dim));\n }\n return out;\n }\n\n async #getExtractor(): Promise<FeatureExtractor> {\n if (this.#extractor !== null) return this.#extractor;\n if (this.#loading !== null) return this.#loading;\n const loader = this.#pipelineFactory ?? (await loadDefaultPipelineFactory());\n this.#loading = loader('feature-extraction', this.#model, {\n ...(this.#revision !== undefined ? { revision: this.#revision } : {}),\n ...(this.#cacheDir !== undefined ? { cache_dir: this.#cacheDir } : {}),\n ...(this.#dtype !== undefined ? { dtype: this.#dtype } : {}),\n ...(this.#device !== undefined ? { device: this.#device } : {}),\n })\n .then((pipe) => {\n this.#extractor = pipe;\n this.#loading = null;\n return pipe;\n })\n .catch((err) => {\n this.#loading = null;\n throw new EmbedderModelLoadError(\n `[graphorin/embedder-transformersjs] failed to load model '${this.#model}'. ` +\n 'See the offline-install guide for instructions on pre-downloading the model.',\n { cause: err },\n );\n });\n return this.#loading;\n }\n}\n\n/** @internal */\nlet CACHED_PIPELINE_FACTORY: PipelineFactory | null = null;\n\nasync function loadDefaultPipelineFactory(): Promise<PipelineFactory> {\n if (CACHED_PIPELINE_FACTORY !== null) return CACHED_PIPELINE_FACTORY;\n try {\n const mod = (await import('@huggingface/transformers')) as unknown as {\n pipeline: PipelineFactory;\n };\n CACHED_PIPELINE_FACTORY = mod.pipeline;\n return CACHED_PIPELINE_FACTORY;\n } catch (err) {\n throw new EmbedderModelLoadError(\n \"[graphorin/embedder-transformersjs] required peer '@huggingface/transformers' is not installed.\",\n { cause: err },\n );\n }\n}\n\n/** Test-only cache reset. */\nexport function _resetPipelineFactoryCacheForTesting(): void {\n CACHED_PIPELINE_FACTORY = null;\n}\n\nconst KNOWN_DIMS: ReadonlyMap<string, number> = new Map([\n ['Xenova/multilingual-e5-small', 384],\n ['Xenova/multilingual-e5-base', 768],\n ['Xenova/multilingual-e5-large', 1024],\n ['Xenova/bge-m3', 1024],\n ['onnx-community/all-MiniLM-L6-v2-ONNX', 384],\n]);\n\nfunction guessDefaultDim(model: string): number | null {\n return KNOWN_DIMS.get(model) ?? null;\n}\n\n/**\n * True when a model id belongs to the E5 family, which requires asymmetric\n * `query:` / `passage:` prefixes (PS-10). Matches an `e5` token bounded by a\n * path / dash / underscore so it covers `multilingual-e5-base`, `e5-large`,\n * `intfloat/e5-mistral`, etc. without false-matching unrelated names.\n */\nexport function isE5Model(model: string): boolean {\n return /(?:^|[/_-])e5(?:[/_-]|$)/i.test(model);\n}\n\n/**\n * Canonical-JSON deterministic hash of an embedder configuration.\n * Object keys are sorted lexicographically; primitives flow through as\n * `JSON.stringify` would render them. Used by the multi-table per-\n * embedder vec0 layout to tell drift apart from a true model swap.\n *\n * @stable\n */\nexport function canonicalConfigHash(config: unknown): string {\n const canonical = canonicalize(config);\n return createHash('sha256').update(canonical, 'utf8').digest('hex');\n}\n\nfunction canonicalize(value: unknown): string {\n if (value === null) return 'null';\n if (typeof value === 'boolean') return value ? 'true' : 'false';\n if (typeof value === 'number') return Number.isFinite(value) ? value.toString() : 'null';\n if (typeof value === 'string') return JSON.stringify(value);\n if (Array.isArray(value)) {\n return `[${value.map(canonicalize).join(',')}]`;\n }\n if (typeof value === 'object') {\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj).sort();\n return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalize(obj[k])}`).join(',')}}`;\n }\n return 'null';\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAaA,UAAkBC;AAwF/B,MAAM,gBAAgB;AACtB,MAAM,cAAc;;;;;;;AAQpB,IAAa,yBAAb,cAA4C,MAAM;CAChD,AAAkB,OAAO;;;;;;;;;AAU3B,SAAgB,6BACd,UAAyC,EAAE,EACnB;AACxB,QAAO,IAAI,uBAAuB,QAAQ;;;;;;;AAQ5C,IAAa,yBAAb,MAAgE;CAC9D,CAASC;CACT,CAASC;CACT,CAASC;CACT,CAASC;CACT,CAASC;CACT,CAASC;CACT,CAASC;CACT,CAASC;;CAET,CAASC;CACT,aAAsC;CACtC,WAA6C;CAC7C;CAEA,YAAY,SAAwC;AAClD,QAAKR,QAAS,QAAQ,SAAS;AAC/B,QAAKC,UAAW,QAAQ,WAAW;AACnC,QAAKC,YAAa,QAAQ,aAAa;AACvC,QAAKC,WAAY,QAAQ;AACzB,QAAKC,WAAY,QAAQ,YAAY,QAAQ,IAAI;AACjD,QAAKC,QAAS,QAAQ;AACtB,QAAKC,S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iBAAiB,KAAK;CACvB,CAAC,wCAAwC,IAAI;CAC9C,CAAC;AAEF,SAAS,gBAAgB,OAA8B;AACrD,QAAO,WAAW,IAAI,MAAM,IAAI;;;;;;;;AASlC,SAAgB,UAAU,OAAwB;AAChD,QAAO,4BAA4B,KAAK,MAAM;;;;;;;;;;AAWhD,SAAgB,oBAAoB,QAAyB;CAC3D,MAAM,YAAY,aAAa,OAAO;AACtC,QAAO,WAAW,SAAS,CAAC,OAAO,WAAW,OAAO,CAAC,OAAO,MAAM;;AAGrE,SAAS,aAAa,OAAwB;AAC5C,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,OAAO,UAAU,UAAW,QAAO,QAAQ,SAAS;AACxD,KAAI,OAAO,UAAU,SAAU,QAAO,OAAO,SAAS,MAAM,GAAG,MAAM,UAAU,GAAG;AAClF,KAAI,OAAO,UAAU,SAAU,QAAO,KAAK,UAAU,MAAM;AAC3D,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,IAAI,MAAM,IAAI,aAAa,CAAC,KAAK,IAAI,CAAC;AAE/C,KAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,MAAM;AAEZ,SAAO,IADM,OAAO,KAAK,IAAI,CAAC,MAAM,CACpB,KAAK,MAAM,GAAG,KAAK,UAAU,EAAE,CAAC,GAAG,aAAa,IAAI,GAAG,GAAG,CAAC,KAAK,IAAI,CAAC;;AAEvF,QAAO"}
@@ -0,0 +1,6 @@
1
+ //#region package.json
2
+ var version = "0.6.1";
3
+
4
+ //#endregion
5
+ export { version };
6
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@graphorin/embedder-transformersjs\",\n \"version\": \"0.6.1\",\n \"description\": \"Default in-process embedder for the Graphorin framework. Wraps `@huggingface/transformers@^4.1.0` to produce dense vectors with the multilingual `Xenova/multilingual-e5-base` model (768-dim) by default. Implements the `EmbedderProvider` contract from `@graphorin/core/contracts` with deterministic `configHash`, batched embed, lazy model download (cache honours `GRAPHORIN_CACHE_DIR`), and an actionable error if the model cannot be fetched.\",\n \"license\": \"MIT\",\n \"author\": \"Oleksiy Stepurenko\",\n \"homepage\": \"https://github.com/o-stepper/graphorin/tree/main/packages/embedder-transformersjs\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/o-stepper/graphorin.git\",\n \"directory\": \"packages/embedder-transformersjs\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/o-stepper/graphorin/issues\"\n },\n \"keywords\": [\n \"graphorin\",\n \"ai\",\n \"agents\",\n \"framework\",\n \"embeddings\",\n \"transformersjs\",\n \"huggingface\",\n \"multilingual\"\n ],\n \"type\": \"module\",\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"CHANGELOG.md\",\n \"LICENSE\"\n ],\n \"scripts\": {\n \"build\": \"tsdown\",\n \"typecheck\": \"tsc --noEmit && tsc -p tsconfig.tests.json\",\n \"test\": \"vitest run\",\n \"lint\": \"biome check .\",\n \"clean\": \"rimraf dist .turbo *.tsbuildinfo\"\n },\n \"dependencies\": {\n \"@graphorin/core\": \"workspace:*\"\n },\n \"peerDependencies\": {\n \"@huggingface/transformers\": \"^4.1.0\"\n },\n \"peerDependenciesMeta\": {\n \"@huggingface/transformers\": {\n \"optional\": false\n }\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"devDependencies\": {\n \"@huggingface/transformers\": \"^4.1.0\"\n }\n}\n"],"mappings":";cAEa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphorin/embedder-transformersjs",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Default in-process embedder for the Graphorin framework. Wraps `@huggingface/transformers@^4.1.0` to produce dense vectors with the multilingual `Xenova/multilingual-e5-base` model (768-dim) by default. Implements the `EmbedderProvider` contract from `@graphorin/core/contracts` with deterministic `configHash`, batched embed, lazy model download (cache honours `GRAPHORIN_CACHE_DIR`), and an actionable error if the model cannot be fetched.",
5
5
  "license": "MIT",
6
6
  "author": "Oleksiy Stepurenko",
@@ -44,7 +44,7 @@
44
44
  "LICENSE"
45
45
  ],
46
46
  "dependencies": {
47
- "@graphorin/core": "0.6.0"
47
+ "@graphorin/core": "0.6.1"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@huggingface/transformers": "^4.1.0"