Open the WaytoAGI knowledge base on Feishu · 100M+ visits, open to everyone →
WaytoAGI

Knowledge Base · Learning paths

Complete Guide to Local LLM Deployment: Build Your Own Agent Workflow with Token Freedom (Beginner-Friendly)

This comprehensive tutorial walks you through the entire process of locally deploying the 124B-parameter Ling-3.0-flash MoE model. From environment setup and vLLM installation to launching the service and running performance tests, this beginner-friendly guide helps you create your own local AI agent workflow and break free from API token limitations.

local LLM deploymentvLLM tutorialrun LLM locallyAI agent workflowLing-3.0-flash

Translated from Chinese by AI. Spotted an issue? Use the feedback button.

🔗 Original source: https://x.com/Lonely__MH/status/208...

This article keeps things as accessible as possible, so even complete beginners can comfortably deploy a model locally and build their own workflow.

China’s open-source large language model (LLM) scene has been buzzing this year. DeepSeek, Qwen, Kimi, GLM, MiniMax… New models keep arriving, more weights are being released, and they’re starting to go toe-to-toe with closed-source models from the US.

But as more models emerge, I find myself increasingly focused on a more specific question: can these models move beyond websites and APIs and actually run on our own machines, connected to local files, tools, and workflows?

Although API prices per token are generally falling, frequent calls and long texts can still rack up substantial costs. Add concerns about privacy, network access, and control over data, and local deployment is becoming the choice for more and more developers and businesses.

So this time, I wanted to pick a model large enough to be a challenge, yet representative of single-machine deployment, and walk through the entire local deployment process.

I ultimately chose Ling-3.0-flash, an open-source mixture-of-experts (MoE) model from Ant Bailing with 124B total parameters. I happened to have an NVIDIA DGX Spark on hand—just what I needed to get it running.

Enough preamble. Let’s get started.

01 The Basics

Before we begin, let’s go over some model-related terminology. Time for a quick primer ✌🏻

Model Precision

The same model often comes in different precision or quantization variants, which directly affect its size and hardware requirements.

For this setup, I’m using Ling’s official INT4 version, which measured approximately 71.75GB in practice.

Dense or MoE

Note that 5.1B refers only to the number of parameters activated during each inference pass. The full 124B parameters’ worth of weights still need to be loaded into memory.

Inference Engine

An inference engine loads model weights, manages context and concurrent requests, and exposes an interface for external access. It is the tool that runs the model, not the model itself.

I chose vLLM because the current official integration supports Ling-3.0-flash’s INT4 weights and MTP speculative decoding.

02 Model Installation and Deployment

First, a quick overview of the setup: I’m using an NVIDIA DGX Spark with a GB10 chip and 121.6GB of unified memory, running Ubuntu 24.04 on ARM64. For this deployment, I’m using Ling-3.0-flash-INT4. In the throughput tests later on, I’ll use Qwen 3.8-27B running on the same machine as a reference.

The official releases include a base version and versions at different precisions, such as FP8, FP4, and INT4. Choose the one that best suits your hardware.

There is also an 8B Ling-3.0-tiny model, available in FP8 and INT4 versions. If you’re using a standard Mac or a single RTX 4090, a lower-precision version of Tiny is a good place to start.

Step 1: Download the model. I’m using the official INT4 version this time. Download links 👇🏻

If accessing Hugging Face is inconvenient, you can also download the files manually from ModelScope. I won’t go into the details here. The download consists of 24 safetensors shards, totaling approximately 71.75GB in my setup. You’ll also need to leave memory available for the inference engine and KV cache at runtime.

Step 2: Set up the environment. Ling-3.0-flash’s BailingMoeV3 architecture is relatively new. I tried using GGUF with llama.cpp, but got the error unknown model architecture: 'bailingmoe3'. So this time, I’m using 👉🏻 the officially adapted vLLM fork directly:

pip install uv
uv venv ~/my_ling_env
source ~/my_ling_env/bin/activate

git clone -b ling_3_0 https://github.com/inclusionAI/vllm-ling-v3.git
cd vllm-ling-v3
VLLM_USE_PRECOMPILED=1 uv pip install --editable . --torch-backend=auto

Step 3: Start the inference service. Replace the model path with the location of your downloaded INT4 weights:

vllm serve /path/to/Ling-3.0-flash-int4 \
  --served-model-name ling-int4 \
  --host 127.0.0.1 \
  --port 30000 \
  --trust-remote-code \
  --max-model-len 16384 \
  --gpu-memory-utilization 0.8 \
  --max-num-seqs 8 \
  --reasoning-parser ling3 \
  --speculative-config '{"method":"bailing_hybrid_v3_mtp","num_speculative_tokens":1}'

