Skip to main content
QUICK REVIEW

[Paper Review] Efficient and Effective Text Encoding for Chinese LLaMA and Alpaca

Yiming Cui, Ziqing Yang|arXiv (Cornell University)|Apr 17, 2023
Natural Language Processing TechniquesComputer Science71 citations
TL;DR

This work extends LLaMA with 20,000 Chinese tokens, uses LoRA for efficient training and fine-tuning, and demonstrates improved Chinese understanding and instruction-following capabilities in Chinese LLaMA/Alpaca models.

ABSTRACT

Large Language Models (LLMs), such as ChatGPT and GPT-4, have dramatically transformed natural language processing research and shown promising strides towards Artificial General Intelligence (AGI). Nonetheless, the high costs associated with training and deploying LLMs present substantial obstacles to transparent, accessible academic research. While several large language models, such as LLaMA, have been open-sourced by the community, these predominantly focus on English corpora, limiting their usefulness for other languages. In this paper, we propose a method to augment LLaMA with capabilities for understanding and generating Chinese text and its ability to follow instructions. We achieve this by extending LLaMA's existing vocabulary with an additional 20,000 Chinese tokens, thereby improving its encoding efficiency and semantic understanding of Chinese. We further incorporate secondary pre-training using Chinese data and fine-tune the model with Chinese instruction datasets, significantly enhancing the model's ability to comprehend and execute instructions. Our experimental results indicate that the newly proposed model markedly enhances the original LLaMA's proficiency in understanding and generating Chinese content. Additionally, the results on the C-Eval dataset yield competitive performance among the models with several times the size of ours. We have made our pre-trained models, training scripts, and other resources available through GitHub, fostering open research for our community. Chinese LLaMA series: \url{https://github.com/ymcui/Chinese-LLaMA-Alpaca} and Chinese Llama-2 series: \url{https://github.com/ymcui/Chinese-LLaMA-Alpaca-2}

Motivation & Objective

  • Enhance LLaMA and Alpaca for Chinese language understanding and generation.
  • Increase encoding efficiency and semantic comprehension for Chinese text.
  • Enable cost-effective training and adaptation using parameter-efficient fine-tuning (LoRA).
  • Provide pre-trained Chinese LLaMA/Alpaca resources to the community.

Proposed method

  • Extend LLaMA vocabulary by 20,000 Chinese tokens and merge with original tokenizer to create a Chinese LLaMA tokenizer (vocab size 49,953).
  • Resize embedding matrices to accommodate the extended vocabulary without altering original token embeddings.
  • Apply Low-Rank Adaptation (LoRA) adapters to attention and MLP layers for parameter-efficient pre-training and fine-tuning.
  • Pre-train Chinese LLaMA with standard Casual Language Modeling (CLM) on Chinese corpora (20 GB basic, 120 GB Plus).
  • Fine-tune with Chinese instruction data using supervised fine-tuning (SFT) in a template-based prompt, following Alpaca paradigms, with a vocabulary size of 49,954.
  • Evaluate on instruction-following tasks and natural language understanding tasks (C-Eval) with GPT-4-based scoring and manual checks.

Experimental results

Research questions

  • RQ1Can extending the LLaMA vocabulary with 20k Chinese tokens improve Chinese encoding efficiency and generation quality?
  • RQ2Does LoRA enable efficient training and fine-tuning of Chinese LLaMA/Alpaca models under limited computational resources?
  • RQ3How do Chinese LLaMA and Chinese Alpaca perform on instruction-following and NLU benchmarks compared to baseline LLaMA/Alpaca?
  • RQ4What is the impact of data scale (20 GB vs 120 GB) on Chinese model performance?
  • RQ5What are the effects of decoding strategies and evaluation methodology on model assessments in Chinese tasks?

Key findings

  • Chinese LLaMA tokenizer reduces encoding length; the tokenizer yields about half as many tokens as the original, effectively doubling context usage and speeding generation.
  • LoRA-based training enables parameter-efficient pre-training and fine-tuning across all Chinese LLaMA/Alpaca variants, with trains focused on attention and MLP components.
  • Chinese Alpaca models (Plus variants) outperform basic models on many instruction-following tasks across multiple metrics, with largerPlus models generally achieving higher GPT-4-rated scores on several tasks.
  • Alpaca-33B shows stronger numerical reasoning, coding, and ethics handling than Plus-7B/Plus-13B, though it may lag in text generation and multi-turn dialogue compared to Plus-series models due to data quantity and model size interactions.
  • On the C-Eval natural language understanding benchmark, the paper reports competitive performance relative to larger models, illustrating efficient Chinese capability with the proposed vocabulary and training approach.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.