NetExternalObject
✖
NetExternalObject
Details



- NetExternalObject is typically used to run inference using neural network models not defined in the Wolfram Language.
- Supported file formats are:
-
"ONNX" ONNX models "MXNet" MXNet models "GGUF" GGUF models - For a model with a single input port, NetExternalObject[…][data] gives the result of applying the model to data.
- For a model with multiple input ports, NetExternalObject[…][<port1data1,… >] provides datai to porti.
- When data is given as NumericArray, the output will be a NumericArray. »
- Information[NetExternalObject[…]] generates an information panel about the model. »
- Information of a NetExternalObject may include the following properties:
-
"Backend" the evaluation back end used by the model "ContextWindowSize" current maximum size of the model context windows "InputPortNames" list of names of input ports "InputPorts" association of input port shapes "OutputPortNames" list of names of output ports "OutputPorts" association of output port shapes "Properties" available properties "RawData" unprocessed native contents of the model "TrainingContextWindowSize" original size of the model context windows - NetExternalObject[…][data,opts] specifies that options should be used in applying the net to data. Possible options include:
-
Method Automatic specify details of the model evaluation TargetDevice "CPU" the device on which to perform evaluation - Possible settings for TargetDevice change depending on the system and the hardware and include:
-
"CPU" use the CPU "GPU" use available dedicated hardware "CoreML" Apple CoreML framework "CUDA" Nvidia CUDA API "DirectML" Microsoft Direct Machine Learning API - For a NetExternalObject with LLaMA.cpp backend ("GGUF" format) that generates text, option Method can be set to a list of rules having any of the following keys:
-
"MaxTokens" Automatic maximum number of generated tokens RandomSeeding Automatic what seeding of pseudorandom generators should be done internally "PrependPrompt" False whether to prepend the input to ext to the output text "ResetState" True whether to reset the language model's state before processing the input "StopTokens" {} a list of strings that should stop the generation if produced
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Import an ONNX model as an external network:

https://wolfram.com/xid/0dc2m79gcrde-kvn6hn

Evaluate the model on some input data:

https://wolfram.com/xid/0dc2m79gcrde-gjt1mz

Import a quantized image classifier:

https://wolfram.com/xid/0dc2m79gcrde-digatt

Define a minimal pipeline to pre- and post-process the data:

https://wolfram.com/xid/0dc2m79gcrde-pk8cc2

https://wolfram.com/xid/0dc2m79gcrde-4m1w6f

Scope (5)Survey of the scope of standard use cases
Formats (3)
Import an ONNX model as a NetExternalObject:

https://wolfram.com/xid/0dc2m79gcrde-j8xvci

