liveBook · Manning

Direct model embedding

As explained in Designing Deep Learning Systems: A guide for software engineers

A model-serving design in which model execution code is integrated with application logic and runs in the same process.

Direct model embedding loads a model and runs prediction inside the user application’s process. Model loading, inference, and application logic remain local, with no communication between processes or remote servers. section 6.2.1

This design fits tightly integrated applications but introduces practical constraints:

  • It can support offline or device-local prediction, such as identifying plants from photos in a mobile application. section 6.2.1
  • Embedding is difficult when application code uses Go, Java, or C# while model code uses Python; PyTorch and TensorFlow provide C++ libraries, and TensorFlow also provides JavaScript and Java libraries. section 6.2.1
  • Large models consume client-device resources and can make applications slower, especially on lower-end hardware. section 6.2.1
  • Mixing serving code with business logic complicates backward compatibility, making this approach relatively uncommon. section 6.2.1

Face-swapping mobile application

A face-swapping app can execute its single deepfake model directly in the application process instead of calling a separate predictor service. The alternative design separates the mobile UI, application backend, and model-serving predictor behind a web API. section 6.3.1

Figure 6.5 In the direct model embedding design, the model is executed in the same process as the application logic.

Use the architecture figure to see model execution colocated with application logic in the same process. section 6.3.1

How Designing Deep Learning Systems: A guide for software engineers covers it

How deep it goes
Defines local execution and implementation trade-offs but treats the strategy briefly rather than detailing deployment internals.
Examples
Uses a flower-identification mobile app and a face-swapping application to illustrate local and alternative serving designs.
What you can do after
Evaluate whether local model execution suits an application’s language, device resources, compatibility needs, and serving use case.
How it connects
Contrasts direct model embedding with model service and model server strategies.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing Deep Learning Systems: A guide for software engineers. The section links point to the parts of the book it draws on.