⚠️ Replace the relevant paths in the commands with the actual paths on your machine.

Here, the maximum context length is set to 16K and concurrency to 8, with MTP speculative decoding enabled.

Note: MTP (Multi-Token Prediction) lets the model attempt to predict multiple tokens at once. Correct predictions can be accepted directly, reducing the number of computation rounds needed to generate tokens one by one and improving output speed.

Step 4: Verify the service. Once startup is complete, send a simple request:

bash
curl -s http://127.0.0.1:30000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"ling-int4",
       "messages":[{"role":"user","content":"Hello, please introduce yourself in one sentence."}],
       "stream":true}'

If the terminal starts streaming a response, the 124B model is now running locally.


03 Testing Model Performance and Capabilities

  1. Token Throughput

Once the model was up and running, I first ran a standalone benchmark using vLLM’s built-in bench serve command. All 20 requests completed successfully, with an output throughput of 84.34 tok/s, a total token throughput of 133.10 tok/s, and an MTP acceptance rate of 67.35%.

Raw log output👇🏻

============ Serving Benchmark Result ============
Successful requests:                     20        
Failed requests:                         0         
Request rate configured (RPS):           2.00      
Benchmark duration (s):                  60.71     
Total input tokens:                      2960      
Total generated tokens:                  5120      
Request throughput (req/s):              0.33      
Output token throughput (tok/s):         84.34     
Peak output token throughput (tok/s):    61.00     
Peak concurrent requests:                20.00     
Total token throughput (tok/s):          133.10    
---------------Time to First Token----------------
Mean TTFT (ms):                          19692.98  
Median TTFT (ms):                        18877.99  
P99 TTFT (ms):                           40039.02  
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          44.61     
Median TPOT (ms):                        44.09     
P99 TPOT (ms):                           49.68     
---------------Inter-token Latency----------------
Mean ITL (ms):                           74.09     
Median ITL (ms):                         72.39     
P99 ITL (ms):                            280.71    
---------------Speculative Decoding---------------
Acceptance rate (%):                     67.35     
Acceptance length:                       1.67      
Drafts:                                  3051      
Draft tokens:                            3051      
Accepted tokens:                         2055      
Per-position acceptance (%):
  Position 0:                            67.35     
==================================================

Next, I ran concurrency tests on both Ling and the locally hosted Qwen 3.8-27B. With 8 concurrent requests, Ling achieved an aggregate throughput of 141.38 tok/s, compared with 32.61 tok/s for Qwen 3.8—a roughly 4.34× difference in this round.

🔥 🔥 🔥 Ling-3.0-Flash vs Qwen3.8-27B Stress Test Comparison

Ling-3.0-flash

Qwen 3.8 -27B

Some readers may be wondering: why does Ling deliver only 34.77 tok/s with a single concurrent request, yet reach 141.38 tok/s with 8 concurrent requests? More technically minded readers might also ask whether that single-request result is somewhat slow compared with certain official figures.

First, let me explain the exact testing method and how different evaluation methods lead to different speed measurements:

  1. Testing method and the actual end-to-end pipeline: These stress tests used a local OpenAI-compatible endpoint with streaming HTTP requests, rather than offline inference outside a serving framework. Each Ling request used the same long-form prompt of approximately 150 tokens, with a maximum output of 512 tokens. Timing began when the client initiated the HTTP request and ended when it finished receiving the streamed response. This therefore includes the local HTTP call, request scheduling, tokenization, prefill, token-by-token decoding, and streaming delivery.

  2. Single-stream generation speed vs. system-wide aggregate throughput: Single-stream speed (what an individual user actually experiences): At $c=1$, the measurement represents a single user's end-to-end generation rate—approximately 35.34 tok/s, with actual individual conversations measured at 38+ tok/s. That is equivalent to typing more than 35 Chinese characters per second, which already looks exceptionally fast as the text streams onto the screen. Aggregate throughput (total output across concurrent requests): As concurrency increases, vLLM uses Continuous Batching to combine multiple requests into batches for GPU computation, making full use of Blackwell's unified memory bandwidth. With 8 concurrent requests, system-wide aggregate throughput jumps to 141.38 tok/s.

As for why these results differ from some official benchmarks, the key is the testing methodology. Model precision, inference engine, context length, input and output token counts, concurrency level, and whether the test uses offline inference or an HTTP service all affect the final results. Direct comparisons are meaningful only when these conditions are broadly consistent.

