Papers › Efficient and Effective Text Encoding for Chinese LLaMA and Alpaca

Efficient and Effective Text Encoding for Chinese LLaMA and Alpaca

17 Apr 2023arXiv:2304.08177archive 2025-07-28

Yiming Cui, Ziqing Yang, Xin Yao

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}

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2304.08177")

Code

Syntology Ran 10 of 24 code samples harvested from 6 repositories linked to this paper; 14 have no recorded run. Of those that ran: 1 ran · honoured contract; 6 ran · our draft was wrong; 3 ran · fixture could not drive it.

By repository: official repository: 5 samples from 2 repositories, 4 ran; community (archive-listed): 17 samples from 4 repositories, 4 ran; 2 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

ymcui/chinese-llama-alpaca officialmentioned in papermentioned on GitHubpytorch report
ymcui/chinese-llama-alpaca-2 officialmentioned in papermentioned on GitHubpytorch report
mryxj/calculate-flops.pytorch mentioned on GitHubpytorchMIT report
neukg/techgpt-2.0 mentioned on GitHubmindsporeApache-2.0 report
ymcui/chinese-llama-alpaca-3 mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

24 samples harvested; 10 ran; 1 honoured the contract we drafted; 14 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
6ran · our draft was wrong
3ran · fixture could not drive it
14unverified

Licence: 2 of the 24 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 6 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

prepare_model_for_kbit_training ymcui/chinese-llama-alpaca-2/scripts/training/run_clm_pt_with_peft.py official repository ran · our draft was wrong Apache-2.0 (permissive) · 591cff6b55ba6bfb · report
preprocess_logits_for_metrics ymcui/chinese-llama-alpaca/scripts/training/run_clm_pt_with_peft.py official repository ran · honoured contract Apache-2.0 (permissive) · d2895bdf14e8f94f · report
translate_state_dict_key ymcui/chinese-llama-alpaca/scripts/merge_llama_with_chinese_lora.py official repository ran · our draft was wrong Apache-2.0 (permissive) · a4f5d0414a1cf9c6 · report
transpose ymcui/chinese-llama-alpaca/scripts/merge_llama_with_chinese_lora.py official repository ran · fixture could not drive it fingerprinted Apache-2.0 (permissive) · 8f1a49e9d8b29d83 · report
unpermute ymcui/chinese-llama-alpaca/scripts/merge_llama_with_chinese_lora.py official repository unverified Apache-2.0 (permissive) · 5b22827888d475e4 · report
collator jackaduma/Alpaca-LoRA-RLHF-PyTorch/tuning_lm_with_rl.py community (archive-listed) ran · our draft was wrong MIT (permissive) · bda36ad0c44dbd74 · report
generate_prompt ymcui/chinese-llama-alpaca-3/scripts/inference/inference_hf.py community (archive-listed) ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 506e15dcebddded4 · report
jsonload ymcui/chinese-llama-alpaca-3/scripts/merge_llama3_with_chinese_lora_low_mem.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · 1d905d8345954c70 · report
read_json neukg/techgpt-2.0/ckpt_weight_convert/convert_weight.py community (archive-listed) ran · our draft was wrong Apache-2.0 (permissive) · c5bcf01d18bba63d · report
calculate_flops mryxj/calculate-flops.pytorch/calflops/flops_counter.py community (archive-listed) unverified MIT (permissive) · e9d40620ba06c476 · report
calculate_flops_hf mryxj/calculate-flops.pytorch/calflops/flops_counter_hf.py community (archive-listed) unverified MIT (permissive) · 25a2892b59109d04 · report
check_has_model mryxj/calculate-flops.pytorch/calflops/estimate.py community (archive-listed) unverified MIT (permissive) · 862bec96a19b9582 · report
create_empty_model mryxj/calculate-flops.pytorch/calflops/estimate.py community (archive-listed) unverified MIT (permissive) · ed09fbaf85f7c338 · report
create_empty_model mryxj/calculate-flops.pytorch/calflops/__pycache__/estimate.py community (archive-listed) unverified MIT (permissive) · e677c1203f29a49d · report
generate_prompt neukg/techgpt-2.0/mindspore_inference/techgpt2-alpaca_inference.py community (archive-listed) unverified Apache-2.0 (permissive) · 5805470da16397ec · report
generate_prompt neukg/techgpt-2.0/mindspore_inference/techgpt2-atom_inference.py community (archive-listed) unverified Apache-2.0 (permissive) · 9975d177719247f6 · report
generate_transformer_input mryxj/calculate-flops.pytorch/calflops/utils.py community (archive-listed) unverified MIT (permissive) · 3095c6f9fc06ee03 · report
macs_to_string mryxj/calculate-flops.pytorch/calflops/utils.py community (archive-listed) unverified MIT (permissive) · 0d2323a5d9352647 · report
name_replace neukg/techgpt-2.0/ckpt_weight_convert/convert_weight.py community (archive-listed) unverified Apache-2.0 (permissive) · 86f93c0600f3a1fd · report
number_to_string mryxj/calculate-flops.pytorch/calflops/utils.py community (archive-listed) unverified MIT (permissive) · fce9fc5087d11c5b · report
verify_on_hub mryxj/calculate-flops.pytorch/calflops/estimate.py community (archive-listed) unverified MIT (permissive) · 658e8c21987864b5 · report
wrapFunc mryxj/calculate-flops.pytorch/calflops/pytorch_ops.py community (archive-listed) unverified MIT (permissive) · 03a510eeef28adc4 · report
accuracy identical code first harvested elsewhere ran · fixture could not drive it fingerprinted licence of this copy not recorded · 8a38d7c525fad8f1 · report
compute_metrics identical code first harvested elsewhere ran · fixture could not drive it licence of this copy not recorded · 6b376a0abe58a427 · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutGPT-4Label SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections