@epfml/discojs-node 3.0.1-p20260119110456.0 → 3.0.1-p20260126134247.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"hellaswag.d.ts","sourceRoot":"","sources":["../src/hellaswag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CA0BvE"}
1
+ {"version":3,"file":"hellaswag.d.ts","sourceRoot":"","sources":["../src/hellaswag.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AASxC;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAqCvE"}
package/dist/hellaswag.js CHANGED
@@ -1,5 +1,12 @@
1
- import { models } from '@epfml/discojs';
1
+ import path from "node:path";
2
2
  import fetch from 'node-fetch';
3
+ import fs from 'node:fs/promises';
4
+ import { models } from '@epfml/discojs';
5
+ import { dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const DATASET_DIR = path.join(__dirname, "..", "..", "datasets");
9
+ const hellaswag_filepath = path.join(DATASET_DIR, "hellaswag_val.jsonl");
3
10
  /**
4
11
  * Loads the HellaSwag dataset from the remote URL in Node.js
5
12
  *
@@ -7,11 +14,22 @@ import fetch from 'node-fetch';
7
14
  * @returns A HellaSwagDataset containing the examples.
8
15
  */
9
16
  export async function load(limit = -1) {
10
- const response = await fetch(models.HELLASWAG_URL);
11
- if (!response.ok) {
12
- throw new Error(`Failed to fetch dataset from ${models.HELLASWAG_URL}: ${response.statusText}`);
17
+ let text;
18
+ try {
19
+ // Reads the file if it exists locally
20
+ text = (await fs.readFile(hellaswag_filepath)).toString();
21
+ }
22
+ catch {
23
+ console.log("Downloading the Hellaswag benchmark");
24
+ // Otherwise fetch it
25
+ const response = await fetch(models.HELLASWAG_URL);
26
+ if (!response.ok) {
27
+ throw new Error(`Failed to fetch dataset from ${models.HELLASWAG_URL}: ${response.statusText}`);
28
+ }
29
+ text = await response.text();
30
+ // Save the file locally
31
+ await fs.writeFile(hellaswag_filepath, text);
13
32
  }
14
- const text = await response.text();
15
33
  const lines = text.split('\n');
16
34
  const dataset = [];
17
35
  let count = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epfml/discojs-node",
3
- "version": "3.0.1-p20260119110456.0",
3
+ "version": "3.0.1-p20260126134247.0",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "dist/index.d.ts",