ALL PROJECTS/NEURL CORTEX

Overview

NEURL Cortex is the serving layer for a trained machine-learning model. It wraps the model behind a Python REST API — entered through run_api.py — so that inference becomes an ordinary HTTP call rather than a notebook exercise. It serves the applications and internal tools that need the model's predictions as structured data they can act on.

Problem

A trained model, on its own, is inert. It lives as a serialised artefact on disk, loadable only by a process that already knows how to find it, how to initialise it, and how to shape input into the tensors it expects. Every downstream consumer that wants a prediction has to reimplement that setup, absorb the model's dependency tree, and pay the cold-start cost of loading weights on every invocation. The result is duplicated glue code, inconsistent preprocessing between callers, and a hard ceiling on how many systems can realistically use the model at all. What was needed was a boundary: one process that owns the model, holds it warm in memory, and publishes a stable contract — request in, structured output out — so that consumers depend on the interface rather than the artefact. That boundary is NEURL Cortex.

System Design

The service is Python-first and deliberately small in surface area. run_api.py at the repository root is the single entry point: it starts the HTTP process, brings the model up, and mounts the routes. Route handlers live under /APIS, keeping transport concerns — request parsing, validation, response shaping — separate from the model code they call into. The model itself ships alongside the service as a packaged artefact (Neurl Model.zip), unpacked at startup rather than fetched at request time, so the weights are resident in the process for the life of the service. The Python dependency set is pinned in requirements.txt; the package.json at the root is a vestigial npm scaffold and carries no build responsibility.

The design point is that the model loads once and serves many. Loading is a startup cost paid on process boot, not a per-request cost paid by every caller, which is what makes on-demand inference viable over HTTP. Around that core, the service treats its outputs as first-class artefacts rather than transient response bodies: an /outputs directory captures generated results on disk, so a prediction can be inspected, re-served, or handed to a downstream job after the originating HTTP request has closed. Structured output is the contract — consumers parse a defined shape, not free-form text, which is what allows other applications to build on the model programmatically.

The repository also carries a Google Cloud service-account key at the root, indicating that the service authenticates outward to a Google Cloud API as part of its work — credentials the process loads on startup and holds for the duration. Operationally, the service is built to run detached and long-lived rather than as an interactive script: service_output.log and service_error.log sit alongside the entry point, splitting normal execution telemetry from failure telemetry into separate streams. That separation is the practical basis for running Cortex as a background service — errors are readable without being buried in inference chatter. A small amount of HTML and CSS accompanies the Python, providing a lightweight rendered surface over the API rather than a full frontend application.

How It Works

01/03
01

Service Startup

The Cortex process boots, loads the packaged model into memory, initialises cloud credentials, and begins listening for inference requests.

  1. 1run_api.py is invoked as the process entry point, typically detached rather than run interactively.
  2. 2The packaged model artefact (Neurl Model.zip) is unpacked and its weights loaded into process memory.
  3. 3Google Cloud service-account credentials are read from the key file at the root and initialised for outbound API calls.
  4. 4Route handlers under /APIS are registered against the HTTP server.
  5. 5Startup telemetry is written to service_output.log; any failure during initialisation lands in service_error.log.
  6. 6The process listens and holds the model warm for the life of the service.
02

Inference Request

A downstream application calls an HTTP endpoint and receives a structured prediction from the already-resident model.

  1. 1A downstream application issues an HTTP request to an inference endpoint exposed by Cortex.
  2. 2The corresponding handler in /APIS parses and validates the incoming payload.
  3. 3The request is shaped into the input form the resident model expects, with no reload and no cold start.
  4. 4The model runs inference against the prepared input.
  5. 5Raw model output is normalised into the service's structured response contract.
  6. 6The structured result is returned over HTTP for the caller to parse programmatically.
03

Output Persistence and Observability

Inference results are written to disk as durable artefacts while execution and failure telemetry are split across separate log streams.

  1. 1As inference completes, the generated result is written into the /outputs directory as a durable artefact.
  2. 2The persisted output remains available after the originating HTTP request has closed.
  3. 3Downstream jobs read results from /outputs rather than re-invoking the model.
  4. 4Successful execution detail is appended to service_output.log.
  5. 5Exceptions and stack traces are routed separately to service_error.log, keeping failure signal clear of routine inference logging.

Key Features

  • Model-serving REST API
  • On-demand inference
  • Structured outputs
  • Python-first architecture

Outcomes

  • The model is callable as a service
  • Reusable across applications

More work

MVP100Hours preview
AI GROWTH PLATFORM

MVP100Hours

An AI-powered lead-to-close platform — silent visitor intelligence to autonomous AI voice outreach

VIEW PROJECT