Implementation:Hiyouga LLaMA Factory WebUI Top Component
| Knowledge Sources | |
|---|---|
| Domains | WebUI, Model Configuration, Gradio Components |
| Last Updated | 2026-02-06 19:00 GMT |
Overview
Top-level model selection and configuration panel that serves as the shared header across all WebUI tabs.
Description
The top.py module defines create_top, which builds the global configuration panel at the top of the WebUI. It includes dropdowns for language selection (en, ru, zh, ko, ja), model name (from SUPPORTED_MODELS plus "Custom"), model path textbox, hub selection (HuggingFace, ModelScope, OpenMind with auto-detection of default), finetuning type (from METHODS, default "lora"), checkpoint path (multiselect for PEFT methods), quantization settings (bit/method), template selection (from TEMPLATES), rope scaling mode, and booster option. The component wires extensive change/input events: model selection triggers path and template lookup plus checkpoint listing; finetuning type changes update quantization availability and checkpoint display mode; hub switching updates environment variables and refreshes model info; and all relevant changes persist to user config.
Usage
Use this component as the first element in the WebUI layout. It provides the model and adapter configuration that feeds into all downstream tabs (training, evaluation, inference, export). It is called by create_ui in the interface module.
Code Reference
Source Location
- Repository: Hiyouga_LLaMA_Factory
- File: src/llamafactory/webui/components/top.py
- Lines: 1-82
Signature
def create_top() -> dict[str, "Component"]: ...
Import
from llamafactory.webui.components.top import create_top
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | -- | -- | This function takes no parameters; it reads SUPPORTED_MODELS, METHODS, and TEMPLATES from constants |
Outputs
| Name | Type | Description |
|---|---|---|
| elem_dict | dict[str, Component] | Dictionary of named Gradio components: lang, model_name, model_path, hub_name, finetuning_type, checkpoint_path, quantization_bit, quantization_method, template, rope_scaling, booster |
Usage Examples
# Adding the top panel to the main WebUI
from llamafactory.webui.components.top import create_top
engine.manager.add_elems("top", create_top())
lang = engine.manager.get_elem_by_id("top.lang")
Related Pages
- Hiyouga_LLaMA_Factory_WebUI_Interface - Main interface that calls create_top as the first layout element
- Hiyouga_LLaMA_Factory_WebUI_Control - Provides callback functions (get_model_info, list_checkpoints, can_quantize, switch_hub, check_template) wired to top panel events
- Hiyouga_LLaMA_Factory_WebUI_Common - Provides save_config for persisting user selections
- Hiyouga_LLaMA_Factory_WebUI_Export_Component - Reads checkpoint_path from the top panel for export operations