Skip to content

Challenger-XJTU/llm4ad

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLM4AD Logo

LLM4AD: Large Language Model for Algorithm Design

Releases Maintenance PR's Welcome Python License Documentation Status Open In Colab

Website | Documentation | Examples | GUI


Introduction 📖

LLM4AD is an open-source Python-based Platform leveraging Large Language Models (LLMs) for Automatic Algorithm Design (AD). Please refer to the paper [LLM4AD] for detailed information, including the overview, methodology, and benchmark results.

LLM4AD is accomplished with Documents and Examples materials to support users and developers to easily test, build and deploy their own LLM4AD applications and conduct research.

LLM4AD was originally developed for optimisation tasks. The framework is versatile enough to be used in other areas, including machine learning, science discovery, game theory and engineering design.

For more information, see the contact list

llm4ad

🔥 News

💡 Features of our package

Feature Support / To be supported
Unified Interfaces for methods 🔥Support
Unified Interfaces for tasks 🔥Support
Unified Interfaces for LLMs 🔥Support
Evaluation acceleration: multiprocessing evaluation, add Numba wrapper for heuristic 🔥Support
Secure Evaluation: main process protection, timeout interruption 🔥Support
Logs: local logs, Wandb and Tensorboard support 🔥Support
GUI: methods selection, tasks selection, convergence, best algorithm, ... 🔥Support
Resume run 🚀Will be updated soon
Support other languages 🚀Will be updated soon
More search methods 🚀Will be updated soon
More task examples 🚀Will be updated soon

🎁 Requirements & Installation

Important

The Python version must be larger or equal to Python 3.9.

  • refer to requirements.txt

  • Numba (if you want to use Numba accelerate)

  • Tensorboard (if you want to use a Tensorboard logger)

  • wandb (if you want to use wandb logger)

  • gym (if you want to try Machine Learning tasks)

  • pandas (if you want to try Science Discovery tasks)

  • all required packages in requirements.txt (if you want to use GUI)

    Install LLM4AD locally

    We suggest to install and run LLM4AD in conda env with python>=3.9, <=3.11

    cd LLM4AD
    
    pip install .

    Install LLM4AD using PiPy

    We suggest to install and run LLM4AD in conda env with python>=3.9, <=3.11

    pip install llm4ad

💻 Example Usage

Quick Start:

Note

Configure your LLM api before running the script. For example:

  1. Set host: 'api.deepseek.com'
  2. Set key: 'your api key'
  3. Set model `deepseek-chat'
from llm4ad.task.optimization.online_bin_packing import OBPEvaluation
from llm4ad.tools.llm.llm_api_https import HttpsApi
from llm4ad.method.eoh import EoH, EoHProfiler


def main():

    llm = HttpsApi(host="xxx",  # your host endpoint, e.g., api.openai.com, api.deepseek.com
                   key="sk-xxx",  # your key, e.g., sk-xxxxxxxxxx
                   model="xxx",  # your llm, e.g., gpt-3.5-turbo, deepseek-chat
                   timeout=20)
    
    task = OBPEvaluation()

    method = EoH(llm=llm,
                 profiler=EoHProfiler(log_dir='logs/eoh', log_style='simple'),
                 evaluation=task,
                 max_sample_nums=20,
                 max_generations=10,
                 pop_size=4,
                 num_samplers=1,
                 num_evaluators=1, 
                 debug_mode=False)

    method.run()


if __name__ == '__main__':
    main()

More Examples:

Check Documents for more tasks and examples

GUI usage:

Important

Install all required packages in requirements.txt for GUI usage

$ cd GUI
$ python run_gui.py

Check GUI Introduction for more information

llm4ad

📦 LLM4AD Search Methods

Methods Paper title
RandomSampling Understanding the Importance of Evolutionary Search in Automated Heuristic Design with Large Language Models (PPSN 2024)
FunSearch Mathematical Discoveries from Program Search with Large Language Models (Nature 2023)
EoH* Evolution of Heuristics: Towards Efficient Automatic Algorithm Design Using Large Language Model (ICML 2024)
(1+1)-EPS*
(HillClimbing)
Understanding the Importance of Evolutionary Search in Automated Heuristic Design with Large Language Models (PPSN 2024)
RegEvo coming soon
Neighborhood search methods coming soon
Multi-objective search methods coming soon
Others coming soon

*The implementation has some minor differences from the original method (demonstrated in their original paper), considering generality and multithreading acceleration.

📦LLM4AD Algorithm Design Tasks

Area Algorithm Task Paper
Optimization [Online Bin Packing, Constructive heuristic] paper
Traveling Salesman Problem (TSP), Construct heuristic paper
Traveling Salesman Problem (TSP), Guided local search paper
Flow Shop Scheduling Problem (FSSP), Guided local search paper
Bayesian Optimization, Cost-aware Acquisition Function Design paper
Machine Learning Adversarial Attack, Attack strategy paper
Acrobot, Heuristic (Agent)
Cart Pole, Heuristic (Agent)
Mountain Car, Heuristic (Agent)
Science Discovery Computational fluid dynamics, Turbulence model design paper
Bacteria Growth, Function
Oscillator, Equation
Stress & Strain, Equation
Math Admissible Sets paper
coming soon ...

🤖 LLM Interfaces

There are three approaches on LLM interface implementation, check Tutorial on LLM interface implementation for more information.

  • Remote LLM API (e.g., GPT4o, GPT3.5, Gemini Pro, Deepseek ...) (<Recommended !!!>)
  • Local HuggingFace LLM Deployment (e.g., Llamacode, Llama, Gemma, Deepseek, ...)
  • Your Implementation If you want to use your own GPT API or local LLMs deployment, please create and add your interface in LLM

🗎 Tutorial: How to Use LLM4AD to Solve Your Algorithm Design Task

A Step-by-step Tutorial on using LLM4AD to solve your algorithm design task is provided here

🪪 Licence

This project is licensed under the MIT License - see the LICENSE file for details. Parts of this project use code licensed under the Apache License 2.0.

✨Reference

If you find LLM4AD helpful please cite:

@article{liu2024llm4ad,
      title={LLM4AD: A Platform for Algorithm Design with Large Language Model}, 
      author={Fei Liu and Rui Zhang and Zhuoliang Xie and Rui Sun and Kai Li and Xi Lin and Zhenkun Wang and Zhichao Lu and Qingfu Zhang},
      year={2024},
      eprint={2412.17287},
      archivePrefix={arXiv},
      primaryClass={cs.AI},
      url={https://arxiv.org/abs/2412.17287}, 
}

About LLM4AD

This platform is developed and maintained by LLM4AD developer group from the City University of Hong Kong (CityUHK) and the Southern University of Science and Technology (SUSTech). We develop LLM4AD platform for research purposes and hope to contribute to the research area by delivering tools for LLM-based algorithm design methods.

  • Contribution: We are more than welcome to contribute including developing code and ideas to improve our platform.
  • Collaborations: If you like our platform, and you would like to use it for profit-making purposes? We are always searching for industrial collaborations because they help direct research to meet the industry’s needs.
  • Issue: If you find a bug or you have any kind of concern regarding the correctness, please report us an issue.
  • Profit Purpose: If you intend to use LLM4AD for any profit-making purposes, please contact us.

Contact

If you are interested in LLM4AD or if you encounter any difficulty using the platform, you can:

  1. Visit our website LLM4AD Web

  2. Visit our collection a collection of resources and research papers on LLM4AD

  3. Join our QQ Group

    LLM4AD Logo
  4. Contact us through email [email protected]

  5. Submit an issue

About

large language model for algorithm design

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.8%
  • Jupyter Notebook 0.2%