This repository guides you through the process of federated LLM instruction tuning with a pre-trained Mistral-7B model across 4 domains --- general NLP, finance, medical and code.
Please follow the instructions to run and evaluate the federated LLMs.
As the first step, please register for a Flower account on flower.ai/login. Then, create a new Python environment and install Flower.
Tip
We recommend using pyenv with the virtualenv plugin to create your environment with Python >= 3.11.0. Other managers, such as Conda, will likely work as well. Check the documentation for alternative ways to install Flower.
pip install flwrIn the new environment, create a new Flower project using one of the FlowerTune apps as your starting point via the flwr new command:
# For general NLP challenge
flwr new @flwrlabs/flowertune-llm-general-nlp
# For finance challenge
flwr new @flwrlabs/flowertune-llm-finance
# For medical challenge
flwr new @flwrlabs/flowertune-llm-medical
# For code challenge
flwr new @flwrlabs/flowertune-llm-codeThe flwr new command will generate a directory with the following structure:
<project_name>
├── README.md # Instructions
├── pyproject.toml # Environment dependencies and configs
└── <project_name>
├── __init__.py
├── client_app.py # Flower ClientApp build
├── dataset.py # Dataset and tokenizer build
├── models.py # Model build
├── server_app.py # Flower ServerApp build
└── strategy.py # Flower strategy buildThis can serve as the starting point for you to build up your own federated LLM fine-tuning methods.
Important
Please note that if you intend to submit your project as an entry to the LLM Leaderboard modifications to the [tool.flwr.app.config.static] section of pyproject.toml, or the use of a different number of SuperNodes than specified in the app’s README, are not allowed and will invalidate the submission.
With a new project directory created, running a baseline challenge can be done by:
-
Navigate inside the directory that you just created.
-
Follow the
Environments setupsection ofREADME.mdin the project directory to install the project dependencies. -
Run the challenge as indicated in the
Running the challengesection in theREADME.md.
Once the LLM fine-tuning finished, evaluate the performance of your fine-tuned LLM
following the README.md in evaluation directory.
Note
If you have any questions about running FlowerTune LLM challenges or evaluation, please feel free to make posts at our dedicated FlowerTune Category on Flower Discuss forum,
or join our Slack channel to ask questions in the #flowertune-llm-leaderboard channel.
