A set of solutions is provided, leveraging Openpangu - 7B as the base model for fine - tuning and application of large language models (LLMs) in operations rese
A set of solutions is provided, leveraging Openpangu - 7B as the base model for fine - tuning and application of large language models (LLMs) in operations rese
EvoOpt-LLM
EvoOpt-LLM provides a comprehensive suite of solutions for fine-tuning and applying Large Language Models (LLMs) to operations research (OR) optimization tasks, using Openpangu-7B as the base model. By integrating modules for model fine-tuning, end-to-end automated modeling, generation of new constraints, and variable pruning, it aims to enhance the specialized capabilities of LLMs in the field of operations research.
Detailed information and technical specifications for Openpangu-7B can be found at: https://ai.gitcode.com/ascend-tribe/openpangu-embedded-7b-model/tree/main
Model Fine-tuning: Utilizes efficient fine-tuning techniques such as LoRA to perform specialized training on the Openpangu-7B base model using domain-specific operations research datasets, primarily achieving the following three functions:
This project is based on the Openpangu-7B base model and is developed and optimized for the Huawei Ascend AI processor (NPU) environment.
Fine-tunes the model for specific operations research tasks to enhance its professional capabilities in this domain.
…1. Modifying Key Parameters in train_config.py
Before starting the fine-tuning process, focus on adjusting the following parameters based on the actual task:
…2. Running finetune.py
After modifying the parameters, execute the following command:
For a single acceleration card:
python finetune.py \
--config train_config.pyFor multiple acceleration cards:
torchrun --nproc_per_node=NUMBER_OF_CARDS finetune.py \
--config train_config.pyA full-process solution for automated modeling, constraint generation, and code evaluation.
…The end-to-end modeling module includes two parts: Automated Modeling and New Scenario Constraints.
(1) The Automated Modeling module is used to batch-generate results for automated modeling prompts, providing an evaluation module to assess the performance. The core entry script is generate_finetuned_example.sh.
BASE_MODEL_PATH: Path to the base model.
LORA_PATH: Directory for the fine-tuned LoRA model.
DATASET_NAME: Directory or file path for the automated modeling task dataset.
DATASET_SPLIT: Specifies which part of the dataset to use (train/test/validation).
SAVE_DIR: Directory for model generation results.
TOPK: Number of results generated per prompt.
DECODING_METHOD: Decoding method.
MAX_TOKENS: Maximum number of tokens to generate.Once ready, execute the script directly: bash generate_finetuned_example.sh
To run the evaluation script, use the following command:
python execute.py \
--input_file INPUT_FILE_PATH (automated modeling generation results) \
--output_file OUTPUT_FILE_PATH \
--timeout Maximum allowed time for code execution \
--max_workers Maximum number of parallel execution threads \
--majority_voting Whether to enable majority voting metrics \
--question_field Field name for question text in input_file \
--answer_field Field name for answer text in input_file \
--numerical_err_tolerance Numerical error tolerance threshold(2) The core entry script for the New Scenario Constraints module is generate_constraints_example.sh.
BASE_MODEL_PATH: Path to the base model.
LORA_PATH: Directory for the fine-tuned LoRA model.
INPUT_PATH: Path to the LP files for adding new constraints.
SAVE_DIR: Directory for model generation results.
TOPK: Number of results generated per prompt.
DECODING_METHOD: Decoding method.
MAX_TOKENS: Maximum number of tokens to generate.bash generate_constraints_example.shThis module performs optimization problem preprocessing by reducing problem scale through variable pruning to improve solving efficiency. The structure is as follows:
end_to_end_pruning/
├── analyze_zero_variables.py # Zero-value variable analysis
├── analyze_zero_variables.sh # Analysis script
├── evaluate_zero_variables.py # Pruning effect evaluation
├── evaluate_zero_variables.sh # Evaluation script
└── results/ # Pruning results filesThe end-to-end pruning module consists of two parts: the Pruning Execution Module and the Pruning Evaluation Module. The execution module uses the fine-tuned Openpangu-7B model to identify variables for pruning in a given LP file, outputting a set of decision variables that can be safely fixed to 0, thereby achieving automated compression and pruning of the MILP model. The evaluation module compares the pruned variables with the ground truth to calculate precision metrics. The core entry script for the variable pruning module is analyze_zero_variables_example.sh.
BASE_MODEL_PATH: Path to the base model.
LORA_PATH: Directory for the fine-tuned LoRA model.
LP_INPUT: Path to the LP files to be pruned.
OUTPUT_JSON: Path for the generated JSON file with pruning results.
TOPK: Number of results generated per prompt.
DECODING_METHOD: Decoding method.
MAX_TOKENS: Maximum number of tokens to generate.Once ready, execute the script directly: bash analyze_zero_variables_example.sh
Key configurable parameters in the evaluation script:
GENERATED_JSON: Path to the generated pruning results.
ANSWER_JSON: Path to the ground truth.
OUTPUT_JSON: Path for the evaluation output file.bash evaluate_zero_variables_example.shNo open issues yet, or sync has not completed.