File size: 961 Bytes
f8d016c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
export function getArg(name: string, def?: string): string | undefined {
  // Check for --name=value format
  const equalFormat = process.argv.find(arg => arg.startsWith(`--${name}=`));
  if (equalFormat) {
    return equalFormat.split('=')[1];
  }

  // Check for --name value format
  const i = process.argv.indexOf(`--${name}`);
  if (i !== -1 && i + 1 < process.argv.length) return process.argv[i + 1];

  return def;
}

export function parseArgs() {
  const modelId = process.argv[2] || "Xenova/distilbert-base-uncased";
  const task = process.argv[3] || "feature-extraction";
  const mode = (getArg("mode", "warm") as "warm" | "cold");
  const repeats = Math.max(1, parseInt(getArg("repeats", "3") || "3", 10));
  const dtype = getArg("dtype"); // optional: fp32, fp16, q8, q4, etc.
  const batchSize = Math.max(1, parseInt(getArg("batch-size", "1") || "1", 10));

  return {
    modelId,
    task,
    mode,
    repeats,
    dtype,
    batchSize,
  };
}