Imagine a hospital that runs its AI model on a GPU it controls. A clinician clicks Draft discharge summary, the app pulls the relevant notes, and a draft comes back for review. The first demo goes exactly as planned.
Then the GPU times out. The gateway retries the request, the queue keeps a failed copy, and an error handler forwards the request body to a monitoring service. The model stayed on the private network. The discharge notes traveled farther than anyone expected.
That hypothetical failure is a useful way to design self-hosted inference. Inference is the work a trained model does when it processes a new input and produces an output.
Self-hosting puts that work on infrastructure you operate, whether it is in your own facility or in your cloud account.
To make the deployment suitable for regulated data, follow the request through the application, the model, and the systems that handle its output and failures.
Start with the smallest version of the discharge workflow. The app checks that the clinician is authorized to open the encounter, fetches the fields needed for the draft, and makes a single inference request.
The draft comes back to the clinician for review. This design gives you a small set of data paths to inspect before adding document search, asynchronous processing, or agent tools.
Draw the same workflow for a timeout. Write down which component retries, whether it keeps the full payload, who can inspect a failed job, and how long the job stays there. Repeat the exercise for a worker restart and a support request.
Where possible, make retries refer to an authorized job ID so each attempt can retrieve the approved inputs from their source.
If a queue needs the payload, give that copy access controls, an expiry policy, and an owner. Retrieval introduces another set of copies. In retrieval-augmented generation, an app searches an index for relevant passages and adds those passages to the model input.
If you add it, filter the search by the caller’s record access and account for chunks, embeddings, and index snapshots in your data inventory. Embeddings are numerical representations of text. Research has demonstrated text recovery from certain embedding models under experimental conditions, so an index deserves its own data classification and review. Text embedding inversion research
Apply the same reasoning to tools. A tool that fetches an authorized encounter and a tool that sends an attachment to an external service make very different data flows possible. Start with a short list of allowed tools and destinations.
Give each tool only the fields it needs and make the application enforce the decision before it makes the call.
When HIPAA applies, identify the permitted use of protected health information and include the inference workflow in the Security Rule risk analysis.
The analysis covers risks to the confidentiality, integrity, and availability of electronic protected health information (ePHI).
It should account for who can access the system, how the team will detect and respond to incidents, and what happens when the service or its storage fails. HHS Security Rule summary
When a cloud provider creates, receives, maintains, or transmits ePHI on behalf of a covered entity or business associate, HHS says the arrangement requires a HIPAA-compliant business associate agreement (BAA).
That can include encrypted backup storage even if the provider lacks the decryption key. Check the services you actually use against your agreement and the provider’s scope.
A cloud account can contain an eligible GPU service alongside a separate monitoring feature whose eligibility still needs review. HHS cloud guidance
Where GDPR applies, document the purpose, the lawful basis under Article 6, and the applicable Article 9 condition for processing health data. Article 28 sets requirements for processors and their contracts.
Article 32 calls for security measures appropriate to the risk. Article 35 calls for a data protection impact assessment (DPIA) before processing likely to result in high risk and expressly includes large-scale processing of health data. GDPR text
Review international transfers at the point of access as well as storage. The European Data Protection Board gives the example of a processor in a third country remotely accessing data held in the EU for support.
Chapter V applies in that example. Ask who can read a production trace or access a support bundle and from which legal entity, alongside where you deploy the database and GPUs. EDPB transfer guidance
Put the model server behind an authenticated gateway. Give the application a service identity, restrict routes to approved callers, and enforce encounter access before retrieval. Keep workers on a private network and limit their outbound connections to destinations the workflow needs.
If your serving engine spans multiple machines, include worker communications in the design. vLLM, for example, documents that its multi-node communications are insecure by default and recommends dedicated network isolation. vLLM security documentation Pick tooling based on the workload you can measure. For a small pilot, one approved model and a single serving endpoint may be enough.
Start by measuring how long typical and unusually long drafts take, how wait times change when several clinicians submit requests together, and how frequently the service needs to retry.
If the app later needs semantic search or reranking, assess that service separately, since it sees different inputs and may write to its own stores. Hugging Face Text Embeddings Inference docs Build an audit trail you can use without routinely exposing clinical text. A restricted audit log might hold the authenticated actor, the action, a protected record reference, the model version, and a timestamp.
Performance dashboards can use a narrower stream with latency, status codes, and aggregate volumes.
Treat identifiers and metadata as sensitive whenever they can be linked back to people. Check default request capture in the gateway, model runtime, and tracing system separately.
Pin the model and runtime versions, review the model’s license and provenance, and keep a record of what changed before you roll out a new version. Evaluate the draft against the job it is meant to do.
In this example, test whether it preserves follow-up instructions, omits important facts, or invents details that a clinician might miss during review. Give the reviewer access to the source notes and a clear way to discard the draft.
Create a synthetic encounter with an unmistakable marker. Run a successful draft, a timeout, a retry, and a worker restart.
Then search the approved systems for the marker. Inspect queue payloads, logs, traces, archived error reports, and the monitoring sinks that receive the app’s events.
Compare each occurrence with the data map. Ask who can retrieve each copy and test the answer with the relevant roles.
Run the reverse test with a clinician who lacks access to the encounter. Confirm the app denies the request before document retrieval or inference. Do it again against any background path so that a delayed retry runs with appropriate authorization even if the caller’s access changes.
Set a clear failure behavior for an overloaded GPU. An external fallback model is a separate processing destination, so review its data handling and contract scope before wiring it in.
Finally, test retention alongside recovery. The source note, the draft, an approved chart entry, a retry copy, and a backup can all have different retention rules.
Document which policy applies to each copy, how exceptions such as a legal obligation are handled, and what happens to previously deleted or expired data when a backup comes back online.
GDPR sets a storage-limitation principle and an erasure right with conditions and exceptions. Put the real retention and restore procedure through a rehearsal. GDPR Articles 5 and 17
Give the rehearsal an owner and an expected result before you run it. For instance, a successful request might leave one short-lived draft and one restricted audit record.
A failed request might leave a job identifier and a status code. Writing down those expectations makes it easier to spot an extra copy than reviewing a long list of services after the fact.
Keep the results with the deployment record. If a copy appears somewhere unexpected, record the path, fix it, and repeat the same test before approving the change.
The record should give the next operator enough detail to reproduce what happened during a service failure.
A hosted service can be suitable when the exact endpoints, enabled features, processor terms, access, and retention fit the workflow. Review the contract scope for each feature the application calls.
For example, a text endpoint and a background file-processing feature may be governed differently. Self-hosting gives you more direct control over model releases and traffic paths while assigning your team more of the work of patching, capacity planning, recovery, and incident response. HIPAA and GDPR allow for third-party processing when applicable requirements are met. HHS on cloud services · GDPR Article 28
Compare both options using realistic peak traffic, acceptable queue times, the quality of drafts after clinician review, and the staffing needed to keep the service running.
A pilot can show whether a smaller model meets the quality bar or whether a particular feature would add an unnecessary processor. The result gives the team a reason to choose a deployment it can afford to maintain.
Before the first real patient record goes through, ask the team to walk through one failed request.
They should be able to show which system held the payload, who could open it, and when it expired.
HIPAA & GDPR-Compliant AI: The Guide to Self-Hosting Inference was originally published in Stackademic on Medium, where people are continuing the conversation by highlighting and responding to this story.