Ai Llm Inference 标志

Ai Llm Inference

社区
vasilyu1983
ai-llm-inference

介绍 LLM 推理模式,涵盖延迟、批处理、缓存、量化、路由和服务技术栈。适用于优化吞吐量、尾延迟或服务成本。

Add to TypingMind

概览

发布者vasilyu1983
代码仓库AI-Agents-public
技能名称ai-llm-inference
星标数
87
复刻数
19
附带文件
41
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 41 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 vasilyu1983 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Ai Llm Inference AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/vasilyu1983/AI-Agents-public/tree/main/frameworks/shared-skills/skills/ai-llm-inference
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/vasilyu1983/AI-Agents-public.git /tmp/AI-Agents-public
mkdir -p .claude/skills
cp -r /tmp/AI-Agents-public/frameworks/shared-skills/skills/ai-llm-inference .claude/skills/ai-llm-inference
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Ai Llm Inference,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Ai Llm Inference。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Ai Llm Inference 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

LLM Inference Production Skill Hub

Operational guidance for choosing and tuning modern inference stacks. Focus on runtime fit, routing, output guarantees, adapter loading, multimodal serving, and measured performance under load.

Use current primary sources for volatile facts such as versions, hardware support, benchmarks, pricing, and release status.

ASCII Flow

text
serving workload
  |
  v
intake
  model + modality + context + QPS + latency SLO + hardware + output contract
  |
  v
serving design
  engine + router + batching + cache + quantization + structured outputs
  |
  v
benchmark
  TTFT + ITL + throughput + error rate + quality floor
  |
  v
production serving path
  capacity plan + rollout + monitoring + rollback thresholds

When to Use This Skill

Use this skill when the user asks for:

  • inference engine selection or stack comparison
  • latency, TTFT, ITL, or throughput optimization
  • cache-aware routing or control-plane design
  • quantization strategy by runtime and hardware
  • multi-GPU or multi-node serving
  • structured outputs or constrained decoding at serve time
  • multimodal or encoder-decoder serving patterns
  • LoRA or multi-adapter serving
  • cost reduction for self-hosted or API inference
  • benchmarking, profiling, or capacity planning
  • CPU or edge deployment with GGUF or llama.cpp, or on-device NPU (per-tensor scales, static shapes)

Scope Boundaries

Quick Reference

DecisionPrimary QuestionDefault Starting PointEscalate When
EngineWhich runtime should execute tokens?vLLM for general text servingNeed stronger KV reuse, multimodal split, or NVIDIA-specific kernels
RouterHow should requests be placed?Simple replica pool firstMultiple replicas, sticky prefixes, multi-LoRA, or mixed workloads
Output controlMust responses obey a schema?Use native structured outputsJSON validity or grammar constraints are part of the SLA
MultimodalIs there a separate encoder path?Keep colocated firstEncoder saturation differs from decode saturation
AdaptersWill many LoRAs or tenants share the base model?Use native multi-LoRA supportCold-load latency or adapter churn affects p95
QuantizationWhich precision is safe in this runtime?Runtime-native FP8 or weight-only pathHardware support or model quality is uncertain
DisaggregationShould prefill/encoder/decode be split?Only after colocated baselineQueueing interference or resource asymmetry is proven

Intake Checklist (Required)

Collect or infer these inputs before recommending changes:

  • model family, size, context length, tokenizer, modality, and adapter usage
  • request contract: streaming, tool use, reasoning mode, schema or grammar constraints
  • prompt and output length distribution, concurrency, QPS, and burst profile
  • prompt reuse patterns: prefix reuse, session reuse, retrieval reuse, LoRA reuse
  • current engine, version, router, autoscaler, and cache settings
  • hardware and topology: GPU SKU, VRAM, interconnect, node count, CPU and RAM
  • SLOs: TTFT, ITL, end-to-end latency, availability, and error budget
  • acceptance criteria: quality floor, JSON validity, long-context accuracy, rollback window

Workflow

  1. Collect the workload shape, runtime contract, hardware, and SLOs before recommending changes.
  2. Route prompt strategy, RAG design, or platform operations to the adjacent skill when inference tuning is not the primary problem.
  3. Choose the serving stack, routing policy, quantization path, and output-control strategy from the decision flow.
  4. Benchmark the baseline, change one lever at a time, and compare throughput, latency, and quality against the acceptance criteria.
  5. Verify volatile engine, hardware, and release facts with the navigation sources before final recommendations.

Decision Flow