Import a net in GGUF format (model credit: Olusegun Odewole, https://huggingface.co/segestic/Tinystories-gpt-0.1-3m ):

https://wolfram.com/xid/0dc2m79gcrde-two0nh

Import an MXNet model as a NetExternalObject:

https://wolfram.com/xid/0dc2m79gcrde-9m6p82

Properties (2)
Extract a property of the external net using Information:

https://wolfram.com/xid/0dc2m79gcrde-1mckga


https://wolfram.com/xid/0dc2m79gcrde-7fwug3


https://wolfram.com/xid/0dc2m79gcrde-miq8vx

Get a list of all the supported properties:

https://wolfram.com/xid/0dc2m79gcrde-w7gxq5


https://wolfram.com/xid/0dc2m79gcrde-m49rw1

Options (4)Common values & functionality for each option
Method (2)
Import a text-generating model:

https://wolfram.com/xid/0dc2m79gcrde-5xp07o

Run the model until a termination token is reached:

https://wolfram.com/xid/0dc2m79gcrde-psbl0c

Prepend the prompt to the generated text:

https://wolfram.com/xid/0dc2m79gcrde-um2s1k

Specify a maximum amount of tokens to generate:

https://wolfram.com/xid/0dc2m79gcrde-yo3i3j

Text generation is a random process:

https://wolfram.com/xid/0dc2m79gcrde-vg21uv

https://wolfram.com/xid/0dc2m79gcrde-r51k20

Fix the seed of the pseudorandom generator to get reproducible results:

https://wolfram.com/xid/0dc2m79gcrde-cfnpu8

TargetDevice (2)
Import an ONNX file and run it on the CPU:

https://wolfram.com/xid/0dc2m79gcrde-mdr267


https://wolfram.com/xid/0dc2m79gcrde-1i1fzy


https://wolfram.com/xid/0dc2m79gcrde-cmg72y

Some models will run faster when evaluated on specialized hardware:

https://wolfram.com/xid/0dc2m79gcrde-nhn8l3


https://wolfram.com/xid/0dc2m79gcrde-fsvea


https://wolfram.com/xid/0dc2m79gcrde-vf8x5t

Applications (3)Sample problems that can be solved with this function
Run a real-time face detector:

https://wolfram.com/xid/0dc2m79gcrde-x6a9rn

https://wolfram.com/xid/0dc2m79gcrde-xn5259

Define a transformation from an image to a list of arrays:

https://wolfram.com/xid/0dc2m79gcrde-ppneid

Run the detector on the encoded image:

https://wolfram.com/xid/0dc2m79gcrde-ybqoc0

Extract the bounding box and probability information from the result:

https://wolfram.com/xid/0dc2m79gcrde-nzrkfp
Visualize the detections, filtering the ones with low probability or large overlap:

https://wolfram.com/xid/0dc2m79gcrde-m0p94x

This network can analyze more that 40 images per second on a consumer laptop:

https://wolfram.com/xid/0dc2m79gcrde-ze06zs

Import a text-generating model:

https://wolfram.com/xid/0dc2m79gcrde-h2z6hb

Run the model until a termination token is reached:

https://wolfram.com/xid/0dc2m79gcrde-36vv3m

Import a "GGUF" file as an embedding model:

https://wolfram.com/xid/0dc2m79gcrde-0t2tv1

Generate an embedding vector for each token in a string:

https://wolfram.com/xid/0dc2m79gcrde-89jtxs

Properties & Relations (2)Properties of the function, and connections to other functions
Input given as a NumericArray will cause the output to also be a NumericArray:

https://wolfram.com/xid/0dc2m79gcrde-6tn454


https://wolfram.com/xid/0dc2m79gcrde-nrsli9

External net models typically have a hard-coded batch dimension:

https://wolfram.com/xid/0dc2m79gcrde-g2ycdk


https://wolfram.com/xid/0dc2m79gcrde-5jjp6f

Ordinary networks do not have an explicit batch dimension:

https://wolfram.com/xid/0dc2m79gcrde-yxwp34

They work both on single examples and batches of any size:

https://wolfram.com/xid/0dc2m79gcrde-p1gz81


https://wolfram.com/xid/0dc2m79gcrde-7w3n3s


https://wolfram.com/xid/0dc2m79gcrde-uchwzw

Possible Issues (2)Common pitfalls and unexpected behavior
External models cannot be modified:

https://wolfram.com/xid/0dc2m79gcrde-3oft4q


https://wolfram.com/xid/0dc2m79gcrde-nl5yp6


External models cannot be retrained:

https://wolfram.com/xid/0dc2m79gcrde-5aq730


https://wolfram.com/xid/0dc2m79gcrde-klc21x


Wolfram Research (2022), NetExternalObject, Wolfram Language function, https://reference.wolfram.com/language/ref/NetExternalObject.html (updated 2025).
Text
Wolfram Research (2022), NetExternalObject, Wolfram Language function, https://reference.wolfram.com/language/ref/NetExternalObject.html (updated 2025).
Wolfram Research (2022), NetExternalObject, Wolfram Language function, https://reference.wolfram.com/language/ref/NetExternalObject.html (updated 2025).
CMS
Wolfram Language. 2022. "NetExternalObject." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/NetExternalObject.html.
Wolfram Language. 2022. "NetExternalObject." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/NetExternalObject.html.
APA
Wolfram Language. (2022). NetExternalObject. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetExternalObject.html
Wolfram Language. (2022). NetExternalObject. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetExternalObject.html
BibTeX
@misc{reference.wolfram_2025_netexternalobject, author="Wolfram Research", title="{NetExternalObject}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/NetExternalObject.html}", note=[Accessed: 07-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_netexternalobject, organization={Wolfram Research}, title={NetExternalObject}, year={2025}, url={https://reference.wolfram.com/language/ref/NetExternalObject.html}, note=[Accessed: 07-June-2025
]}