PhoGPT: Generative Pre-training for Vietnamese (2023)
We open-source a state-of-the-art 4B-parameter generative model series for Vietnamese, which includes the base pre-trained monolingual model PhoGPT-4B and its chat variant, PhoGPT-4B-Chat. The base model, PhoGPT-4B, with exactly 3.7B parameters, is pre-trained from scratch on a Vietnamese corpus of 102B tokens, with an 8192 context length, employing a vocabulary of 20K token types. The chat variant, PhoGPT-4B-Chat, is the modeling output obtained by fine-tuning PhoGPT-4B on a dataset of 70K instructional prompts and their responses, along with an additional 290K conversations. We demonstrate its superior performance compared to previous open-source models.
More details about the general architecture and experimental results of PhoGPT can be found in our technical report. All output responses of PhoGPT and baselines are available HERE for readers' self-evaluation. Please CITE our technical report when PhoGPT is used to help produce published results or is incorporated into other software:
@article{PhoGPT,
title = {{PhoGPT: Generative Pre-training for Vietnamese}},
author = {Dat Quoc Nguyen and Linh The Nguyen and Chi Tran and Dung Ngoc Nguyen and Dinh Phung and Hung Bui},
journal = {arXiv preprint},
volume = {arXiv:2311.02945},
year = {2023}
}
| Model | Type | Model Size | Context length | Vocab size | Training data size | Note |
|---|---|---|---|---|---|---|
vinai/PhoGPT-4B |
Base | 3.7B | 8192 | 20K | 2 training epochs on 482GB of texts | Loading "PhoGPT-4B" or "PhoGPT-4B-Chat" in float16 takes 7GB of GPU memory |
vinai/PhoGPT-4B-Chat |
Instruction following & Chat | 3.7B | 8192 | 20K | 70K instructional prompt and response pairs & 290K conversations | PROMPT_TEMPLATE = "### Câu hỏi: {instruction}\n### Trả lời:" |
PhoGPT can run with inference engines, such as vLLM, Text Generation Inference and llama.cpp.
cd llama.cpp
python3 -m pip install -r requirements.txt
python3 convert-hf-to-gguf.py --outfile ./PhoGPT-4B-Chat.gguf./quantize ./PhoGPT-4B-Chat.gguf ./PhoGPT-4B-Chat-Q4_K_M.gguf Q4_K_M./quantize ./PhoGPT-4B-Chat.gguf ./PhoGPT-4B-Chat-Q8_0.gguf Q8_0./main -m ./PhoGPT-4B-Chat-Q4_K_M.gguf -n 1024 -p "### Câu hỏi: Viết bài văn nghị luận xã hội về an toàn giao thông\n### Trả lời:"Converted gguf files are available at: vinai/PhoGPT-4B-Chat-gguf. Note that phogpt_4b_chat_preset.json might be needed for LM Studio to work properly with our gguf files.
transformers…
messages = [
{"role": "user", "content": "Kể tên một môn thể thao mạo hiểm"},
{"role": "assistant", "content": "Nhảy Bungee."},
{"role": "user", "content": "Bạn đã bao giờ đi nhảy bungee chưa"}
]
# Using apply_chat_template
tokenizer = AutoTokenizer.from_pretrained("vinai/PhoGPT-4B-Chat", trust_remote_code=True)
input_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
bitsandbytesimport torch
from transformers import BitsAndBytesConfig, AutoConfig, AutoModelForCausalLM, AutoTokenizer
config = AutoConfig.from_pretrained("vinai/PhoGPT-4B-Chat", trust_remote_code=True)
config.init_device = "cuda"
# 8-bit quantization
model_8bit = AutoModelForCausalLM.from_pretrained("vinai/PhoGPT-4B-Chat", config=config, load_in_8bit=True)
See llm-foundry docs for details. To fully fine-tune PhoGPT, users can find an example of model finetuning YAML configuration at fine-tuning-phogpt.yaml. Users can also find the sample_instruction_following_dataset folder as an example of an instruction-following dataset.
llm-foundry, see Section "Installation" in https://github.com/mosaicml/llm-foundry.cd llm-foundry/scripts/train/ and then composer --world_size train.py (e.g. composer --world_size 1 train.py fine-tuning-phogpt.yaml).Other fine-tuning options may include the use of transformers's Trainer (e.g. see stanford_alpaca as an example), lit-gpt or LLaMA-Factory.
PhoGPT has certain limitations. For example, it is not good at tasks involving reasoning, coding or mathematics. PhoGPT may generate harmful, hate speech, biased responses, or answer unsafe questions. Users should be cautious when interacting with PhoGPT that can produce factually incorrect output.
No open issues yet, or sync has not completed.