text
Need to improve inference:
    |
    |- Is the workload text-only?
    |   |- No -> evaluate multimodal runtime support and encoder separation
    |   `- Yes -> continue
    |
    |- Is schema validity or constrained decoding part of the SLA?
    |   |- Yes -> prefer runtimes with native structured outputs
    |   `- No -> continue
    |
    |- Are there multiple replicas, tenants, or adapters?
    |   |- Yes -> design routing and placement explicitly
    |   `- No -> simple replica pool may be enough
    |
    |- Is there high prefix or session reuse?
    |   |- Yes -> prefer KV-aware routing and native prefix reuse
    |   `- No -> standard load balancing is acceptable
    |
    |- Are long prompts or mixed prompt lengths hurting p95?
    |   |- Yes -> test admission control first, then prefill or encoder disaggregation
    |   `- No -> keep colocated
    |
    |- Is this a MoE model (DeepSeek-V3/V4, Qwen3-MoE, Kimi-K2, Mixtral)?
    |   |- Yes -> assess EP degree, EPLB support, and all-to-all topology
    |   |         see references/moe-expert-parallelism.md
    |   `- No -> continue
    |
    `- Does the model fit latency and cost targets at current precision?
        |- Yes -> keep the simpler stack
        `- No -> walk the lever ladder in order, cheapest and least lossy first:
            1. roofline diagnosis: memory-bandwidth-bound or compute-bound?
               (the answer decides which of the rungs below can help at all)
            2. batching / admission control      (lossless)
            3. KV-cache quantization             (lossy -> eval gate)
            4. speculative decoding              (lossless only with rejection-sampling
                                                    verification; gate Medusa-style)
            5. weight quantization               (lossy -> eval gate)
            6. pruning / distillation            (lossy -> eval gate, retrain cost)
            Each lossy rung gets its own eval gate and rollback window.
            Change one rung at a time; stacking them hides the regression.

Stack Guidance

vLLM

  • Good default for OpenAI-compatible text serving, structured outputs, LoRA serving, and broad quantization support.
  • Strong fit for teams that want one runtime for text inference plus production router patterns.
  • Official docs now expose separate pages for structured outputs, disaggregated prefilling, disaggregated encoder serving, LoRA, and quantization. Treat those features independently instead of assuming one toggle solves all performance issues.
  • Important caveat: disaggregated prefilling is documented as experimental and does not improve throughput by itself; use it only after measuring real queueing or resource contention.

SGLang

  • Strong fit for chat, agents, repeated prefixes, multimodal serving, and adapter-heavy workloads.
  • Current docs emphasize RadixAttention, HiCache, PD and EPD disaggregation, Model Gateway, DP Router, structured outputs for reasoning models, and LoRA serving.
  • Prefer SGLang when prompt reuse, multimodal encoder pressure, or adapter churn is the main bottleneck rather than raw kernel speed alone.

TensorRT-LLM

  • Strong fit for NVIDIA-only deployments where explicit precision control, KV cache reuse, and low-latency GPU execution matter more than portability.
  • Current docs expose precision-specific guidance, KV cache reuse, disaggregated serving, and trtllm-serve.
  • Treat precision recommendations as runtime-scoped: TensorRT-LLM documents more INT8 and low-bit paths than a blanket hardware-only rule suggests.

Router And Control Plane

  • Separate token generation from request placement once you have more than a single box or a single replica.
  • Use routing-and-control-planes.md for cache-aware routing, sticky placement, multi-LoRA request steering, and control-plane selection.
  • vLLM-centric clusters: start with vLLM Router or the vLLM Production Stack.
  • Kubernetes and cache-aware scale-out: evaluate llm-d.
  • SGLang-centric clusters: use Model Gateway or DP Router patterns.
  • Multi-cloud or on-premise data-center environments: consider Dynamo (open-source Apache 2.0, supports AWS EKS, GKE, and NVIDIA hardware; confirmed 2026-05-17 via github.com/ai-dynamo/dynamo).

Quantization Rules

  • Choose quantization inside the runtime you will actually deploy, not from a generic hardware table.
  • On vLLM, prefer the runtime-native path first. Current docs expose FP8, INT4 W4A16, AWQ, GPTQ, and INT8 W8A8, with INT8 W8A8 explicitly excluding Blackwell (compute capability >= 10.0) in vLLM docs — FP8 is the documented Blackwell substitute.
  • On TensorRT-LLM, select from the precision modes the engine documents for that stack: FP8, INT8 SmoothQuant, weight-only INT4 or INT8, GPTQ or AWQ, and NVFP4 for supported Blackwell flows.
  • On SGLang, verify model-specific quantizer support in current docs before committing to FP4, FP8, AWQ, GPTQ, or quantized KV cache.
  • For CPU or edge deployment, use GGUF with llama.cpp and tune quant level, thread count, and n_gpu_layers explicitly.
  • On-device NPU is not CPU/edge: most NPU runtimes want INT8/INT4 with per-tensor scales and static shapes, not group-scaled formats — see the NPU row in references/quantization-patterns.md.
  • After any quantization change, re-run latency, long-context, and structured-output validation before rollout.

