Add the "Test your TFM" synthetic-data tool

#1
by arthurnahmias - opened
Neuralk-AI org

What

  • The Space moves from the static template to a Docker FastAPI server: app.py mounts each tool under tool/ at its own path, and / redirects to /synth_data/.
  • tool/synth_data holds the Test your TFM page. It draws a classification dataset from a random MLP (X ~ N(0, I), tanh layers, y = argmax of the logits), then fits XGBoost, LightGBM or Seldon (seldon-small) on it and ranks them per dataset. The code is tfm_lab/server.py's, served over HTTP instead of MCP.

The Neuralk key

  • Each viewer enters their own key in the page's Neuralk key tab. It stays in the browser tab (sessionStorage), or in the browser (localStorage) if they tick Remember on this device.
  • The page sends it only with a TFM fit, in the X-Neuralk-Key header. The server hands it to SeldonClassifier(api_key=...) for that fit. It never stores or logs the key and never reads NEURALK_API_KEY, so no org key is used by default.
  • A Content-Security-Policy limits the page to its own server: no third-party script, no request anywhere else.

Tested locally

  • Seed 0 reproduces the page's example run exactly (XGBoost 0.776, LightGBM 0.786).
  • End to end in Chrome: the tabs, storing and forgetting the key, the header sent only for the TFM, the CSP, and no console errors.
  • With a fake key, the Neuralk API answers 401, the page says the key was refused, and the key appears in neither the response nor the server log.

Not tested yet

  • A real Seldon fit with a real key.
  • The Docker build, since Docker isn't installed locally. The first build on the Space after the merge will test it.

Run it locally

uv run --with-requirements requirements.txt uvicorn app:app --port 7860

๐Ÿค– Generated with Claude Code

arthurnahmias changed pull request status to open
paulnovello-nk changed pull request status to merged

Sign up or log in to comment