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: https://github.com/ymcui/Chinese-LLaMA-Alpaca and Chinese Llama-2 series: https://github.com/ymcui/Chinese-LLaMA-Alpaca-2

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

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

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 24 code samples: 22 from 6 repositories linked to this paper, 2 identical to code harvested from another paper's repository. Across all 24: 18 ran (of which 0 constructed an object rather than computing a result; 9 with no instrument failure: 1 honoured, 0 violated, 8 with no contract checked; 9 where Syntology's instrument failed) · 6 unverified. Where Syntology's instrument failed: 6 where our contract draft was wrong; 3 where the contract check could not run; failures of Syntology's instrument, not of the code.

By repository: official repository: 5 samples from 2 repositories, 4 ran (1 with no instrument failure; 3 where Syntology's instrument failed); community (archive-listed): 17 samples from 4 repositories, 12 ran (8 with no instrument failure; 4 where Syntology's instrument failed); 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.

Levels written between 2026-09-22 and 2026-09-25 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed. 4 of the 18 samples that ran have no recorded date.

ymcui/chinese-llama-alpaca officialmentioned in papermentioned on GitHubpytorchSyntology: 4 samples, 3 ran (2 instrument-failed) · 1 unverified report
ymcui/chinese-llama-alpaca-2 officialmentioned in papermentioned on GitHubpytorchSyntology: 1 sample, 1 ran (1 instrument-failed) · 0 unverified report
mryxj/calculate-flops.pytorch mentioned on GitHubpytorchMITSyntology: 10 samples, 5 ran (0 instrument-failed) · 5 unverified report
neukg/techgpt-2.0 mentioned on GitHubmindsporeApache-2.0Syntology: 4 samples, 4 ran (1 instrument-failed) · 0 unverified report
ymcui/chinese-llama-alpaca-3 mentioned on GitHubpytorchSyntology: 2 samples, 2 ran (2 instrument-failed) · 0 unverified report
jackaduma/Alpaca-LoRA-RLHF-PyTorch pytorchMITSyntology: 1 sample, 1 ran (1 instrument-failed) · 0 unverified 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: 18 ran (of which 0 constructed an object rather than computing a result; 9 with no instrument failure: 1 honoured, 0 violated, 8 with no contract checked; 9 where Syntology's instrument failed) · 6 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page has not changed since , the first build that kept a record date for it; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

1ran · honoured contract
6ran · our draft was wrong
3ran; the contract check could not run
8ran
6unverified

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; the list below is grouped by repository, each group headed by its name and what it is to the paper. 2 samples are listed last, in a group without a repository. “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. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (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 are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. 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 six 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; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. 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.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity. A census tag appears when Syntology's census ran implementations with that name on one shared input per bucket: it gives how many were compared, from how many papers, and how many distinct outputs they produced, and names this sample's bucket when this sample was one of them.

ymcui/chinese-llama-alpaca official repository 4 samples, 3 ran (2 instrument-failed) · 1 unverified
preprocess_logits_for_metrics in 15 papers scripts/training/run_clm_pt_with_peft.py ran · honoured contract fingerprinted Apache-2.0 (permissive) · d2895bdf14e8f94f · report fixture: signature logits:Tensor/2/float, labels:Tensor/1/int · returned Tensor · level recorded 2026-09-22
translate_state_dict_key in 12 papers scripts/merge_llama_with_chinese_lora.py ran · our draft was wrong Apache-2.0 (permissive) · a4f5d0414a1cf9c6 · report fixture: signature k:str/0/str · returned str · level recorded 2026-09-22
transpose in 53 papers
census: 6 implementations from 13 papers, 3 distinct outputs across 2 buckets, one shared input per bucket this sample: bucket 2 of 2, arg 1: rank 2, kind float, dtype float32
scripts/merge_llama_with_chinese_lora.py ran; the contract check could not run (RAISES) · metamorphic tier: invariant fingerprinted Apache-2.0 (permissive) · 8f1a49e9d8b29d83 · report fixture: signature weight:Tensor/2/float, fan_in_fan_out:bool/0/bool · returned Tensor · level recorded 2026-09-22
unpermute in 12 papers scripts/merge_llama_with_chinese_lora.py unverified Apache-2.0 (permissive) · 5b22827888d475e4 · report
ymcui/chinese-llama-alpaca-2 official repository 1 sample, 1 ran (1 instrument-failed) · 0 unverified
prepare_model_for_kbit_training in 5 papers scripts/training/run_clm_pt_with_peft.py ran · our draft was wrong Apache-2.0 (permissive) · 591cff6b55ba6bfb · report fixture: signature model:callable/0/?, use_gradient_checkpointing:bool/0/bool · returned MockModel · level recorded 2026-09-22
mryxj/calculate-flops.pytorch community (archive-listed) 10 samples, 5 ran (0 instrument-failed) · 5 unverified
check_has_model calflops/estimate.py ran MIT (permissive) · 862bec96a19b9582 · report fixture: signature error:RuntimeError/0/? · returned str · level recorded 2026-09-24
generate_transformer_input calflops/utils.py ran MIT (permissive) · 3095c6f9fc06ee03 · report fixture: signature model_tokenizer:MockTokenizer/0/?, input_shape:tuple/1/int, device:str/0/str · returned dict · level recorded 2026-09-24
macs_to_string calflops/utils.py ran MIT (permissive) · 0d2323a5d9352647 · report fixture: signature macs:int/0/int, units:NoneType/0/?, precision:int/0/int · returned str · level recorded 2026-09-25
number_to_string calflops/utils.py ran MIT (permissive) · fce9fc5087d11c5b · report fixture: signature num:float/0/float, units:NoneType/0/?, precision:int/0/int · returned str · level recorded 2026-09-25
wrapFunc calflops/pytorch_ops.py ran MIT (permissive) · 03a510eeef28adc4 · report fixture: signature func:callable/0/?, funcFlopCompute:callable/0/?, old_functions:dict/0/?, module_flop_count:list/1/list, module_mac_count:list/1/list · returned function · level recorded 2026-09-25
calculate_flops in 10 papers calflops/flops_counter.py unverified MIT (permissive) · e9d40620ba06c476 · report
calculate_flops_hf calflops/flops_counter_hf.py unverified MIT (permissive) · 25a2892b59109d04 · report
create_empty_model calflops/estimate.py unverified MIT (permissive) · ed09fbaf85f7c338 · report
create_empty_model calflops/__pycache__/estimate.py unverified MIT (permissive) · e677c1203f29a49d · report
verify_on_hub calflops/estimate.py unverified MIT (permissive) · 658e8c21987864b5 · report
neukg/techgpt-2.0 community (archive-listed) 4 samples, 4 ran (1 instrument-failed) · 0 unverified
generate_prompt in 110 papers mindspore_inference/techgpt2-alpaca_inference.py ran fingerprinted Apache-2.0 (permissive) · 5805470da16397ec · report fixture: signature instruction:str/0/str · returned str · level recorded 2026-09-25
generate_prompt in 110 papers mindspore_inference/techgpt2-atom_inference.py ran fingerprinted Apache-2.0 (permissive) · 9975d177719247f6 · report fixture: signature instruction:str/0/str · returned str · level recorded 2026-09-24
name_replace ckpt_weight_convert/convert_weight.py ran fingerprinted Apache-2.0 (permissive) · 86f93c0600f3a1fd · report fixture: signature name:str/0/str · returned str · level recorded 2026-09-25
read_json in 250 papers ckpt_weight_convert/convert_weight.py ran · our draft was wrong Apache-2.0 (permissive) · c5bcf01d18bba63d · report fixture: signature path:str/0/str · returned dict · level recorded, date not recorded
ymcui/chinese-llama-alpaca-3 community (archive-listed) 2 samples, 2 ran (2 instrument-failed) · 0 unverified
generate_prompt in 110 papers scripts/inference/inference_hf.py ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 506e15dcebddded4 · report fixture: signature instruction:str/0/str · returned str · level recorded 2026-09-22
jsonload scripts/merge_llama3_with_chinese_lora_low_mem.py ran · our draft was wrong Apache-2.0 (permissive) · 1d905d8345954c70 · report fixture: signature filename:str/0/str · returned dict · level recorded 2026-09-22
jackaduma/Alpaca-LoRA-RLHF-PyTorch community (archive-listed) 1 sample, 1 ran (1 instrument-failed) · 0 unverified
collator in 16 papers tuning_lm_with_rl.py ran · our draft was wrong MIT (permissive) · bda36ad0c44dbd74 · report fixture: signature data:list/1/dict · returned dict · level recorded, date not recorded
Repository not located 2 samples, 2 ran (2 instrument-failed) · 0 unverified
2 samples are identical to code Syntology harvested from another paper's repository; this paper's own copy was not located, so no repository is named and no licence is recorded.
accuracy in 872 papers
census: 8 implementations from 7 papers, 7 distinct outputs across 6 buckets, one shared input per bucket
repository not located ran; the contract check could not run (RAISES) · metamorphic tier: deterministic fingerprinted licence of this copy not recorded · 8a38d7c525fad8f1 · report fixture: signature predictions:ndarray/1/int, references:ndarray/1/int, normalize:bool/0/bool, sample_weight:ndarray/1/float · returned dict · level recorded, date not recorded
compute_metrics in 208 papers repository not located ran; the contract check could not run (RAISES) · metamorphic tier: deterministic licence of this copy not recorded · 6b376a0abe58a427 · report fixture: signature eval_preds:tuple/1/ndarray · returned dict · level recorded, date not recorded

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