Expert Judgment: When Quantization Actually Hurts Quality

  • Quality risk is not evenly distributed across formats. Weight-only formats (AWQ, GPTQ, INT4 W4A16) rarely move task accuracy more than a point or two on general chat/instruct evals, but they degrade disproportionately on: long-context retrieval (needle-in-haystack style tasks), multi-step arithmetic and code, and low-resource languages — test those specifically, not just a generic eval average.
  • W8A8 and other activation-quantized paths carry outlier risk that weight-only paths do not: a small number of hidden-state channels can dominate the error budget (see SmoothQuant calibration in architecture-and-attention-serving.md §6). If the calibration set does not match production traffic, W8A8 can look fine on a benchmark and fail on production long-tail inputs — calibrate on production-representative samples, not generic corpora.
  • KV cache quantization (FP8/INT8 KV) is usually safer than weight quantization for quality, because it compresses an intermediate activation rather than model parameters — but it interacts with speculative decoding and long-context RoPE scaling in ways that are runtime-specific; validate the combination, not each piece alone.
  • Structured-output and tool-call validity are often the first thing to regress under aggressive quantization, before generic quality metrics move — treat schema-valid rate as a leading indicator, not an afterthought.
  • Stacking quantization changes (weight format + KV dtype + speculative decoding) in one rollout makes root-causing a regression nearly impossible. Change one lever, measure, then stack.
  • If quality regresses only on a narrow task class (e.g., code, non-English, long documents) rather than broadly, the fix is usually a mixed-precision or per-layer scheme, not a wholesale rollback to full precision — check whether the runtime supports keeping specific layers or the LM head at higher precision.

Expert Judgment: Batching vs Latency

  • Continuous batching raises throughput almost for free until the GPU crosses from memory-bandwidth-bound to compute-bound decode (see the roofline model in architecture-and-attention-serving.md §3). Below that crossover, adding concurrency barely changes per-token latency — above it, added concurrency directly inflates TTFT and inter-token latency because requests now queue for compute, not just memory bandwidth.
  • The practical tell: if p50 latency is flat while p95/p99 climb as load increases, the batch scheduler is admitting more concurrent sequences than the compute budget supports at the target latency SLO — cap max_num_seqs / concurrent-request limits rather than tuning kernels first.
  • Do not chase throughput by raising batch or concurrency caps without a latency budget attached — throughput-optimal and latency-optimal operating points are different points on the same curve, and the "best" batch size is an SLO decision, not a hardware-maximization decision.
  • Mixed short/long prompt traffic in one queue is the most common cause of p99 collapse that looks like a batching bug but is actually a scheduling/admission-control gap — bucket by prompt-length class or add chunked prefill before concluding the engine is misconfigured.
  • When a stakeholder asks for "lower latency and higher throughput" without a concurrency ceiling, push back: those two goals trade off past the compute-bound crossover, and the SLO (not the engine) has to decide where the line sits.

