Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Hiyouga LLaMA Factory WebUI Infer Component

From Leeroopedia
Revision as of 15:07, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Hiyouga_LLaMA_Factory_WebUI_Infer_Component.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains WebUI, Inference, Gradio Components
Last Updated 2026-02-06 19:00 GMT

Overview

Gradio inference tab component that provides model loading/unloading controls and an embedded chat interface for interactive inference.

Description

The infer.py module defines create_infer_tab, which builds the inference tab with backend selection (huggingface, vllm, sglang), dtype dropdown (auto, float16, bfloat16, float32), and an extra arguments textbox. It includes load and unload buttons wired to the engine chatter's load_model and unload_model methods. An embedded chat box (from the chatbot component) is initially hidden and becomes visible once a model is successfully loaded. The multimodal input box visibility is dynamically toggled based on whether the selected model supports multimodal inputs, as determined by is_multimodal from the common module.

Usage

Use this component when assembling the main WebUI to provide real-time inference and chat capabilities. It is instantiated within create_ui in the interface module as the "Chat" tab.

Code Reference

Source Location

Signature

def create_infer_tab(engine: "Engine") -> dict[str, "Component"]: ...

Import

from llamafactory.webui.components.infer import create_infer_tab

I/O Contract

Inputs

Name Type Required Description
engine Engine Yes The WebUI engine instance providing access to Manager and WebChatModel (chatter)

Outputs

Name Type Description
elem_dict dict[str, Component] Dictionary of all named Gradio components: infer_backend, infer_dtype, extra_args, load_btn, unload_btn, info_box, plus all chat box elements (chat_box, role, system, tools, mm_box, image, video, audio, query, submit_btn, max_new_tokens, top_p, temperature, skip_special_tokens, escape_html, enable_thinking, clear_btn)

Usage Examples

# Adding the inference tab to the main UI
from llamafactory.webui.components.infer import create_infer_tab

with gr.Tab("Chat"):
    engine.manager.add_elems("infer", create_infer_tab(engine))

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment