@workglow/eval 0.3.26
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/README.md +179 -0
- package/dist/commands/dataset.d.ts +9 -0
- package/dist/commands/dataset.d.ts.map +1 -0
- package/dist/commands/report.d.ts +11 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/run.d.ts +9 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/config.d.ts +29 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/evals/classify.d.ts +25 -0
- package/dist/evals/classify.d.ts.map +1 -0
- package/dist/evals/extract.d.ts +26 -0
- package/dist/evals/extract.d.ts.map +1 -0
- package/dist/evals/prompt.d.ts +12 -0
- package/dist/evals/prompt.d.ts.map +1 -0
- package/dist/evals/runner.d.ts +25 -0
- package/dist/evals/runner.d.ts.map +1 -0
- package/dist/evals/similarity.d.ts +15 -0
- package/dist/evals/similarity.d.ts.map +1 -0
- package/dist/evals/types.d.ts +39 -0
- package/dist/evals/types.d.ts.map +1 -0
- package/dist/hf/auth.d.ts +8 -0
- package/dist/hf/auth.d.ts.map +1 -0
- package/dist/hf/datasetsServer.d.ts +14 -0
- package/dist/hf/datasetsServer.d.ts.map +1 -0
- package/dist/hf/hubFiles.d.ts +38 -0
- package/dist/hf/hubFiles.d.ts.map +1 -0
- package/dist/hf/ids.d.ts +20 -0
- package/dist/hf/ids.d.ts.map +1 -0
- package/dist/hf/pullDataset.d.ts +26 -0
- package/dist/hf/pullDataset.d.ts.map +1 -0
- package/dist/hf/types.d.ts +33 -0
- package/dist/hf/types.d.ts.map +1 -0
- package/dist/models.d.ts +49 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/providers.d.ts +17 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/report/aggregate.d.ts +35 -0
- package/dist/report/aggregate.d.ts.map +1 -0
- package/dist/score/classification.d.ts +29 -0
- package/dist/score/classification.d.ts.map +1 -0
- package/dist/score/correlation.d.ts +12 -0
- package/dist/score/correlation.d.ts.map +1 -0
- package/dist/score/extraction.d.ts +47 -0
- package/dist/score/extraction.d.ts.map +1 -0
- package/dist/storage.d.ts +152 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/test/aggregate.test.d.ts +7 -0
- package/dist/test/aggregate.test.d.ts.map +1 -0
- package/dist/test/extractSmoke.e2e.test.d.ts +7 -0
- package/dist/test/extractSmoke.e2e.test.d.ts.map +1 -0
- package/dist/test/extraction.test.d.ts +7 -0
- package/dist/test/extraction.test.d.ts.map +1 -0
- package/dist/test/ggufSmoke.e2e.test.d.ts +7 -0
- package/dist/test/ggufSmoke.e2e.test.d.ts.map +1 -0
- package/dist/test/hubFiles.test.d.ts +7 -0
- package/dist/test/hubFiles.test.d.ts.map +1 -0
- package/dist/test/ids.test.d.ts +7 -0
- package/dist/test/ids.test.d.ts.map +1 -0
- package/dist/test/liveSimilarity.e2e.test.d.ts +7 -0
- package/dist/test/liveSimilarity.e2e.test.d.ts.map +1 -0
- package/dist/test/models.test.d.ts +7 -0
- package/dist/test/models.test.d.ts.map +1 -0
- package/dist/test/score.test.d.ts +7 -0
- package/dist/test/score.test.d.ts.map +1 -0
- package/dist/test/storage.test.d.ts +7 -0
- package/dist/test/storage.test.d.ts.map +1 -0
- package/dist/util.d.ts +13 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/worker_hft.d.ts +7 -0
- package/dist/worker_hft.d.ts.map +1 -0
- package/dist/worker_hft.js +9 -0
- package/dist/worker_llamacpp.d.ts +7 -0
- package/dist/worker_llamacpp.d.ts.map +1 -0
- package/dist/worker_llamacpp.js +3 -0
- package/dist/workglow-eval.d.ts +8 -0
- package/dist/workglow-eval.d.ts.map +1 -0
- package/dist/workglow-eval.js +1266 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Workglow Eval Example
|
|
2
|
+
|
|
3
|
+
A command-line harness for comparing AI models on Workglow task workflows, using
|
|
4
|
+
HuggingFace datasets as ground truth and Workglow storage for every artifact —
|
|
5
|
+
dataset rows, eval runs, and per-row results all live in a queryable SQLite
|
|
6
|
+
database.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
The [`@workglow/sec`](https://github.com/workglow-dev/sec) project ships an eval
|
|
11
|
+
harness specialized for SEC filing extraction. This example is the
|
|
12
|
+
general-purpose version of that idea:
|
|
13
|
+
|
|
14
|
+
1. **Pull** a dataset split from HuggingFace into tabular storage.
|
|
15
|
+
2. **Run** each stored row through a task workflow, once per candidate model.
|
|
16
|
+
3. **Score** the stored results and rank the models on quality and latency.
|
|
17
|
+
|
|
18
|
+
Because every step reads from and writes to `ITabularStorage`, runs are
|
|
19
|
+
inspectable and repeatable: re-score without re-running, diff two runs, or point
|
|
20
|
+
another tool at the same SQLite file.
|
|
21
|
+
|
|
22
|
+
## Getting Started
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bun install
|
|
26
|
+
bun run build-example
|
|
27
|
+
|
|
28
|
+
# 1. Pull a dataset split into storage
|
|
29
|
+
./dist/workglow-eval.js dataset pull dair-ai/emotion --split test --limit 100
|
|
30
|
+
./dist/workglow-eval.js dataset list
|
|
31
|
+
|
|
32
|
+
# 2. Run an eval workflow across models (per-row workflow × models)
|
|
33
|
+
./dist/workglow-eval.js run-classify --dataset dair-ai/emotion --split test \
|
|
34
|
+
--models "onnx-community/LFM2.5-350M-ONNX,claude-haiku-4-5,gpt-5.4-mini"
|
|
35
|
+
|
|
36
|
+
# 3. Re-score any stored run later
|
|
37
|
+
./dist/workglow-eval.js runs
|
|
38
|
+
./dist/workglow-eval.js report [run-id] --format json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Everything is stored under `~/.workglow/eval` (override with
|
|
42
|
+
`WORKGLOW_EVAL_HOME`). Re-pulling a split replaces it; pulling with `--offset`
|
|
43
|
+
extends the stored split, so large splits can be paged in incrementally.
|
|
44
|
+
|
|
45
|
+
## Eval workflows
|
|
46
|
+
|
|
47
|
+
### `run-classify` — label accuracy
|
|
48
|
+
|
|
49
|
+
Each row runs a one-task workflow: `StructuredGenerationTask` with an output
|
|
50
|
+
schema whose `label` property is an enum of the candidate labels. Any model
|
|
51
|
+
with text generation + JSON mode is comparable — local ONNX models and cloud
|
|
52
|
+
models compete on the same rows. Scored by accuracy (case/punctuation
|
|
53
|
+
insensitive).
|
|
54
|
+
|
|
55
|
+
Works out of the box with classification datasets such as `dair-ai/emotion` or
|
|
56
|
+
`SetFit/sst2`. Integer-coded label columns are mapped through the dataset's
|
|
57
|
+
`ClassLabel` names automatically; use `--labels "a,b,c"` when the dataset
|
|
58
|
+
doesn't declare them (integer gold labels are then mapped through that list,
|
|
59
|
+
in order).
|
|
60
|
+
|
|
61
|
+
### `run-similarity` — embedding quality
|
|
62
|
+
|
|
63
|
+
Each row runs a one-task workflow: `TextEmbeddingTask` embeds a sentence pair,
|
|
64
|
+
and the cosine similarity of the two vectors is the model's predicted score.
|
|
65
|
+
Scored by Pearson/Spearman correlation against the dataset's gold ratings
|
|
66
|
+
(correlation is scale-invariant, so 0–5 ratings work as-is).
|
|
67
|
+
|
|
68
|
+
Works out of the box with `mteb/stsbenchmark-sts`:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
./dist/workglow-eval.js dataset pull mteb/stsbenchmark-sts --split test --limit 200
|
|
72
|
+
./dist/workglow-eval.js run-similarity --dataset mteb/stsbenchmark-sts --split test \
|
|
73
|
+
--models "Xenova/all-MiniLM-L6-v2,text-embedding-3-small"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### `run-extract` — structured extraction quality
|
|
77
|
+
|
|
78
|
+
Each row runs a one-task workflow: `StructuredGenerationTask` with an `items`
|
|
79
|
+
array output schema, extracting structured records (people, deals, entities…)
|
|
80
|
+
from the row's prose. The gold column (`--expected-column`, default
|
|
81
|
+
`expected`) holds an array of objects — parquet struct/list columns and JSON
|
|
82
|
+
strings both work. Candidate items are aligned to gold rows by
|
|
83
|
+
`--key-field` (default `name`, case/punctuation-insensitive) and scored on
|
|
84
|
+
three axes, micro-averaged across the split:
|
|
85
|
+
|
|
86
|
+
- **score** — field-level agreement over matched rows, excluding the key
|
|
87
|
+
field itself (a matched pair agrees on it by construction). The ranking
|
|
88
|
+
metric; falls back to **found** when no fields were scored.
|
|
89
|
+
- **found** — entity recall (gold rows matched by key)
|
|
90
|
+
- **prec** — precision over distinct candidate rows (1 − hallucinated rows)
|
|
91
|
+
|
|
92
|
+
`--fields "a,b,c"` limits which fields are requested and scored (default: the
|
|
93
|
+
keys seen in the gold rows); `--instruction "…"` replaces the task sentence at
|
|
94
|
+
the top of the prompt.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
./dist/workglow-eval.js run-extract --dataset my-org/people-extraction --split test \
|
|
98
|
+
--key-field name --fields "name,role" \
|
|
99
|
+
--instruction "Extract every person mentioned in the text." \
|
|
100
|
+
--models "claude-haiku-4-5,onnx-community/LFM2.5-350M-ONNX,gguf:prism-ml/Bonsai-27B-gguf:Q1_0"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This is the generalized form of the SEC repo's extraction eval: same
|
|
104
|
+
alignment-by-key scoring (a model that emits the same entity twice is
|
|
105
|
+
over-producing rows, not hallucinating, so precision is computed over
|
|
106
|
+
distinct rows), but driven by any HuggingFace dataset instead of committed
|
|
107
|
+
fixtures.
|
|
108
|
+
|
|
109
|
+
## Model ids
|
|
110
|
+
|
|
111
|
+
Model ids resolve to an inline `ModelConfig` by shape — no model repository
|
|
112
|
+
setup needed:
|
|
113
|
+
|
|
114
|
+
| Shape | Provider |
|
|
115
|
+
| ---------------------------------------- | ----------------------------------- |
|
|
116
|
+
| `claude-*` | Anthropic (`ANTHROPIC_API_KEY`) |
|
|
117
|
+
| `gpt-*`, `o<n>*`, `text-embedding-*` | OpenAI (`OPENAI_API_KEY`) |
|
|
118
|
+
| `gemini-*` | Google Gemini (`GEMINI_API_KEY`) |
|
|
119
|
+
| `grok-*` | xAI (`XAI_API_KEY`) |
|
|
120
|
+
| `org/name` (optionally `org/name:dtype`) | Local HuggingFace Transformers ONNX |
|
|
121
|
+
| `gguf:org/repo:Quant` or `gguf:*.gguf` | Local node-llama-cpp (GGUF) |
|
|
122
|
+
|
|
123
|
+
Local models download on first use into the eval home's cache and run in a
|
|
124
|
+
worker; no API key required. Embedding dimensions for ONNX models are read from
|
|
125
|
+
the model's `config.json` on the hub; GGUF references resolve through
|
|
126
|
+
node-llama-cpp's `hf:` URIs (an explicit `gguf:` prefix is required because a
|
|
127
|
+
GGUF repo id is indistinguishable from an ONNX one). Note that small instruct
|
|
128
|
+
models vary widely in JSON mode reliability — `onnx-community/LFM2.5-350M-ONNX`
|
|
129
|
+
(the classify default) follows the schema; e.g. SmolLM2-360M echoes the schema
|
|
130
|
+
back instead of an answer. A model that fails a row is recorded as a failed
|
|
131
|
+
result (visible in the report), never a crashed sweep.
|
|
132
|
+
|
|
133
|
+
### Bonsai 27B
|
|
134
|
+
|
|
135
|
+
The Bonsai 27B release (2026-07, Qwen3.6-27B base) is the kind of model this
|
|
136
|
+
harness is for — a 1-bit/ternary model whose claim is cloud-class quality at
|
|
137
|
+
local cost. Compare it against a cloud model on the same rows:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
./dist/workglow-eval.js run-classify --dataset dair-ai/emotion --split test \
|
|
141
|
+
--models "gguf:prism-ml/Bonsai-27B-gguf:Q1_0,claude-haiku-4-5"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The ternary variant is `gguf:prism-ml/Ternary-Bonsai-27B-gguf:Q2_0`. As of the
|
|
145
|
+
release only GGUF/MLX/AWQ conversions exist — when `onnx-community` publishes
|
|
146
|
+
the 27B ONNX conversion it slots straight in as
|
|
147
|
+
`onnx-community/Bonsai-27B-ONNX` (the smaller Bonsai ONNX sizes,
|
|
148
|
+
e.g. `onnx-community/Bonsai-8B-ONNX`, work today).
|
|
149
|
+
|
|
150
|
+
## Dataset fetching
|
|
151
|
+
|
|
152
|
+
`dataset pull` prefers the HuggingFace datasets viewer API
|
|
153
|
+
(`datasets-server.huggingface.co/rows`), which provides typed features and
|
|
154
|
+
pagination. When that endpoint is unreachable it falls back to downloading the
|
|
155
|
+
repo's data files directly from the hub, parsing parquet (including the
|
|
156
|
+
`ClassLabel` names embedded in the parquet footer), `jsonl`, `jsonl.gz`,
|
|
157
|
+
`ndjson`, and `json`. Set `HF_TOKEN` for gated or private datasets.
|
|
158
|
+
|
|
159
|
+
## Storage layout
|
|
160
|
+
|
|
161
|
+
| Table | Key | Contents |
|
|
162
|
+
| ------------------ | --------------------------- | ------------------------------------- |
|
|
163
|
+
| `eval_dataset` | (dataset, split) | columns, ClassLabel names, row count |
|
|
164
|
+
| `eval_dataset_row` | (dataset, split, row_index) | raw row JSON |
|
|
165
|
+
| `eval_run` | run_id (uuid) | kind, dataset, models, column options |
|
|
166
|
+
| `eval_result` | (run_id, model, row_index) | expected/predicted, latency, ok/error |
|
|
167
|
+
|
|
168
|
+
The same schemas run on any `ITabularStorage` backend — the unit tests exercise
|
|
169
|
+
them with `InMemoryTabularStorage`, the CLI uses `SqliteTabularStorage`.
|
|
170
|
+
|
|
171
|
+
## Tests
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
bun run test # unit tests (scorers, parsers, storage round-trip)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`src/test/liveSimilarity.e2e.test.ts` (ONNX) and `src/test/ggufSmoke.e2e.test.ts`
|
|
178
|
+
(GGUF) are live end-to-end checks (network + model download) and are excluded
|
|
179
|
+
from the default vitest run like the rest of the repo's `.e2e.test.ts` files.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Command } from "commander";
|
|
7
|
+
import type { EvalStores } from "../storage";
|
|
8
|
+
export declare function registerDatasetCommand(program: Command, openStores: () => Promise<EvalStores>): void;
|
|
9
|
+
//# sourceMappingURL=dataset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../src/commands/dataset.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GACpC,IAAI,CA6EN"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Command } from "commander";
|
|
7
|
+
import type { EvalStores } from "../storage";
|
|
8
|
+
/** Render the report for one stored run to stdout (table or json). */
|
|
9
|
+
export declare function printReport(stores: EvalStores, runId: string, format: string): Promise<void>;
|
|
10
|
+
export declare function registerReportCommand(program: Command, openStores: () => Promise<EvalStores>): void;
|
|
11
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/commands/report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,sEAAsE;AACtE,wBAAsB,WAAW,CAC/B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAyDf;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GACpC,IAAI,CA2CN"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Command } from "commander";
|
|
7
|
+
import type { EvalStores } from "../storage";
|
|
8
|
+
export declare function registerRunCommand(program: Command, openStores: () => Promise<EvalStores>, ensureProviders: () => Promise<void>): void;
|
|
9
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA0C7C,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,EACrC,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GACnC,IAAI,CA0CN"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export interface EvalConfig {
|
|
7
|
+
/** Directory holding the SQLite database and model cache. */
|
|
8
|
+
readonly home: string;
|
|
9
|
+
/** SQLite database file with dataset rows, runs, and results. */
|
|
10
|
+
readonly dbPath: string;
|
|
11
|
+
/** ONNX model cache directory for the HuggingFace Transformers worker. */
|
|
12
|
+
readonly modelCache: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The eval home directory (no side effects; safe to call from pure helpers).
|
|
16
|
+
* WORKGLOW_EVAL_HOME is set by the invoking user for their own machine — the
|
|
17
|
+
* same trust domain as the process itself, like HOME or XDG_DATA_HOME — and is
|
|
18
|
+
* normalized to an absolute path so a relative value anchors predictably.
|
|
19
|
+
*/
|
|
20
|
+
export declare function evalHome(): string;
|
|
21
|
+
/** GGUF weights directory for the node-llama-cpp worker (used by the model resolver). */
|
|
22
|
+
export declare function ggufCacheDir(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the eval home directory. Everything the harness persists (dataset
|
|
25
|
+
* rows, eval runs, per-row results, downloaded local models) lives under this
|
|
26
|
+
* one directory so it is easy to inspect and easy to delete.
|
|
27
|
+
*/
|
|
28
|
+
export declare function loadConfig(): EvalConfig;
|
|
29
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,UAAU;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAGjC;AAED,yFAAyF;AACzF,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAQvC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { ModelConfig } from "@workglow/ai";
|
|
7
|
+
import type { DatasetRow, LabelNames } from "../hf/types";
|
|
8
|
+
import type { ColumnOptions, DatasetContext, RowExecutor } from "./types";
|
|
9
|
+
/**
|
|
10
|
+
* Resolve the gold label for a row: integer-coded labels (HuggingFace
|
|
11
|
+
* `ClassLabel`) are mapped through the dataset's label names, falling back to
|
|
12
|
+
* the candidate label list (`--labels`) when the dataset doesn't declare
|
|
13
|
+
* names; string labels pass through unchanged.
|
|
14
|
+
*/
|
|
15
|
+
export declare function expectedLabel(row: DatasetRow, labelColumn: string, labelNames: LabelNames, candidateLabels?: readonly string[]): string;
|
|
16
|
+
/** The candidate label set: explicit flag, else the dataset's ClassLabel names. */
|
|
17
|
+
export declare function resolveCandidateLabels(options: ColumnOptions, context: DatasetContext): readonly string[];
|
|
18
|
+
export declare function buildClassifyPrompt(text: string, labels: readonly string[]): string;
|
|
19
|
+
/**
|
|
20
|
+
* Per-row classification workflow: a single StructuredGenerationTask whose
|
|
21
|
+
* output schema constrains the label to the candidate set, so any model with
|
|
22
|
+
* text generation + JSON mode (cloud or local ONNX) is comparable.
|
|
23
|
+
*/
|
|
24
|
+
export declare function makeClassifyExecutor(model: ModelConfig, options: ColumnOptions, context: DatasetContext): RowExecutor;
|
|
25
|
+
//# sourceMappingURL=classify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/evals/classify.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,UAAU,EACf,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,UAAU,EACtB,eAAe,GAAE,SAAS,MAAM,EAAO,GACtC,MAAM,CAOR;AAED,mFAAmF;AACnF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,cAAc,GACtB,SAAS,MAAM,EAAE,CAQnB;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAOnF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,cAAc,GACtB,WAAW,CAkCb"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { ModelConfig } from "@workglow/ai";
|
|
7
|
+
import type { ExtractedRow } from "../score/extraction";
|
|
8
|
+
import type { ColumnOptions, DatasetContext, RowExecutor } from "./types";
|
|
9
|
+
/**
|
|
10
|
+
* Parse a gold extraction column: parquet struct/list columns and
|
|
11
|
+
* datasets-server JSON arrive as real arrays of objects; string columns hold
|
|
12
|
+
* JSON. Anything else is a data error surfaced as a per-row failure.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseExpectedRows(value: unknown, column: string): ExtractedRow[];
|
|
15
|
+
/** The fields to extract and score: explicit flag, else keys seen in the gold rows. */
|
|
16
|
+
export declare function resolveExtractionFields(expectedRows: readonly ExtractedRow[], keyField: string, fields: readonly string[] | undefined): string[];
|
|
17
|
+
export declare function buildExtractPrompt(text: string, instruction: string, keyField: string, fields: readonly string[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* Per-row extraction workflow: a single StructuredGenerationTask whose output
|
|
20
|
+
* schema is an `items` array of objects keyed by the alignment field, so any
|
|
21
|
+
* model with text generation + JSON mode is comparable. The gold column
|
|
22
|
+
* supplies the expected rows; scoring aligns candidate items to them by
|
|
23
|
+
* `keyField` (see {@link scoreExtraction}).
|
|
24
|
+
*/
|
|
25
|
+
export declare function makeExtractExecutor(model: ModelConfig, options: ColumnOptions, context: DatasetContext): RowExecutor;
|
|
26
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/evals/extract.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAW1E;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAShF;AAED,uFAAuF;AACvF,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,SAAS,YAAY,EAAE,EACrC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACpC,MAAM,EAAE,CAaV;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,MAAM,EAAE,GACxB,MAAM,CASR;AA+BD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,cAAc,GACtB,WAAW,CA4Cb"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Fence untrusted dataset text for inclusion in a prompt. The quote delimiter
|
|
8
|
+
* grows until it does not occur in the text, so a row that itself contains
|
|
9
|
+
* `"""` cannot terminate the fence early and smuggle instructions.
|
|
10
|
+
*/
|
|
11
|
+
export declare function fenceText(text: string): string;
|
|
12
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/evals/prompt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI9C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalKind } from "../models";
|
|
7
|
+
import type { DatasetRowRecord, EvalStores } from "../storage";
|
|
8
|
+
import type { ColumnOptions, DatasetContext } from "./types";
|
|
9
|
+
export interface SweepOptions {
|
|
10
|
+
readonly kind: EvalKind;
|
|
11
|
+
readonly dataset: string;
|
|
12
|
+
readonly split: string;
|
|
13
|
+
readonly models: readonly string[];
|
|
14
|
+
readonly columns: ColumnOptions;
|
|
15
|
+
readonly context: DatasetContext;
|
|
16
|
+
readonly onProgress?: ((done: number, total: number, model: string, ok: boolean) => void) | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Run every stored dataset row through the eval workflow for each model,
|
|
20
|
+
* persisting one result row per (run, model, dataset row). Failures are
|
|
21
|
+
* recorded (`ok: 0` + error) rather than aborting the sweep, so one bad model
|
|
22
|
+
* or one bad row never loses the rest of the run.
|
|
23
|
+
*/
|
|
24
|
+
export declare function runSweep(stores: EvalStores, rows: readonly DatasetRowRecord[], options: SweepOptions): Promise<string>;
|
|
25
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/evals/runner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI/D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAe,MAAM,SAAS,CAAC;AAE1E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,UAAU,CAAC,EAClB,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACnF;AAoBD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,SAAS,gBAAgB,EAAE,EACjC,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,CAAC,CAwEjB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { ModelConfig } from "@workglow/ai";
|
|
7
|
+
import type { ColumnOptions, DatasetContext, RowExecutor } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Per-row sentence-similarity workflow: one TextEmbeddingTask embeds both
|
|
10
|
+
* sentences, and cosine similarity of the two vectors is the model's predicted
|
|
11
|
+
* score. Correlation against the dataset's gold score (e.g. STS-Benchmark's
|
|
12
|
+
* 0–5 ratings) is scale-invariant, so no normalization is needed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function makeSimilarityExecutor(model: ModelConfig, options: ColumnOptions, context: DatasetContext): RowExecutor;
|
|
15
|
+
//# sourceMappingURL=similarity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"similarity.d.ts","sourceRoot":"","sources":["../../src/evals/similarity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,cAAc,GACtB,WAAW,CAiCb"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { DatasetRow, LabelNames } from "../hf/types";
|
|
7
|
+
/** What one workflow execution produced for one dataset row. */
|
|
8
|
+
export interface RowPrediction {
|
|
9
|
+
readonly expected?: string | undefined;
|
|
10
|
+
readonly predicted?: string | undefined;
|
|
11
|
+
readonly expectedValue?: number | undefined;
|
|
12
|
+
readonly predictedValue?: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Runs the eval workflow for a single dataset row against one model. */
|
|
15
|
+
export type RowExecutor = (row: DatasetRow) => Promise<RowPrediction>;
|
|
16
|
+
export interface ColumnOptions {
|
|
17
|
+
readonly textColumn: string;
|
|
18
|
+
/** classify: gold label column. */
|
|
19
|
+
readonly labelColumn: string;
|
|
20
|
+
/** classify: candidate labels; defaults to the dataset's ClassLabel names. */
|
|
21
|
+
readonly labels?: readonly string[] | undefined;
|
|
22
|
+
/** similarity: second sentence column. */
|
|
23
|
+
readonly pairColumn: string;
|
|
24
|
+
/** similarity: gold similarity score column. */
|
|
25
|
+
readonly scoreColumn: string;
|
|
26
|
+
/** extract: gold column holding an array of objects (or its JSON string). */
|
|
27
|
+
readonly expectedColumn: string;
|
|
28
|
+
/** extract: field that identifies an entity when aligning rows. */
|
|
29
|
+
readonly keyField: string;
|
|
30
|
+
/** extract: fields to request and score; defaults to keys seen in the gold rows. */
|
|
31
|
+
readonly fields?: readonly string[] | undefined;
|
|
32
|
+
/** extract: task sentence at the top of the prompt. */
|
|
33
|
+
readonly instruction?: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface DatasetContext {
|
|
36
|
+
readonly columns: readonly string[];
|
|
37
|
+
readonly labelNames: LabelNames;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/evals/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,gEAAgE;AAChE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9C;AAED,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;AAEtE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,mCAAmC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAChD,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,oFAAoF;IACpF,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAChD,uDAAuD;IACvD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACjC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** Bearer-token headers for HuggingFace requests (gated/private repos). */
|
|
7
|
+
export declare function hfAuthHeaders(token?: string | undefined): Record<string, string>;
|
|
8
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/hf/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGhF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { FetchDatasetOptions, FetchedDataset } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Fetch rows through the HuggingFace datasets viewer API
|
|
9
|
+
* (`datasets-server.huggingface.co/rows`). Works for any public dataset the
|
|
10
|
+
* viewer has processed and includes `ClassLabel` names so integer label
|
|
11
|
+
* columns can be mapped back to strings.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fetchViaDatasetsServer(options: FetchDatasetOptions): Promise<FetchedDataset>;
|
|
14
|
+
//# sourceMappingURL=datasetsServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasetsServer.d.ts","sourceRoot":"","sources":["../../src/hf/datasetsServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAc,mBAAmB,EAAE,cAAc,EAAc,MAAM,SAAS,CAAC;AAmD3F;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,cAAc,CAAC,CAqCzB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { DatasetRow, FetchDatasetOptions, FetchedDataset, LabelNames } from "./types";
|
|
7
|
+
export interface HubTreeEntry {
|
|
8
|
+
readonly type: "file" | "directory";
|
|
9
|
+
readonly path: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Rank a repo file for a requested split. Data files on the hub conventionally
|
|
13
|
+
* embed the split in the file name (`test-00000-of-00001.parquet`, `test.jsonl.gz`)
|
|
14
|
+
* or live in a split-named directory. Returns undefined when the file cannot
|
|
15
|
+
* belong to the split.
|
|
16
|
+
*/
|
|
17
|
+
export declare function scoreFileForSplit(path: string, split: string): number | undefined;
|
|
18
|
+
/** Pick the data files (shards, sorted) that best match the requested split. */
|
|
19
|
+
export declare function selectSplitFiles(files: readonly string[], split: string): string[];
|
|
20
|
+
/** JSON-safe copy of a row; see {@link sanitizeValue}. */
|
|
21
|
+
export declare function sanitizeRow(row: DatasetRow): DatasetRow;
|
|
22
|
+
export declare function parseJsonLines(text: string): DatasetRow[];
|
|
23
|
+
/**
|
|
24
|
+
* Parse one downloaded dataset file into rows (+ any `ClassLabel` names the
|
|
25
|
+
* parquet footer carries). `limit` bounds how many rows are decoded.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseDatasetFile(path: string, bytes: ArrayBuffer, limit: number): Promise<{
|
|
28
|
+
rows: DatasetRow[];
|
|
29
|
+
labelNames: LabelNames;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Fetch rows by downloading the dataset's data files straight from the hub
|
|
33
|
+
* (`huggingface.co/datasets/<id>/resolve/main/...`). Used when the datasets
|
|
34
|
+
* viewer API is unreachable (e.g. restricted egress). Supports parquet,
|
|
35
|
+
* jsonl(.gz), ndjson, and json(.gz) files.
|
|
36
|
+
*/
|
|
37
|
+
export declare function fetchViaHubFiles(options: FetchDatasetOptions): Promise<FetchedDataset>;
|
|
38
|
+
//# sourceMappingURL=hubFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hubFiles.d.ts","sourceRoot":"","sources":["../../src/hf/hubFiles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI3F,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAaD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASjF;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAalF;AAyBD,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAEvD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAMzD;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC,CAwCzD;AAyBD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CA6B5F"}
|
package/dist/hf/ids.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Validate and re-encode a HuggingFace repo id (`name` or `org/name`) for use
|
|
8
|
+
* in a hub URL. Ids come from CLI flags, so each segment is checked against
|
|
9
|
+
* the hub's id alphabet, dot-only segments are rejected, and the returned
|
|
10
|
+
* value is rebuilt from URL-encoded segments — user input can neither change
|
|
11
|
+
* the request host nor traverse to a different API path.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sanitizeHubRepoId(id: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Validate and re-encode a file path inside a hub repo (e.g. from the repo's
|
|
16
|
+
* tree listing) for use in a `resolve/` download URL. Rejects empty, `.`, and
|
|
17
|
+
* `..` segments and URL-encodes the rest.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sanitizeHubFilePath(path: string): string;
|
|
20
|
+
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/hf/ids.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWxD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalStores } from "../storage";
|
|
7
|
+
import type { FetchDatasetOptions, FetchedDataset } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Fetch dataset rows, preferring the datasets viewer API (typed features,
|
|
10
|
+
* server-side pagination) and falling back to downloading the repo's data
|
|
11
|
+
* files directly when the viewer is unreachable.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fetchDataset(options: FetchDatasetOptions): Promise<FetchedDataset>;
|
|
14
|
+
/**
|
|
15
|
+
* Fetch a dataset split and persist it into tabular storage: one metadata row
|
|
16
|
+
* per (dataset, split) plus one row per example. A plain re-pull replaces the
|
|
17
|
+
* stored split; a pull with `--offset` extends it (only rows from the offset
|
|
18
|
+
* onward are replaced), so a split can be paged in incrementally. The replace
|
|
19
|
+
* runs in a transaction so a failed pull cannot leave the split half-wiped
|
|
20
|
+
* (real rollback on SQLite; best-effort on backends without transactions).
|
|
21
|
+
*/
|
|
22
|
+
export declare function pullDatasetIntoStorage(stores: EvalStores, options: FetchDatasetOptions): Promise<{
|
|
23
|
+
numRows: number;
|
|
24
|
+
source: string;
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=pullDataset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pullDataset.d.ts","sourceRoot":"","sources":["../../src/hf/pullDataset.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEnE;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAUxF;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAmC9C"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** A dataset row as a plain JSON object keyed by column name. */
|
|
7
|
+
export type DatasetRow = Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Integer-coded label columns and their string names, as declared by the
|
|
10
|
+
* dataset (HuggingFace `ClassLabel` features). Keyed by column name.
|
|
11
|
+
*/
|
|
12
|
+
export type LabelNames = Record<string, readonly string[]>;
|
|
13
|
+
export interface FetchedDataset {
|
|
14
|
+
readonly rows: readonly DatasetRow[];
|
|
15
|
+
readonly columns: readonly string[];
|
|
16
|
+
readonly labelNames: LabelNames;
|
|
17
|
+
/** The config the rows came from ("" when unknown, e.g. unfiltered hub files). */
|
|
18
|
+
readonly config: string;
|
|
19
|
+
/** Which fetch path produced the rows. */
|
|
20
|
+
readonly source: "datasets-server" | "hub-files";
|
|
21
|
+
}
|
|
22
|
+
export interface FetchDatasetOptions {
|
|
23
|
+
readonly dataset: string;
|
|
24
|
+
/** Dataset config name; defaults to the first config the server reports. */
|
|
25
|
+
readonly config?: string | undefined;
|
|
26
|
+
readonly split: string;
|
|
27
|
+
/** Maximum number of rows to fetch. */
|
|
28
|
+
readonly limit: number;
|
|
29
|
+
readonly offset?: number | undefined;
|
|
30
|
+
/** HF access token for gated/private datasets (defaults to HF_TOKEN env). */
|
|
31
|
+
readonly token?: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hf/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW,CAAC;CAClD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC"}
|