Expert Judgment: Capacity Planning Heuristics

  • Do not size GPUs from raw parameter count alone. Size from three numbers together: weight memory at the target precision, KV cache memory at the target max-context × max-concurrency, and headroom for activations and framework overhead (roughly 10-20% of the total, verify against your runtime's actual footprint) — KV cache, not weights, is usually the first thing that runs out at real concurrency and long context.
  • Treat "GPUs needed" as a queueing problem, not a peak-throughput division problem: use Little's Law and expected burst behavior (see queueing-theory-applied.md) to size for the tail, not the mean, or the fleet will meet average-load SLOs and fail every burst.
  • A colocated baseline sized correctly beats a disaggregated topology sized on guesswork — get capacity numbers from the simple deployment first, then decide whether splitting phases is what actually buys back headroom.
  • Reserve explicit capacity margin for cold-start and adapter-load events (autoscaling lag, LoRA cold loads, MoE weight loading) — steady-state utilization targets that ignore these events under-provision for real p99 behavior.

Operational Rules

Do

  • Measure TTFT, ITL, end-to-end latency, queueing delay, tokens per second, and schema-valid rate under realistic load.
  • Cap queue depth and concurrency at the API boundary.
  • Keep routing logic explicit once prefix reuse or adapter locality matters.
  • Treat multimodal encoder saturation separately from decode saturation.
  • Log request IDs, model ID, precision, cache hit data, and overload reason.

Avoid

  • Avoid universal claims about the "best" engine without a workload profile.
  • Avoid using stale benchmark ratios as architecture proof.
  • Avoid disaggregation before proving colocated interference.
  • Avoid switching precision without a rollback plan and eval set.
  • Avoid generic round-robin when prefix or adapter locality drives most of the cost.

Known Traps

  • Benchmarking with synthetic prompts that do not match production prefix reuse, output length, schema-validity requirements, or concurrency bursts.
  • Introducing prefill or encoder disaggregation before tightening queue limits, admission control, and placement policy on a colocated baseline.
  • Optimizing only tokens/sec while TTFT, structured-output validity, or long-context quality regresses.
  • Swapping engines or tokenizer stacks without validating compatibility for stop conditions, function/tool contracts, and schema-constrained decoding.
  • Treating quantization as a pure hardware choice instead of a runtime-specific capability with quality and feature caveats.

Common Anti-Patterns

  • Chasing headline benchmark deltas as if they transfer directly to a different workload shape.
  • Using round-robin routing on prefix-heavy or multi-LoRA workloads where locality determines most of the latency and cost.
  • Mixing many prompt-length classes in one queue with no admission-control policy, then blaming the runtime for p95 collapse.
  • Rolling out a new precision or kernel path without a schema-validity suite, long-context checks, and an explicit rollback window.

Accuracy Protocol (Required)

  • Treat benchmark ratios as workload-specific unless you have a current primary source and comparable conditions.
  • State runtime assumptions whenever recommending hardware or precision changes.
  • Mark experimental or beta features explicitly.
  • Prefer official docs and release notes over secondary blogs whenever both exist.

Navigation

Core References

Applied Foundations

  • Queueing Theory Applied - continuous batching, KV-cache sizing, admission control, disaggregation, multi-tenant isolation, and token-budget backpressure — grounded in foundations-queueing-theory primitives (Little's Law, M/M/c, Erlang-C, Kingman, P-K)
  • Reliability Theory Applied - SLO budget allocation across cascaded models, hedged requests, provider failover, cascading-failure prevention, KV-cache corruption rollback, and spec-decode rollback semantics — grounded in foundations-reliability-theory primitives (MTBF/MTTR, error budgets, FTA, redundancy math)

Templates

Scripts

ScriptPurpose
scripts/latency_benchmark.pyIssue N concurrent requests against an OpenAI-compatible /v1/chat/completions endpoint and report p50/p95/p99 latency and throughput. stdlib-only (urllib + threading).

Data

Trend Awareness Protocol

When the user asks for the latest, best, current, recommended, or still-relevant inference tooling:

  • use available browsing or web search
  • prefer official runtime docs, release notes, and vendor docs
  • verify feature status before recommending it
  • report dated assumptions and runtime-specific caveats

Check at least these source types before final recommendations:

  • engine docs for vLLM, SGLang, TensorRT-LLM, or llama.cpp
  • router or control-plane docs when request placement matters
  • vendor precision docs when hardware or quantization is involved
  • current pricing docs when cost decisions depend on managed APIs

Related Skills

Fact-Checking

  • Known bugs, regressions, framework/compiler/runtime footguns, and version-specific crash or workaround guidance must be verified against current primary web sources before being treated as current fact.
  • Verify current external facts, versions, pricing, and hardware support before final answers.
  • Prefer primary sources and include links for volatile recommendations.
  • If browsing is unavailable, label time-sensitive guidance as unverified.

Learnings Loop

Before applying this skill on a non-trivial task, read learnings.consolidated.md in this directory (and learnings.md if present).

After applying it, if you encountered a pattern worth remembering, a mistake worth preventing, or a domain fact that surprised you, append one dated bullet to learnings.md via agents-skills-feedback-loop/scripts/append_learning.py. Do not modify SKILL.md itself.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Ai Llm Inference AI 技能有什么作用?

介绍 LLM 推理模式,涵盖延迟、批处理、缓存、量化、路由和服务技术栈。适用于优化吞吐量、尾延迟或服务成本。

为什么在 TypingMind 中使用 Ai Llm Inference?

因为您只需安装一次,就能搭配任何模型使用。Ai Llm Inference 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Ai Llm Inference?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/vasilyu1983/AI-Agents-public/tree/main/frameworks/shared-skills/skills/ai-llm-inference。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Ai Llm Inference?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Ai Llm Inference 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Ai Llm Inference 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Ai Llm Inference AI 技能免费吗?

是的。vasilyu1983 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