Put simply, different evaluation methods produce different speed measurements. Testing at very high concurrency, such as 32 or 64 concurrent requests, or in a compute-only environment without network protocol overhead will produce higher total throughput figures. But for real-world production use, such as everyday one-on-one conversations and coding, Ling's single-stream speed of 35+ tok/s and near-instant time to first token (<220 ms) already make responses feel exceptionally smooth, with no noticeable stuttering.

With a single concurrent request, Ling's average single-stream speed was approximately 35.34 tok/s; with 8 concurrent requests, its system-wide aggregate throughput reached 141.38 tok/s. Qwen3.8 achieved an aggregate throughput of 32.61 tok/s at 8 concurrent requests. In this round of testing, Ling's main advantages were generation speed and concurrent throughput, and its faster responses were clearly noticeable in actual use.


  1. Real-World Capabilities

Benchmarks capture only part of the picture. Whether a model is genuinely useful depends on how it handles specific problems. I chose three areas for a brief evaluation.

(1) Logical reasoning: I prepared a variation on the chickens-and-rabbits-in-a-cage puzzle, the classic car-wash question, and a car-wash-machine question. The main goal was to see whether it could accurately understand the conditions rather than fall back on a familiar-looking answer. For the chickens-and-rabbits puzzle, I also added four three-legged mechanical birds specifically to break the standard pattern.

(2) Safety boundaries: Next, I tested how it responded to high-risk operations: would it execute commands immediately, or first identify the risks, ask the user for confirmation, and suggest safer alternatives?

(3) Long text: Finally, I ran a long-text test. I buried key information in a lengthy context to see whether it could accurately locate that information and answer the questions, while also observing output speed and stability with long inputs.


04 From API to TUI, Then to Tool Calling

With model deployment and capability testing complete, the next step was to make the model easier to use. For most users, curl is better suited to checking whether an API works than to everyday use. For extended conversations with a local model, a more convenient interface is needed.

So I first built a simple TUI—a chat interface that runs in the terminal. It is nothing elaborate: I simply asked AI to write a Python script that wraps local API calls, streaming output, and conversation history saving, then launches with a single command:

python3 ling-3.0-chat.py

This saves me from having to write curl commands every time. I can open the terminal and start chatting, with responses streamed in real time and TPS, TTFT, and token counts displayed alongside them. This is the interface I used for the earlier rounds of capability testing.

At this point, however, the TUI was still just a text-based chat tool, with no ability to call tools. The large language model (LLM) was like a “brain” that could think but had no “hands or feet”: it could not directly read files or execute commands, and it had no awareness of the system’s actual current state.

To let it access system capabilities, I needed to add tool calling. In simple terms, this means wrapping operations such as command execution and file reading and writing as tools. The model first determines what information it needs, then makes a tool-use request. The Python script executes the request and returns the results to the model for further processing.

For example, when I initially asked it to check the system’s GPU information, it had no way of knowing the actual utilization and could only explain how I could check it myself. After adding tool calling, it could execute system commands on its own, organize the results, and display them directly in the TUI.

The same approach can be used to add web search, internal company APIs, database access, and more. You can extend the available tools to suit your business needs.


05 Adding a Graphical Interface

For everyday personal use, a TUI with tool calling is already more than enough. If you want to go a step further and put the model into a more complete AI agent workspace, you can integrate it with an AI agent framework such as Harness.

For this setup, I chose Liang Sheng’s DeepSeek Harness. It does more than add a chat page to the model: it also provides context management, workspaces, tool calling, permission controls, and task planning, along with a built-in browser-based Web UI. Its “everything is a plugin” architecture makes it easy to extend its functionality as needed.

Keep in mind that DeepSeek Harness is still in developer preview and is evolving rapidly, so future updates may introduce breaking changes. There are also many other open-source AI agent frameworks to choose from depending on your needs; I will not cover them individually here.

The integration process is straightforward. The key is to add a custom model provider and point it to the local API served by vLLM. You can configure this directly in the Web UI or edit the configuration file, as illustrated below:

llm-pi-ai:
  providers:
    ling:
      displayName: "Ling-3.0-flash (124B)"
      api: openai-completions
      baseURL: http://127.0.0.1:30000/v1
      apiKeyEnv: OPENAI_API_KEY
      models:
        - id: ling-int4
          name: Ling-3.0-flash (124B MoE)

After starting the Web UI, open the default address in your browser:

http://localhost:3080

You can now handle everyday conversations, conversation history, and model switching directly in DeepSeek Harness. Harness already provides file operations, command execution, and task planning, and can be extended further through plugins. If you are interested in detailed usage instructions or third-party plugins, you can look them up; I will not go into them here.

