umer-wasim commited on
Commit
53e9e4a
·
verified ·
1 Parent(s): 3cf2a5f

Security assistant uses the fine-tuned Devseis model v0.4 (1.5B)

Browse files
app/model-version.json CHANGED
@@ -2,7 +2,7 @@
2
  "version": "v0.3",
3
  "note": "Model version the desktop app and phone check use (Devseis/endpoint-auditor-0.5b-*-MLC tags). Read at start-up, so installed apps follow updates.",
4
  "chat": {
5
- "version": null,
6
  "size": "1.5B",
7
  "note": "Chat model: Devseis/endpoint-auditor-1.5b-*-MLC tag. null = base Qwen2.5-1.5B-Instruct until v0.4 is published."
8
  }
 
2
  "version": "v0.3",
3
  "note": "Model version the desktop app and phone check use (Devseis/endpoint-auditor-0.5b-*-MLC tags). Read at start-up, so installed apps follow updates.",
4
  "chat": {
5
+ "version": "v0.4",
6
  "size": "1.5B",
7
  "note": "Chat model: Devseis/endpoint-auditor-1.5b-*-MLC tag. null = base Qwen2.5-1.5B-Instruct until v0.4 is published."
8
  }
app/package.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "devseis-endpoint-auditor",
3
  "productName": "Devseis Endpoint Auditor",
4
- "version": "0.4.1",
5
  "description": "Read-only endpoint audit for ISO 27001, GDPR and the EU AI Act, with a local AI auditor.",
