Implementation:Hiyouga LLaMA Factory WebUI Eval Component
| Knowledge Sources | |
|---|---|
| Domains | WebUI, Evaluation, Gradio Components |
| Last Updated | 2026-02-06 19:00 GMT |
Overview
Gradio evaluation and prediction tab component that provides the UI for configuring and launching model evaluation or prediction tasks.
Description
The eval.py module defines create_eval_tab, which builds the complete evaluation tab layout with Gradio components. It includes dataset directory and selection inputs with an integrated preview box, configuration sliders for cutoff length, max samples, batch size, and a predict checkbox. Generation parameters (max_new_tokens, top_p, temperature) and an output directory textbox are provided for controlling evaluation behavior. The tab includes command preview, start, and stop buttons wired to the engine runner's preview_eval, run_eval, and set_abort methods respectively, plus a progress monitor triggered by a hidden resume checkbox.
Usage
Use this component when assembling the main WebUI to provide evaluation and prediction capabilities. It is instantiated within create_ui in the interface module as the "Evaluate & Predict" tab.
Code Reference
Source Location
- Repository: Hiyouga_LLaMA_Factory
- File: src/llamafactory/webui/components/eval.py
- Lines: 1-94
Signature
def create_eval_tab(engine: "Engine") -> dict[str, "Component"]: ...
Import
from llamafactory.webui.components.eval import create_eval_tab
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| engine | Engine | Yes | The WebUI engine instance providing access to Manager and Runner |
Outputs
| Name | Type | Description |
|---|---|---|
| elem_dict | dict[str, Component] | Dictionary of all named Gradio components: dataset_dir, dataset, data_preview_btn, preview_count, page_index, prev_btn, next_btn, close_btn, preview_samples, cutoff_len, max_samples, batch_size, predict, max_new_tokens, top_p, temperature, output_dir, cmd_preview_btn, start_btn, stop_btn, resume_btn, progress_bar, output_box |
Usage Examples
# Assembling the eval tab within the main UI
from llamafactory.webui.components.eval import create_eval_tab
with gr.Tab("Evaluate & Predict"):
engine.manager.add_elems("eval", create_eval_tab(engine))
Related Pages
- Hiyouga_LLaMA_Factory_WebUI_Interface - Main interface that assembles the eval tab
- Hiyouga_LLaMA_Factory_WebUI_Data_Component - Preview box used within the eval tab
- Hiyouga_LLaMA_Factory_WebUI_Engine - Engine providing the runner for eval execution
- Hiyouga_LLaMA_Factory_WebUI_Control - Provides list_datasets callback for dataset focus event