@epfml/discojs-web 3.0.1-p20250429140233.0 → 3.0.1-p20250701123931.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.
- package/dist/hellaswag.d.ts +8 -0
- package/dist/hellaswag.js +33 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { models } from '@epfml/discojs';
|
|
2
|
+
/**
|
|
3
|
+
* Loads the HellaSwag dataset from the remote URL in the browser
|
|
4
|
+
*
|
|
5
|
+
* @param limit - Maximum number of examples to load (-1 means all)
|
|
6
|
+
* @returns A HellaSwagDataset containing the examples
|
|
7
|
+
*/
|
|
8
|
+
export declare function load(limit?: number): Promise<models.HellaSwagDataset>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { models } from '@epfml/discojs';
|
|
2
|
+
/**
|
|
3
|
+
* Loads the HellaSwag dataset from the remote URL in the browser
|
|
4
|
+
*
|
|
5
|
+
* @param limit - Maximum number of examples to load (-1 means all)
|
|
6
|
+
* @returns A HellaSwagDataset containing the examples
|
|
7
|
+
*/
|
|
8
|
+
export async function load(limit = -1) {
|
|
9
|
+
const response = await fetch(models.HELLASWAG_URL);
|
|
10
|
+
if (!response.ok) {
|
|
11
|
+
throw new Error(`Failed to fetch dataset from ${models.HELLASWAG_URL}: ${response.statusText}`);
|
|
12
|
+
}
|
|
13
|
+
const text = await response.text();
|
|
14
|
+
const lines = text.split('\n');
|
|
15
|
+
const dataset = [];
|
|
16
|
+
let count = 0;
|
|
17
|
+
for (const line of lines) {
|
|
18
|
+
if (line.trim().length === 0)
|
|
19
|
+
continue;
|
|
20
|
+
if (limit !== -1 && count >= limit)
|
|
21
|
+
break;
|
|
22
|
+
try {
|
|
23
|
+
const data = JSON.parse(line.trim());
|
|
24
|
+
dataset.push(data);
|
|
25
|
+
count++;
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
console.error(`Failed to parse line:`, line);
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return dataset;
|
|
33
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED