API
OpenAI-Compatible RESTful APIs & SDK
FastChat provides OpenAI-compatible APIs for its supported models, so you can use FastChat as a local drop-in replacement for OpenAI APIs. The FastChat server is compatible with both openai-python library and cURL commands. See openai_api.
Hugging Face Generation APIs
See fastchat/serve/huggingface_api.py.
LangChain Integration
Evaluation
We use MT-bench, a set of challenging multi-turn open-ended questions to evaluate models. To automate the evaluation process, we prompt strong LLMs like GPT-4 to act as judges and assess the quality of the models’ responses. See instructions for running MT-bench at fastchat/llm_judge.
MT-bench is the new recommended way to benchmark your models. If you are still looking for the old 80 questions used in the vicuna blog post, please go to vicuna-blog-eval.
Fine-tuning
Data
Vicuna is created by fine-tuning a LLaMA base model using approximately 125K user-shared conversations gathered from ShareGPT.com with public APIs. To ensure data quality, we convert the HTML back to markdown and filter out some inappropriate or low-quality samples. Additionally, we divide lengthy conversations into smaller segments that fit the model’s maximum context length. For detailed instructions to clean the ShareGPT data, check out here.
We will not release the ShareGPT dataset. If you would like to try the fine-tuning code, you can run it with some dummy conversations in dummy_conversation.json. You can follow the same format and plug in your own data.
Code and Hyperparameters
Our code is based on Stanford Alpaca with additional support for multi-turn conversations. We use similar hyperparameters as the Stanford Alpaca.
Hyperparameter | Global Batch Size | Learning rate | Epochs | Max length | Weight decay |
---|---|---|---|---|---|
Vicuna-13B | 128 | 2e-5 | 3 | 2048 | 0 |
Fine-tuning Vicuna-7B with Local GPUs
- Install dependency
- You can use the following command to train Vicuna-7B with 4 x A100 (40GB). Update
--model_name_or_path
with the actual path to LLaMA weights and--data_path
with the actual path to data.
Tips:
- If you are using V100 which is not supported by FlashAttention, you can use the memory-efficient attention implemented in xFormers. Install xformers and replace
fastchat/train/train_mem.py
above with fastchat/train/train_xformers.py. - If you meet out-of-memory due to “FSDP Warning: When using FSDP, it is efficient and recommended… ”, see solutions here.
- If you meet out-of-memory during model saving, see solutions here.
Other models, platforms and LoRA support
More instructions to train other models (e.g., FastChat-T5) and use LoRA are in training.
Fine-tuning on Any Cloud with SkyPilot
SkyPilot is a framework built by UC Berkeley for easily and cost effectively running ML workloads on any cloud (AWS, GCP, Azure, Lambda, etc.). Find SkyPilot documentation here on using managed spot instances to train Vicuna and save on your cloud costs.
Citation
The code (training, serving, and evaluation) in this repository is mostly developed for or derived from the paper below. Please cite it if you find the repository helpful.
We are also planning to add more of our research to this repository.