Note that the tools I wrote for the Python TUI earlier will not carry over automatically. To keep using them in Harness, you will need to integrate them through its plugin system. The screen recording below shows my working Ling integration in action.


06 Building an AI Workflow

At this point, the entire single-model pipeline built around Ling-3.0-flash is in place, from model deployment and the chat interface to tool calling.

In real projects, though, you usually won't rely on just one model. Different models excel at different things, and combining them is often a better approach than asking one model to handle every task.

Ling-3.0-flash's strengths are text processing and fast generation, but it does not natively support multimodal input. If a task involves understanding images or videos, you can bring in a multimodal model such as Qwen3.8-27B. If you also need to generate videos, you can add the recently open-sourced MiniMax H3. Each model handles the part it does best, then passes its results to the next model for further processing.

For example, to build a video generation workflow, you could have Ling interpret the requirements, write a script, and break it down into a storyboard. A multimodal model could then review the reference materials and check visual consistency, before handing everything over to a video model for generation. Once the video is generated, you can run another visual review, revise the prompts based on the results, and regenerate:

Requirements and source materials
→ Ling generates the script and storyboard
→ A multimodal model reviews the materials and visual requirements
→ MiniMax H3 generates the video
→ A multimodal model checks the visuals and continuity
→ Ling adjusts the prompts based on feedback
→ A human performs the final review

The video below is an actual example generated by MiniMax H3 using prompts first created by Ling-3.0-flash.

Once this workflow is established, you can reuse it simply by swapping in new requirements and source materials. However, running multiple large language models (LLMs) locally at the same time requires a substantial amount of GPU memory and RAM. Ling INT4 takes about 72 GB, and Qwen3.8-27B BF16 takes about 51.77 GB. Add the KV cache and the video model, and keeping everything loaded on this Spark becomes very difficult.

Before deploying, make sure you calculate how much GPU memory or unified memory each model needs. If resources are limited, you can load and unload models as needed at each step, choose quantized versions, or distribute the models across multiple devices. Rather than running independently, the models work together on the same task, handing off results from one to the next. That is what makes a multi-model AI workflow truly practical.


07 Final Thoughts

After all this tinkering, we've covered the full pipeline: model deployment, the TUI, tool calling, and a multi-model workflow. The goal of this article is not to share a fixed configuration, but a reusable approach.

Open-source models will continue to evolve. Whether you switch models, quantized versions, or inference engines in the future, the overall process—from downloading weights and starting the service to connecting tools and workflows—will remain largely the same.

If you have the resources, I still recommend deploying a local model yourself:

  1. Control over your data: Files, conversations, and business data can stay on your machine or internal network, and you can set your own restrictions on directory access and command execution.

  2. Well suited to frequent use: You don't have to track token costs for every request, and you can reduce your dependence on the internet and third-party services.

  3. Easy to customize: You can choose and adjust the model, quantization precision, inference engine, and tools, as well as connect internal APIs and databases.

As open-source models become more capable, local deployment will become an increasingly popular choice. You can select a suitable model based on your tasks, hardware, and budget, then build out your tools and workflows. Hopefully, everyone will eventually have their own local AI agent, without having to watch token usage on every call—and enjoy true “token freedom”!


Related Resources


Past Articles

  1. Hermes Agent Hands-On Guide: From Anxious Scrolling on X to Automated Knowledge Capture

  2. A Programmer’s Guide to Preventing Hair Loss

  3. Connecting Hermes to iMessage

  4. Connecting Hermes to X Premium

  5. The Complete Guide to Hermes Agent

  6. A Beginner’s Guide to Hermes Agent: Auxiliary Models

  7. A Beginner’s Guide to Hermes Agent

  8. An Advanced Guide to Hermes Agent

  9. An Incomplete Guide to Hermes Agent

  10. The Complete Guide to Subscribing to Claude Pro in the Nigeria Region

  11. How to Create a Nigeria-Region Apple ID

  12. Subscribe to ChatGPT Plus at Half Price in the Turkey Region

  13. How to Create a US-Region Apple ID

  14. Subscribe to Claude, ChatGPT, and Gemini with Alipay

  15. The Complete Tutorial on Running Large Language Models (LLMs) Locally on a Mac

  16. Checking IP Address Quality

  17. Why Doubao Doesn’t Recommend Your Brand

  18. How to Explain to Your Grandma That What Doubao Says Isn’t True


If you found this helpful, give me a follow, bookmark it, and repost it 👏🏻

Follow @Lonely__MH for regular beginner-friendly tutorials and practical tips for using AI tools.