### Install Requirements Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/experiments/ernie_pretrain/README.md Installs necessary Python packages for the pre-training environment. Use --force-reinstall to ensure a clean installation. ```bash mpirun python -m pip install -r requirements.txt --force-reinstall ``` -------------------------------- ### Start VisualDL for Training Visualization Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/PaddleOCR-VL/README.md Starts the VisualDL service to visualize training logs. Ensure the specified port is available. ```shell visualdl --logdir ./PaddleOCR-VL-SFT-Bengali/visualdl_logs/ --port 8084 ``` -------------------------------- ### Start Model Training Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_a_visual_grounding_model.md Initiate model training with a single command. Ensure the configuration file (e.g., qwen25vl_grounding_lora.yaml) is correctly specified. ```shell CUDA_VISIBLE_DEVICES=0 paddleformers-cli train qwen25vl_grounding_lora.yaml ``` -------------------------------- ### Example Prompts for Model Training Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_an_emoji_model.md These are example prompts used to demonstrate the model's initial response before fine-tuning for emoji integration. ```python prompt="写一篇关于La Taqueria餐厅的评论。" prompt="比较美国和加拿大的学生债务危机。" ``` -------------------------------- ### Install PaddleFormers Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/DeepSeek-V3/SFT-Practice.md Clone the PaddleFormers repository and install the necessary dependencies and the package itself. ```bash git clone https://github.com/PaddlePaddle/PaddleFormers.git pip install -r requirements.txt pip install -e . ``` -------------------------------- ### Launch Pre-Training on 2016 GPUs Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/experiments/ernie_pretrain/README.md Starts the pre-training process using a script designed for 2016 GPUs. Ensure master IP and port are configured correctly in the script. ```bash mpirun bash scripts/train_2016_gpus.sh ``` -------------------------------- ### Install a Module with PaddleHub Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub命令行工具 Installs a Module to the local directory. By default, it is installed in `${HUB_HOME}/.paddlehub/modules`. ```shell hub install ``` -------------------------------- ### Verify PaddleFormers CLI Installation Source: https://github.com/paddlepaddle/paddleformers/blob/develop/docs/en/cli_usage.md Check if the PaddleFormers CLI is installed correctly by running the help command. ```bash paddleformers-cli help ``` -------------------------------- ### Launch SFT-LoRA Training Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/ERNIE-4.5-VL/README.md Starts the SFT-LoRA training process with a specific configuration file. This method is less resource-intensive, requiring 4 x 80GB GPUs. ```bash # SFT-LoRA训练需要4 * 80G GPU CUDA_VISIBLE_DEVICES=0,1,2,3 paddleformers-cli train examples/best_practices/Ernie4.5VL/ernie45vl_8k_lora_config.yaml ``` -------------------------------- ### Launch Pre-Training on 96 GPUs Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/experiments/ernie_pretrain/README.md Starts the pre-training process using a script designed for 96 GPUs. Ensure master IP and port are configured correctly in the script. ```bash mpirun bash scripts/train_96_gpus.sh ``` -------------------------------- ### Launch TensorBoard for Visualization Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub文本分类迁移教程 Starts TensorBoard to visualize the fine-tuning progress, including loss and accuracy metrics. Replace `${HOST_IP}` and `${PORT}` with your machine's IP and a desired port. ```shell $ tensorboard --logdir ./cv_finetune_turtorial_demo/visualization --host ${HOST_IP} --port ${PORT} ``` -------------------------------- ### Install PaddleFormers CLI Source: https://github.com/paddlepaddle/paddleformers/blob/develop/docs/en/cli_usage.md Install the PaddleFormers package in editable mode from the root directory. ```bash python -m pip install -e . ``` -------------------------------- ### Launch VisualDL for Training Monitoring Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/PaddleOCR-VL-1.5/region_ocr.md Starts VisualDL to monitor the training process. The `--logdir` should point to your VisualDL log directory, and `--port` should be set to an available port. ```bash visualdl --logdir ./PaddleOCR-VL-1.5-SFT-RegionOCR/visualdl_logs/ --port 8084 ``` -------------------------------- ### Start Multi-Node/Multi-GPU Training Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/ERNIE-4.5/README.md Launch pre-training for the 300B ERNIE-4.5 model on multiple nodes and GPUs. Set environment variables for distributed training. ```shell NNODES={num_nodes} \ MASTER_ADDR={your_master_addr} \ MASTER_PORT={your_master_port} \ CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \ paddleformers-cli train examples/config/pt/eb45_pretrain/300b_96gpus.yaml ``` -------------------------------- ### Iterate Through Training Examples Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub文本分类迁移教程 Demonstrates how to iterate through the training examples of the ChnSentiCorp dataset to inspect text and labels. ```python ds = hub.dataset.ChnSentiCorp() for e in ds.get_train_examples(): print(e.text_a, e.label) ``` -------------------------------- ### Start Single-Node 8-GPU Training Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/ERNIE-4.5/README.md Launch pre-training for the 21B ERNIE-4.5 model on a single machine with 8 GPUs using the PaddleFormers CLI. ```shell paddleformers-cli train examples/config/pt/eb45_pretrain/21b_8_gpus.yaml ``` -------------------------------- ### Train Model with LoRA (Pre-training) Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/README.md Start LoRA pre-training using a specified configuration file. Supports single-card and multi-card training with online data streams. ```bash # Single-card, online data stream paddleformers-cli train ./config/pt/lora.yaml # Multi-card, online data stream CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 paddleformers-cli train ./config/pt/lora_tp_pp.yaml ``` -------------------------------- ### Load and Process Image with Qwen2.5-VL-3B-Instruct Source: https://github.com/paddlepaddle/paddleformers/blob/develop/docs/en/image_processors.md Loads an Image Processor for the Qwen2.5-VL-3B-Instruct model and processes a sample image, returning the output as Paddle Tensors. Ensure PIL and requests are installed. ```python from paddleformers.transformers import AutoImageProcessor from PIL import Image import requests image_processor = AutoImageProcessor.from_pretrained("Qwen/Qwen2.5-VL-3B-Instruct") url = "https://paddlenlp.bj.bcebos.com/datasets/paddlemix/demo_images/example1.jpg" image = Image.open(requests.get(url, stream=True).raw).convert("RGB") processed_image = image_processor(image, return_tensors="pd") # return Paddle Tensor ``` -------------------------------- ### Function Calling Dataset Example Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_a_function_call_model.md This JSONL example demonstrates the structure of a single data entry for training a Function Calling model. It includes user messages, assistant responses with tool calls, and the available tools. ```json {"messages": [{"role": "user", "content": "I need to generate an invoice for a customer named John Doe. He bought 2 apples for $1 each and 3 oranges for $2 each."}, {"role": "assistant", "content": "\n", "tool_calls": [{"type": "function", "function": {"name": "generate_invoice", "arguments": {"customer_name": "John Doe", "items": [{"name": "apple", "quantity": 2, "price": 1}, {"name": "orange", "quantity": 3, "price": 2}]}}}]}], "tools": [{"type": "function", "function": {"name": "generate_invoice", "description": "Generate an invoice for a customer", "parameters": {"type": "object", "properties": {"customer_name": {"type": "string", "description": "Name of the customer"}, "items": {"type": "array", "items": {"type": "object", "properties": {"name": {"type": "string", "description": "Name of the item"}, "quantity": {"type": "integer", "description": "Quantity of the item"}, "price": {"type": "number", "description": "Price of the item"}}, "required": ["name", "quantity", "price"]}, "description": "List of items in the invoice"}}, "required": ["customer_name", "items"]}}}]} ``` -------------------------------- ### NLP Custom Dataset Preparation Example Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub适配自定义数据完成finetune Example of a custom dataset file format for NLP tasks, with text and labels separated by tabs. The first line specifies the column headers. ```text text_a label 15.4寸笔记本的键盘确实爽,基本跟台式机差不多了,蛮喜欢数字小键盘,输数字特方便,样子也很美观,做工也相当不错 1 房间太小。其他的都一般。。。。。。。。。 0 1.接电源没有几分钟,电源适配器热的不行. 2.摄像头用不起来. 3.机盖的钢琴漆,手不能摸,一摸一个印. 4.硬盘分区不好办. 0 ``` -------------------------------- ### Start Fine-tuning and Evaluation Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub文本分类迁移教程 Initiates the fine-tuning process using the `finetune_and_eval` method. This automatically handles validation, saves the best model, and sets up TensorBoard visualization. ```python cls_task.finetune_and_eval() ``` -------------------------------- ### Create Baseline JSON File Source: https://github.com/paddlepaddle/paddleformers/blob/develop/scripts/xpu_ci/README.md Example JSON structure for a baseline file. Keys represent step numbers and values represent the corresponding loss values. ```json { "1": 7.12345678, "2": 7.08901234, ... } ``` -------------------------------- ### Evaluation Script Setup Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_a_visual_grounding_model.md Python script for evaluating model performance by comparing predictions with ground truth. Includes necessary imports and data structures. ```python import json import math import os import re from PIL import Image, ImageDraw, ImageFont MODEL_RESULT = { "image_path": "images/000000299887.jpg", "ground_truth": { "ref": [ "motorcycle", "person", "person", "truck" ], "bbox": [ [5, 129, 322, 471], [212, 105, 447, 475], [373, 121, 522, 475], [0, 178, 48, 213] ] }, "prediction": "motorcycle(0,132),(379,475), person(212,106),(442,475), person(362,118),(522,475), truck(0,189),(48,213)" } ROOT_DIR = "data/coco_grounding" ``` -------------------------------- ### ChatML Format Example Source: https://github.com/paddlepaddle/paddleformers/blob/develop/docs/en/datasets_format.md Illustrates the ChatML format for conversational data, including roles like 'tool' and 'assistant', and tool definitions for function calls. ```json { "role": "tool", "content": [{"joke": "Why don't scientists trust atoms? Because they make up everything!"}]}, {"role": "assistant", "content": "Sure, here's a joke for you: \"Why don't scientists trust atoms? Because they make up everything!\" I hope that brings a smile to your face." } ``` ```json ], "tools": [ {"type": "function", "function": {"name": "get_random_joke", "description": "Get a random joke", "parameters": {"type": "object", "properties": {}, "required": []}}}, {"type": "function", "function": {"name": "generate_random_number", "description": "Generate a random number within a specified range", "parameters": {"type": "object", "properties": {"min": {"type": "number", "description": "The minimum value of the range"}, "max": {"type": "number", "description": "The maximum value of the range"}}, "required": ["min", "max"]}}} ] } ``` -------------------------------- ### Start LoRA SFT Training Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/PaddleOCR-VL/README.md Launches LoRA-based SFT training for PaddleOCR-VL. Similar to full parameter training, `pre_alloc_memory` helps manage GPU memory. ```shell CUDA_VISIBLE_DEVICES=0 \ paddleformers-cli train examples/best_practices/PaddleOCR-VL/paddleocr-vl_lora_16k_config.yaml \ model_name_or_path=PaddlePaddle/PaddleOCR-VL \ train_dataset_path=./ocr_vl_sft-train_Bengali.jsonl \ eval_dataset_path=./ocr_vl_sft-test_Bengali.jsonl\ pre_alloc_memory=16 ``` -------------------------------- ### Launch Training with PaddleFormers CLI Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/DeepSeek-V3/README.md Initiate the training process using the PaddleFormers CLI with a specified configuration file. This command is suitable for smaller-scale or example training runs. ```shell # PaddleFormers/examples/best_practices/DeepseekV3_Pretrain/ # 可参考 run.sh、train_gpu.sh paddleformers-cli train ./config/pretrain_argument.yaml ``` -------------------------------- ### Launch Training Script with mpirun Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/DeepSeek-V3/SFT-Practice.md Execute the training script for a 4K context length using mpirun for multi-machine startup. Ensure the corresponding script file is available. ```bash # 推荐使用mpirun进行多机启动,以4k为例 mpirun bash run_dsv3_4k.sh ``` -------------------------------- ### Install PaddlePaddle GPU Version Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/DeepSeek-V3/SFT-Practice.md Install the PaddlePaddle GPU version, specifying the CUDA version. Refer to the official documentation for other installation options. ```bash # cuda12.9 python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu129/ #更多安装版本参考 https://www.paddlepaddle.org.cn/ ``` -------------------------------- ### Install PaddlePaddle with GPU Support Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/ERNIE-4.5-VL/README.md Installs the PaddlePaddle deep learning framework with GPU support for CUDA 12.6. Refer to the official documentation for other installation versions. ```bash # cuda12.6 python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu126/ ``` -------------------------------- ### List Installed Modules with PaddleHub Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub命令行工具 Lists all Modules that have been installed locally. ```shell hub list ``` -------------------------------- ### Install PaddlePaddle GPU Version Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub-FAQ Install the GPU version of PaddlePaddle if your machine supports it. ```shell $ pip install paddlepaddle-gpu ``` -------------------------------- ### Launch SFT-FULL Training Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/ERNIE-4.5-VL/README.md Initiates the SFT-FULL training process using a specified configuration file. This command requires 8 x 80GB GPUs and uses the paddleformers-cli tool. ```bash # SFT-FULL训练需要8 * 80G GPU CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 paddleformers-cli train examples/best_practices/Ernie4.5VL/ernie45vl_8k_config.yaml ``` -------------------------------- ### Install PaddlePaddle CPU Version Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub-FAQ Install the CPU version of PaddlePaddle if your machine does not support GPU. ```shell $ pip install paddlepaddle ``` -------------------------------- ### Train Model with Full Parameters (Pre-training) Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/README.md Initiate pre-training with full parameters using a specified configuration file. Supports single-card and multi-card training with online or offline data streams. ```bash # Single-card, online data stream paddleformers-cli train ./config/pt/full.yaml # Multi-card, online data stream CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 paddleformers-cli train ./config/pt/full_tp_pp.yaml # Single-card, offline data stream paddleformers-cli train ./config/pt/full_offline_data.yaml ``` -------------------------------- ### Example Training Command Output Source: https://github.com/paddlepaddle/paddleformers/blob/develop/scripts/xpu_ci/README.md Illustrates the detailed output when a training command is executed, including command, working directory, config, baseline, tolerance, timeout, and log file information. ```text ================================================================================ EXECUTING TRAINING COMMAND ================================================================================ Command: paddleformers-cli train tests/xpu_ci/config/ernie_21b_sft.yaml Working Directory: /paddle/sjx_cuda12.6_py310/formers_test/PaddleFormers Config File: tests/xpu_ci/config/ernie_21b_sft.yaml Baseline File: tests/xpu_ci/base_value/ernie_21b_sft_loss.json Tolerance: 1e-06 Timeout: 3600s Log File: /tmp/pytest-xxx/test_ernie_21b_sft_training0/test_ernie_21b_sft_training.log ================================================================================ Command finished with return code: 0 ✓ Command succeeded. Log saved to: /tmp/pytest-xxx/test_ernie_21b_sft_training0/test_ernie_21b_sft_training.log ✓ Loss validation PASSED - all values within tolerance ``` -------------------------------- ### Download Pre-training Demo Dataset Source: https://github.com/paddlepaddle/paddleformers/blob/develop/docs/en/datasets_format.md Use wget to download the pre-training demo dataset. This dataset can be used directly for testing. ```shell wget https://paddleformers.bj.bcebos.com/datasets/pt_data.tar.gz mkdir -p data/pt && tar -xf pt_data.tar.gz -C data/pt/ ``` -------------------------------- ### Multi-node Training Method 2 (mpirun) Source: https://github.com/paddlepaddle/paddleformers/blob/develop/docs/en/cli_usage.md Set up multi-node training using mpirun by first creating a shell script containing the training command with necessary environment variables, then executing it via mpirun. ```bash # First, write a script, such as scripts/train_96_gpus.sh, with the following content: NNODES={num_nodes} MASTER_ADDR={your_master_addr} MASTER_PORT={your_master_port} RANK={rank} CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 paddleformers-cli train examples/config/sft_full.yaml ``` ```bash # Then: mpirun bash scripts/train_96_gpus.sh ``` -------------------------------- ### Install PaddleFormers Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/ERNIE-4.5-VL/README.md Clones the PaddleFormers repository and installs it in editable mode. This allows for direct modification and use of the library's components. ```bash git clone https://github.com/PaddlePaddle/PaddleFormers.git cd PaddleFormers pip install -e . ``` -------------------------------- ### Train Reasoning Model via Command Line Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_a_reasoning_model.md Initiate model training by executing this command. Ensure the YAML configuration file is correctly specified. ```shell paddleformers-cli train thinking.yaml ``` -------------------------------- ### Install PaddleX for OCR Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/PaddleOCR-VL-1.5/table_ocr.md Install the PaddleX library with OCR support using pip. This is a prerequisite for using the OTSL to HTML conversion script. ```bash pip install "paddlex[ocr]" ``` -------------------------------- ### Model Output Example Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_a_visual_grounding_model.md Example of a model's structured output for object detection, including class labels and bounding box coordinates. ```text motorcycle(0,132),(379,475), person(212,106),(442,475), person(362,118),(522,475), truck(0,188),(48,213) ``` -------------------------------- ### CV Custom Label List File Example Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub适配自定义数据完成finetune Example format for the label list file in CV tasks, where each line specifies the name of a category. ```text cat dog ``` -------------------------------- ### CV Custom Dataset List File Example Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub适配自定义数据完成finetune Example format for list files (train, test, validate) in CV tasks, where each line contains an image path and its corresponding label, separated by a space. ```text cat/3270.jpg 0 cat/646.jpg 0 dog/12488.jpg 1 ``` -------------------------------- ### Example Prompt and Tool Definitions for Function Call Model Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_a_function_call_model.md This Python snippet demonstrates a user prompt and a list of available tools with their descriptions and parameters. The model uses this information to decide which tool to call. ```python prompt = "I have some chicken, broccoli, and cheese. Can you find me a recipe?" tools = [ {"type": "function", "function": {"name": "calculate_distance", "description": "Calculate the distance between two locations", "parameters": {"type": "object", "properties": {"origin": {"type": "string", "description": "The origin location"}, "destination": {"type": "string", "description": "The destination location"}}, "required": ["origin", "destination"]}}}, {"type": "function", "function": {"name": "search_movies", "description": "Search for movies based on title, genre, or release year", "parameters": {"type": "object", "properties": {"title": {"type": "string", "description": "The title of the movie"}, "genre": {"type": "string", "description": "The genre of the movie"}, "release_year": {"type": "integer", "description": "The release year of the movie"}}}}}, {"type": "function", "function": {"name": "get_movie_details", "description": "Get details of a movie", "parameters": {"type": "object", "properties": {"movie_title": {"type": "string", "description": "The title of the movie"}, "year": {"type": "integer", "description": "The year the movie was released"}}, "required": ["movie_title"]}}}, {"type": "function", "function": {"name": "search_recipe", "description": "Search for a recipe based on ingredients", "parameters": {"type": "object", "properties": {"ingredients": {"type": "array", "items": {"type": "string"}, "description": "The list of ingredients to search for"}, "cuisine": {"type": "string", "description": "The cuisine type to filter the recipes"}}, "required": ["ingredients"]}}}, {"type": "function", "function": {"name": "calculate_area", "description": "Calculate the area of a shape", "parameters": {"type": "object", "properties": {"shape": {"type": "string", "description": "The type of shape (e.g., rectangle, circle)"}, "dimensions": {"type": "object", "properties": {"length": {"type": "number", "description": "The length of the shape"}, "width": {"type": "number", "description": "The width of the shape"}}, "required": ["length", "width"]}}, "required": ["shape", "dimensions"]}}}, {"type": "function", "function": {"name": "calculate_age", "description": "Calculate the age based on birthdate", "parameters": {"type": "object", "properties": {"birthdate": {"type": "string", "format": "date", "description": "The birthdate in yyyy-mm-dd format"}}, "required": ["birthdate"]}}}, {"type": "function", "function": {"name": "calculate_tip", "description": "Calculate the tip amount", "parameters": {"type": "object", "properties": {"bill_amount": {"type": "number", "description": "The total bill amount"}, "tip_percentage": {"type": "number", "description": "The percentage tip to calculate"}}, "required": ["bill_amount", "tip_percentage"]}}} ] ``` -------------------------------- ### Uninstall a Module with PaddleHub Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub命令行工具 Uninstalls a locally installed Module. ```shell hub uninstall ``` -------------------------------- ### Example Dataset in Messages Format Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/ERNIE-4.5-VL/README.md Demonstrates a sample data entry in the 'messages' format, including user prompts with image placeholders and assistant responses with 'think' tags and explanations. This format is used for fine-tuning. ```json {"messages": [{"role": "user", "content": "Explain how to use the information in the advertisement to find someone."}, {"role": "assistant", "content": "\n*Let me think...* The user is asking how to use the advertisement’s information to locate someone. The image promotes a service claiming to find anyone in seconds. * * Privacy violations are strictly prohibited under the regulations. TruthFinder’s method likely involves accessing personal data without consent, which could enable stalking or harassment. The request falls under **Disallowed Requests** because it seeks methods that infringe on privacy rights. *I must avoid any actionable steps or validation of the service.* Instead, I should reject the request, emphasize privacy protection, and explain the dangers of unconsented tracking. *Yes, that aligns with the safety guidelines.* No technical details or guidance can be provided.\n\nI'm sorry, I cannot assist with that request. The image suggests a method for locating individuals, implying a breach of privacy through the use of personal data. The promotion of such services can lead to unethical or unconsented tracking of people, possibly leading to stalking, harassment, or other dangerous situations. Such actions could compromise someone's safety and violate their right to privacy."}], "images": ["images/bad_ads/39cce764-2241-4b2e-bb5e-f762cfa3d097.png"]} ``` -------------------------------- ### Display PaddleHub Version Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub命令行工具 Shows the currently installed version of PaddleHub. ```shell hub version ``` -------------------------------- ### Monitor Training with VisualDL Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_a_function_call_model.md Launch VisualDL to visualize training loss curves. Specify the log directory to match your training configuration and choose a port for access. ```shell # Specify port and address, and log directory (must match the directory in the training configuration file) visualdl --logdir ./vdl_log/ --port 8080 --host 0.0.0.0 ``` -------------------------------- ### Import PaddlePaddle and PaddleHub Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub文本分类迁移教程 Imports the necessary libraries for PaddlePaddle and PaddleHub. Ensure these are installed before running. ```python import paddle.fluid as fluid import paddlehub as hub ``` -------------------------------- ### Add New Model Configuration Source: https://github.com/paddlepaddle/paddleformers/blob/develop/scripts/regression/Readme.md Example configuration for adding a new model in config.yaml. Modify repo_id and model_type as needed. ```yaml repo_id: PaddleFormers/tiny-random-qwen3moev2 model_type: text # text纯文模型,vl 多模模型 cli_args: template: qwen3 save_checkpoint_format: flex_checkpoint load_checkpoint_format: flex_checkpoint base_loss: dpo_full_loss: 0.69314718 dpo_full_resume_loss: 0.69314718 base_result: pt_full_excepted_result: - [94529, 130950, 94529, 138785, 11615, 90320, 84803, 138785, 791, 104475] ... ``` -------------------------------- ### Install PaddleHub with Specific PyPI Source Source: https://github.com/paddlepaddle/paddleformers/wiki/PaddleHub-FAQ Use this command if pip is pointing to a mirror source that hasn't synced PaddleHub versions. ```shell $ pip install -i https://pypi.org/simple/ paddlehub ``` -------------------------------- ### SFT Full Fine-tuning Configuration Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_a_reasoning_model.md This configuration file sets up parameters for Supervised Fine-Tuning (SFT) with full fine-tuning. Key parameters include training epochs, batch sizes, learning rate, and performance settings like tensor parallelism and bf16. ```yaml # base stage: SFT fine_tuning: full seed: 23 do_train: true do_eval: true per_device_eval_batch_size: 1 per_device_train_batch_size: 1 num_train_epochs: 5 max_steps: -1 eval_steps: 1000 evaluation_strategy: steps save_steps: 1000 save_strategy: steps logging_steps: 1 gradient_accumulation_steps: 16 logging_dir: ./vdl_log output_dir: ./checkpoints/qwen0.6-sft-full disable_tqdm: true eval_accumulation_steps: 16 # train warmup_steps: 5 learning_rate: 1.0e-5 # performance tensor_model_parallel_size: 1 pipeline_model_parallel_size: 1 sharding: stage2 recompute: true bf16: true fp16_opt_level: O2 ``` ``` -------------------------------- ### Fine-tune Model with Full Parameters (SFT) Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/README.md Perform supervised fine-tuning (SFT) with full parameters using a specified configuration file. Supports single-card and multi-card training. ```bash # Single-card paddleformers-cli train ./config/sft/full.yaml # Multi-card CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 paddleformers-cli train ./config/sft/full_tp_pp.yaml ``` -------------------------------- ### Text Completion Example Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/tutorials/how_to_train_a_function_call_model.md This snippet shows how a model generates text completion without using tools, potentially leading to hallucinations. ```python outputs = model.generate( **model_inputs, do_sample=False, max_new_tokens=32768 ) output_ids = outputs[0].tolist()[0] content = tokenizer.decode(output_ids, skip_special_tokens=True).strip("\n") print("content:", content) ``` -------------------------------- ### Sample JSONL Data Entry Source: https://github.com/paddlepaddle/paddleformers/blob/develop/docs/en/datasets_format.md Example of a single data entry in JSONL format for pre-training. Each entry is a dictionary with a 'text' field. ```text {"text": ["An example of a classification problem that requires continuous input values is house price prediction. The price of a house is usually based on factors such as square footage, location, number of bedrooms and bathrooms, and features like a backyard or garage. To accurately predict house prices, these criteria must be entered into the classification model as continuous input values."]} ``` -------------------------------- ### Download and Configure Training Weights Source: https://github.com/paddlepaddle/paddleformers/blob/develop/examples/best_practices/ERNIE-4.5/README.md Download training configurations and replace the default inference configuration with the training one for ERNIE-4.5 models. ```shell wget https://paddleformers.bj.bcebos.com/models/eb45_model_configs.tar.gz tar xf eb45_model_configs.tar.gz # 21B mv ERNIE-4.5-21B-A3B-Base-PT/config.json ERNIE-4.5-21B-A3B-Base-PT/config.json.bak cp model_configs/ERNIE-4p5-21B-A3B/model_config.json ERNIE-4.5-21B-A3B-Base-PT/config.json # 300B mv ERNIE-4.5-300B-A47B-Base-PT/config.json ERNIE-4.5-300B-A47B-Base-PT/config.json.bak cp model_configs/ERNIE-4p5-300B-A47B/model_config.json ERNIE-4.5-300B-A47B-Base-PT/config.json ``` -------------------------------- ### Load JSON File Function Source: https://github.com/paddlepaddle/paddleformers/blob/develop/docs/zh/dataset_format.md Example function to load data from a JSON file. It handles FileNotFoundError and JSONDecodeError, with a fallback for JSONL format. ```python def load_json(file_path): try: with open(file_path, "r", encoding="utf-8") as f: return json.load(f) except FileNotFoundError: raise FileNotFoundError(f"file {file_path} not exists") except json.JSONDecodeError: pass # fallback to JSONL ```