6
  "author": {
7
  "name": "Devseis",
 
1
  {
2
  "name": "devseis-endpoint-auditor",
3
  "productName": "Devseis Endpoint Auditor",
4
+ "version": "0.4.2",
5
  "description": "Read-only endpoint audit for ISO 27001, GDPR and the EU AI Act, with a local AI auditor.",
6
  "author": {
7
  "name": "Devseis",
mobile/test/webllm-test.cjs CHANGED
@@ -9,7 +9,7 @@ app.whenReady().then(async () => {
9
  win.webContents.on('console-message', e => { if (e.level === 'error') console.log('[page]', e.message); });
10
  const js = code => win.webContents.executeJavaScript(code);
11
  try {
12
- await win.loadURL('http://127.0.0.1:8765/mobile/test/webllm-test.html');
13
  while (!(await js('window.ready === true'))) await new Promise(r => setTimeout(r, 200));
14
  const info = await js(`loadModel(${JSON.stringify(modelUrl)})`);
15
  console.log('loaded', JSON.stringify(info));
@@ -20,13 +20,16 @@ app.whenReady().then(async () => {
20
  let ok = 0;
21
  for (const e of pick) {
22
  const arg = e.meta.task === 'chat' ? JSON.stringify(e.messages.slice(0, -1)) : JSON.stringify(e.messages[1].content);
 
23
  const r = await Promise.race([js(`ask(${JSON.stringify(e.meta.task)}, ${arg}, ${useSchema === 'schema'})`),
24
- new Promise(res => setTimeout(() => res({ seconds: 240, problems: ['timeout after 240 s'], reply: '' }), 240000))]);
 
25
  if (!r.problems.length) ok++;
26
  if (process.env.FULL) console.log('FULL REPLY:', r.reply.length, 'chars\n' + r.reply.slice(-700));
27
  console.log(`${e.meta.task.padEnd(18)} ${String(r.seconds).padStart(3)}s ${r.problems.length ? 'NOT grounded: ' + r.problems.slice(0, 2).join('; ') : 'grounded'} | ${r.reply.replace(/\s+/g, ' ').slice(0, 110)}`);
28
  }
29
  console.log(`RESULT ${ok}/${pick.length} grounded`);
 
30
  } catch (error) { console.log('FAILED', error.message); process.exitCode = 1; }
31
  app.quit();
32
  });
 
9
  win.webContents.on('console-message', e => { if (e.level === 'error') console.log('[page]', e.message); });
10
  const js = code => win.webContents.executeJavaScript(code);
11
  try {
12
+ await win.loadURL('http://127.0.0.1:8765/mobile/test/webllm-test.html' + '?' + (process.env.CTX ? `ctx=${process.env.CTX}&` : '') + (process.env.RESET ? 'reset=1' : ''));
13
  while (!(await js('window.ready === true'))) await new Promise(r => setTimeout(r, 200));
14
  const info = await js(`loadModel(${JSON.stringify(modelUrl)})`);
15
  console.log('loaded', JSON.stringify(info));
 
20
  let ok = 0;
21
  for (const e of pick) {
22
  const arg = e.meta.task === 'chat' ? JSON.stringify(e.messages.slice(0, -1)) : JSON.stringify(e.messages[1].content);
23
+ // One failing case (engine error, timeout) is recorded and the rest still run.
24
  const r = await Promise.race([js(`ask(${JSON.stringify(e.meta.task)}, ${arg}, ${useSchema === 'schema'})`),
25
+ new Promise(res => setTimeout(() => res({ seconds: 240, problems: ['timeout after 240 s'], reply: '' }), 240000))])
26
+ .catch(error => ({ seconds: 0, problems: ['engine error: ' + error.message], reply: '' }));
27
  if (!r.problems.length) ok++;
28
  if (process.env.FULL) console.log('FULL REPLY:', r.reply.length, 'chars\n' + r.reply.slice(-700));
29
  console.log(`${e.meta.task.padEnd(18)} ${String(r.seconds).padStart(3)}s ${r.problems.length ? 'NOT grounded: ' + r.problems.slice(0, 2).join('; ') : 'grounded'} | ${r.reply.replace(/\s+/g, ' ').slice(0, 110)}`);
30
  }
31
  console.log(`RESULT ${ok}/${pick.length} grounded`);
32
+ if (ok < pick.length) process.exitCode = 1;
33
  } catch (error) { console.log('FAILED', error.message); process.exitCode = 1; }
34
  app.quit();
35
  });
mobile/test/webllm-test.html CHANGED
@@ -13,11 +13,15 @@ window.loadModel = async (modelUrl) => {
13
  const base = webllm.prebuiltAppConfig.model_list.find(m => m.model_id === `Qwen2.5-${size}-Instruct-${quant}-MLC`);
14
  const url = modelUrl.replace('{quant}', quant);
15
  const custom = { ...base, model: url, model_id: 'devseis-test-' + quant };
16
- window.engine = await webllm.CreateMLCEngine(custom.model_id, { appConfig: { ...webllm.prebuiltAppConfig, model_list: [custom] } });
 
 
 
17
  return { quant, url };
18
  };
19
  // task 'chat': messages = the full chat messages (system + user); otherwise prompt = report prompt.
20
  window.ask = async (task, prompt, useSchema) => {
 
21
  if (task === 'chat') {
22
  const t0 = performance.now();
23
  const r = await window.engine.chat.completions.create({ messages: prompt, temperature: 0, max_tokens: 700 });
 
13
  const base = webllm.prebuiltAppConfig.model_list.find(m => m.model_id === `Qwen2.5-${size}-Instruct-${quant}-MLC`);
14
  const url = modelUrl.replace('{quant}', quant);
15
  const custom = { ...base, model: url, model_id: 'devseis-test-' + quant };
16
+ // ?ctx=N caps the KV cache (context window); the 1.5B default (32768) breaks after the first answer on some GPUs.
17
+ const ctx = +new URLSearchParams(location.search).get('ctx') || 0;
18
+ window.engine = await webllm.CreateMLCEngine(custom.model_id, { appConfig: { ...webllm.prebuiltAppConfig, model_list: [custom] } },
19
+ ctx ? { context_window_size: ctx } : undefined);
20
  return { quant, url };
21
  };
22
  // task 'chat': messages = the full chat messages (system + user); otherwise prompt = report prompt.
23
  window.ask = async (task, prompt, useSchema) => {
24
+ if (new URLSearchParams(location.search).get('reset')) await window.engine.resetChat();
25
  if (task === 'chat') {
26
  const t0 = performance.now();
27
  const r = await window.engine.chat.completions.create({ messages: prompt, temperature: 0, max_tokens: 700 });
training/eval/base-v0.4.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "base model",
3
+ "data": "training/out-v0.4/test.jsonl",
4
+ "count": 60,
5
+ "seed": 5,
6
+ "tasks": {
7
+ "ai_classification": {
8
+ "n": 4,
9
+ "valid_json": 0.0,
10
+ "grounded": 0.0,
11
+ "fields_match": 0.0
12
+ },
13
+ "chat": {
14
+ "n": 32,
15
+ "valid_json": 1.0,
16
+ "grounded": 0.96875,
17
+ "fields_match": 0.03125
18
+ },
19
+ "finding": {
20
+ "n": 20,
21
+ "valid_json": 0.0,
22
+ "grounded": 0.0,
23
+ "fields_match": 0.0
24
+ },
25
+ "summary": {
26
+ "n": 4,
27
+ "valid_json": 0.0,
28
+ "grounded": 0.0,
29
+ "fields_match": 0.0
30
+ }
31
+ },
32
+ "overall": {
33
+ "valid_json": 0.5333333333333333,
34
+ "grounded": 0.5166666666666667,
35
+ "fields_match": 0.016666666666666666
36
+ }
37
+ }
training/eval/v0.4.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "adapter training/models/auditor-lora-v0.4/final",
3
+ "data": "training/out-v0.4/test.jsonl",
4
+ "count": 60,
5
+ "seed": 5,
6
+ "tasks": {
7
+ "ai_classification": {
8
+ "n": 4,
9
+ "valid_json": 1.0,
10
+ "grounded": 1.0,
11
+ "fields_match": 1.0
12
+ },
13
+ "chat": {
14
+ "n": 32,
15
+ "valid_json": 1.0,
16
+ "grounded": 1.0,
17
+ "fields_match": 0.96875
18
+ },
19
+ "finding": {
20
+ "n": 20,
21
+ "valid_json": 1.0,
22
+ "grounded": 1.0,
23
+ "fields_match": 1.0
24
+ },
25
+ "summary": {
26
+ "n": 4,
27
+ "valid_json": 0.75,
28
+ "grounded": 0.75,
29
+ "fields_match": 0.75
30
+ }
31
+ },
32
+ "overall": {
33
+ "valid_json": 0.9833333333333333,
34
+ "grounded": 0.9833333333333333,
35
+ "fields_match": 0.9666666666666667
36
+ }
37
+ }
training/pipeline-v0.4.sh CHANGED
@@ -35,8 +35,8 @@ if stage webllm_check; then
35
  pgrep -f "http.server 8765" >/dev/null || (python3 -m http.server 8765 --bind 127.0.0.1 >/dev/null 2>&1 &)
36
  ln -sfn ../../mlc/devseis-auditor-1.5b-v0.4-q4f16_1-MLC training/models/mlc-serve/resolve/v0.4-1.5b-q4f16_1
37
  echo "-- WebLLM v0.4 1.5B q4f16_1 (report and chat)"
38
- app/node_modules/.bin/electron mobile/test/webllm-test.cjs "http://127.0.0.1:8765/training/models/mlc-serve/resolve/v0.4-1.5b-q4f16_1/" training/out-v0.4/test.jsonl 10 schema 2>&1 | grep -E "grounded|RESULT|FAILED|loaded"
39
- done_ webllm_check
40
  fi
41
  if stage publish; then
42
  $PY training/publish_model.py --size 1.5b --version v0.4 --dataset-revision v0.4 --merged training/models/devseis-auditor-1.5b-v0.4 \
@@ -46,7 +46,7 @@ fi
46
  if stage dataset; then
47
  TMP=$(mktemp -d); mkdir -p $TMP/data && cp training/out-v0.4/*.jsonl $TMP/data/ &&
48
  hf upload Devseis/endpoint-auditor-synthetic $TMP/data data --repo-type dataset --commit-message "v0.4.0: report tasks + 1,286 grounded chat examples (Devseis Security Assistant)" &&
49
- hf repos tag create Devseis/endpoint-auditor-synthetic v0.4 --repo-type dataset -m "Training data v0.4 (used for model v0.4, 1.5B chat + reports)" ; rm -rf $TMP; done_ dataset
50
  fi
51
  if stage switch_chat; then
52
  $PY - <<'PY' && hf upload Devseis/Arx . . --repo-type space "${EXCL[@]}" --commit-message "Security assistant uses the fine-tuned Devseis model v0.4 (1.5B)" && done_ switch_chat || { echo "== FAILED switch_chat"; exit 1; }
 
35
  pgrep -f "http.server 8765" >/dev/null || (python3 -m http.server 8765 --bind 127.0.0.1 >/dev/null 2>&1 &)
36
  ln -sfn ../../mlc/devseis-auditor-1.5b-v0.4-q4f16_1-MLC training/models/mlc-serve/resolve/v0.4-1.5b-q4f16_1
37
  echo "-- WebLLM v0.4 1.5B q4f16_1 (report and chat)"
38
+ app/node_modules/.bin/electron mobile/test/webllm-test.cjs "http://127.0.0.1:8765/training/models/mlc-serve/resolve/v0.4-1.5b-q4f16_1/" training/out-v0.4/test.jsonl 10 schema 2>&1 | grep -E "grounded|RESULT|FAILED|loaded" &&
39
+ done_ webllm_check || { echo "== FAILED webllm_check"; exit 1; }
40
  fi
41
  if stage publish; then
42
  $PY training/publish_model.py --size 1.5b --version v0.4 --dataset-revision v0.4 --merged training/models/devseis-auditor-1.5b-v0.4 \
 
46
  if stage dataset; then
47
  TMP=$(mktemp -d); mkdir -p $TMP/data && cp training/out-v0.4/*.jsonl $TMP/data/ &&
48
  hf upload Devseis/endpoint-auditor-synthetic $TMP/data data --repo-type dataset --commit-message "v0.4.0: report tasks + 1,286 grounded chat examples (Devseis Security Assistant)" &&
49
+ hf repos tag create Devseis/endpoint-auditor-synthetic v0.4 --repo-type dataset -m "Training data v0.4 (used for model v0.4, 1.5B chat + reports)" && { rm -rf $TMP; done_ dataset; } || { rm -rf $TMP; echo "== FAILED dataset"; exit 1; }
50
  fi
51
  if stage switch_chat; then
52
  $PY - <<'PY' && hf upload Devseis/Arx . . --repo-type space "${EXCL[@]}" --commit-message "Security assistant uses the fine-tuned Devseis model v0.4 (1.5B)" && done_ switch_chat || { echo "== FAILED switch_chat"; exit 1; }