Bactrian-X : A Multilingual Replicable Instruction-Following Model with Low-Rank Adaptation
Paper • 2305.15011 • Published • 1
How to use MBZUAI/bactrian-x-llama-7b-merged with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="MBZUAI/bactrian-x-llama-7b-merged") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("MBZUAI/bactrian-x-llama-7b-merged")
model = AutoModelForCausalLM.from_pretrained("MBZUAI/bactrian-x-llama-7b-merged")How to use MBZUAI/bactrian-x-llama-7b-merged with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "MBZUAI/bactrian-x-llama-7b-merged"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MBZUAI/bactrian-x-llama-7b-merged",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/MBZUAI/bactrian-x-llama-7b-merged
How to use MBZUAI/bactrian-x-llama-7b-merged with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "MBZUAI/bactrian-x-llama-7b-merged" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MBZUAI/bactrian-x-llama-7b-merged",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "MBZUAI/bactrian-x-llama-7b-merged" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MBZUAI/bactrian-x-llama-7b-merged",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use MBZUAI/bactrian-x-llama-7b-merged with Docker Model Runner:
docker model run hf.co/MBZUAI/bactrian-x-llama-7b-merged
This repo contains a merged model using low-rank adaptation (LoRA) for LLaMA-7b fit on the Stanford-Alpaca-52k and databricks-dolly-15k data in 52 languages.
gpt-3.5-turbo for each language (conducted on April 2023).
The code for training the model is provided in our github, which is adapted from Alpaca-LoRA. This version of the weights was trained with the following hyperparameters:
That is:
python finetune.py \
--base_model='decapoda-research/llama-7b-hf' \
--num_epochs=10 \
--batch_size=128 \
--cutoff_len=512 \
--group_by_length \
--output_dir='./bactrian-x-llama-7b-lora' \
--lora_target_modules='q_proj,k_proj,v_proj,o_proj' \
--lora_r=64 \
--micro_batch_size=32
Instructions for running it can be found at https://github.com/MBZUAI-nlp/Bactrian-X.
(1) Translation bias; (2) Potential English-culture bias in the translated dataset.
@misc{li2023bactrianx,
title={Bactrian-X : A Multilingual Replicable Instruction-Following Model with Low-Rank Adaptation},
author={Haonan Li and Fajri Koto and Minghao Wu and Alham Fikri Aji and Timothy Baldwin},
year={2023},
eprint={2305.15011},
archivePrefix={arXiv},
primaryClass={cs.CL}
}