commit fdd162d8a327ec7930774cb9681443267c03df14 Author: ModelHub XC Date: Sun Nov 15 02:13:20 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: Duyu/VanMach-7B Source: Original Platform diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6d4ffe3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,37 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +tokenizer.json filter=lfs diff=lfs merge=lfs -text +images/VanMach.ai filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md new file mode 100644 index 0000000..6944fdd --- /dev/null +++ b/README.md @@ -0,0 +1,263 @@ +--- +language: +- vi +- zh +- en +license: other +license_name: seallms +license_link: https://huggingface.co/SeaLLMs/SeaLLM-13B-Chat/blob/main/LICENSE +base_model: SeaLLMs/SeaLLMs-v3-7B-Chat +library_name: transformers +pipeline_tag: text-generation +tags: +- vanmach +- van-mach +- chu-nom +- han-nom +- vietnamese +- vietnamese-culture +- classical-vietnamese +- multilingual +- qwen2 +- seallms +- cultural-heritage +--- + +

+
+ +

+ +# _VanMach-7B_ : Van Mach Large Language Model + +### Documentation Languages + +[**English**](./README.md) | [**Chinese Simplified**](./README.zh-CN.md) | [**Chinese Traditional**](./README.zh-TW.md) | [**Vietnamese**](./README.vi.md) + +## 1. Model Overview + +**Van Mach (Vietnamese: Văn Mạch; Chinese: 文脉大模型; Model ID: VanMach-7B)** is a 7B-scale multilingual large language model designed for Vietnamese traditional writing (Chữ Nôm), historical documents, and linguistic and cultural studies. Built upon [SeaLLMs-v3-7B-Chat](https://huggingface.co/SeaLLMs/SeaLLMs-v3-7B-Chat), the model enhances its capabilities in processing Vietnamese Chữ Nôm, modern Vietnamese, historical Hán-Nôm documents, and traditional Vietnamese cultural knowledge through a specially designed Chữ Nôm vocabulary expansion, purely mathematical embedding initialization, continued pre-training (CPT), and supervised fine-tuning (SFT). Unlike general-purpose models primarily developed for modern Vietnamese natural language processing tasks, our VanMach-7B places **the computational linguistic representation of Chữ Nôm, historical linguistic knowledge, and their connections to modern Vietnamese** at the center of its development. The model supports three languages and their corresponding writing systems: **Vietnamese** 【Chữ Quốc ngữ and the historically used Chữ Nôm】, **Chinese** 【Simplified Chinese and Traditional Chinese】, and **English**. + +Chữ Nôm is an important writing system historically used to represent the Vietnamese language. Although its character forms are closely related to the Chinese character system, it has distinctive characteristics in meaning, pronunciation, graphical composition, and actual usage. Many Chữ Nôm characters occur extremely infrequently in the training corpora of modern general-purpose large language models, and some cannot even obtain independent, complete Token representations through existing tokenizers. Meanwhile, the amount of digitized training data available for Chữ Nôm remains relatively limited, particularly the lack of large-scale, systematically curated, high-quality data aligned with modern Vietnamese. These circumstances present several significant challenges for conventional large language model fine-tuning methods: + +1. **Insufficient Character Representation**: Many Chữ Nôm characters lack independent Tokens and are easily split into multiple subword or byte-level Tokens, making it difficult to establish stable semantic representations for individual characters. +2. **Scarcity of Training Data**: Hán-Nôm documents and Chữ Nôm dictionaries possess substantial linguistic and historical value, but the amount of data directly usable for large language model training is relatively limited. +3. **Slow Convergence with Random Initialization**: If newly added Chữ Nôm embeddings are initialized randomly, the model must simultaneously learn fundamental character representations, pronunciation associations, and contextual semantics from limited training data. +4. **Difficulties in Cross-Script Alignment**: Chữ Nôm, Chinese characters, and modern Vietnamese Chữ Quốc ngữ have complex historical and linguistic relationships that are difficult to establish adequately through ordinary text training alone. +5. **Limited Computational Resources**: Large-scale vocabulary expansion and continued training generally require additional GPU memory and computational overhead, posing particular challenges in single-GPU environments. + +To address these challenges, VanMach-7B adopts a technical approach that differs from simple random initialization followed by direct fine-tuning: + +**First, dictionary knowledge, existing Chinese character vectors, Vietnamese pronunciation representations, and convex optimization methods are used to construct linguistically informed initial representations for newly added Chữ Nôm characters (injecting character-level embeddings) before training begins. Subsequently, CPT and SFT progressively enable the model to learn actual Chữ Nôm usage, correspondences with modern Vietnamese, and related cultural knowledge.** + +## 2. Basic Model Information + +### 2.1 Model Specifications + +| Item | Specification | +|---|---| +| Model Name | Van Mach (Vietnamese: Văn Mạch; Chinese: 文脉大模型) | +| Model ID | VanMach-7B | +| Model Type | Autoregressive causal language model | +| Model Architecture | Qwen2ForCausalLM | +| Base Model | SeaLLMs-v3-7B-Chat | +| Model Size | **7.71B** (7,713,187,328) | +| Model Weight Data Size | Approximately **14.37 GiB** (15,426,374,656 bytes) | +| Vocabulary Size | 165,676 (original size: 152,064) | +| Number of Added Chữ Nôm Tokens | **13,612** | +| Embedding Dimension | 3,584 | +| Additional Embedding and Output Layer Parameters | Untied, approximately 97.57M (97,570,816) | +| Supported Languages | Vietnamese, Chinese, English | +| Specialized Domains | Chữ Nôm, Hán-Nôm documents, modern Vietnamese, Vietnamese history and culture | + +### 2.2 Model Origins and Technical Lineage + +VanMach-7B is developed directly from SeaLLMs-v3-7B-Chat. + +

+
+ +

+ +SeaLLMs-v3-7B-Chat is a multilingual conversational model designed for Southeast Asian languages. According to the official SeaLLMs 3 technical paper, its foundation model originates from the **Qwen2 family**. + +## 3. Training Corpora and Knowledge Sources + +The training corpora of VanMach-7B primarily cover traditional Vietnamese writing, historical literature, Hán-Nôm dictionaries, optical character recognition data, and modern Vietnamese lexical knowledge. Unlike general-purpose language models trained primarily on large-scale web text, this project makes extensive use of dictionaries and textual resources with explicit linguistic structures, applying them to embedding initialization, continued pre-training, and supervised fine-tuning. + +#### Tự Điển Chữ Nôm Dẫn Giải + +*Tự Điển Chữ Nôm Dẫn Giải* (Chinese: 《喃字释义辞典》; Explanatory Dictionary of Chữ Nôm) is one of the project's important sources of Chữ Nôm linguistic knowledge. Such resources contain Chữ Nôm characters together with their pronunciations, definitions, and orthographic information, providing valuable foundations for establishing connections between Chữ Nôm and modern Vietnamese. During model development, dictionary-based data are primarily used to establish correspondences between Chữ Nôm characters and their Chữ Quốc ngữ pronunciations, provide the linguistic knowledge required for mathematical initialization of newly added Chữ Nôm Tokens, and construct structured training texts. + +#### Chữ Nôm Standardization Table of the Vietnamese Hán-Nôm Revival Committee + +The project also uses the Chữ Nôm standardization table published by **Ủy ban Phục sinh Hán Nôm Việt Nam (Chinese: 越南汉喃复兴委员会)**. These resources supplement and organize information about Chữ Nôm characters, providing references for character coverage, vocabulary expansion, and character normalization. + +#### Hugging Face Hán-Nôm and Sino-Vietnamese Pronunciation Datasets + +In addition, the training process incorporates several Hán-Nôm and Sino-Vietnamese pronunciation datasets available on Hugging Face. These datasets supplement the orthographic and phonetic relationships among Chữ Nôm, Chinese characters, Sino-Vietnamese pronunciations, and the Vietnamese language. + +#### Classical Vietnamese Literature + +To expose the model to linguistic forms within authentic historical contexts, VanMach-7B incorporates multiple works of classical Vietnamese literature. + +The main works include: + +| Corpus | Content and Training Value | +|---|---| +| *Truyện Kiều* (Chinese: 《金云翘传》) | A representative work of classical Vietnamese literature, used to construct parallel Chữ Quốc ngữ–Chữ Nôm corpora and supplement historical Vietnamese expressions and literary vocabulary | +| *Chinh phụ ngâm* (Chinese: 《征妇吟》) | Used to learn classical literary language, poetic expressions, and related cultural knowledge | +| *Lục Vân Tiên* (Chinese: 《蓼云仙》) | Used to supplement traditional Vietnamese narrative literature and historical linguistic materials | +| *Poetry of Hồ Xuân Hương* (Chinese: 《胡春香诗集》) | Used to supplement classical Vietnamese poetry, literary language, cultural imagery, and traditional expressions | +| *Đại Việt sử ký* (Chinese: 《大越史记》) | Used to supplement knowledge of Vietnamese history, traditional institutions, historical figures, geographical names, historical events, and related Literary Chinese and Hán-Nôm writing forms. | + +#### OCR Text Data + +The project uses text data released by **NomNaOCR**. + +## 4. Model Training + +The training of VanMach-7B consists of three stages. First, Chữ Nôm dictionaries, the original model's embedding space, and convex optimization methods are used to initialize the input embeddings and LM Head weights for 13,612 newly added Chữ Nôm Tokens. Next, continued pre-training (CPT) combines Hán-Nôm documents, modern Vietnamese, and structured dictionary corpora to further train the representations of newly added Chữ Nôm characters and related Chinese characters while incorporating domain-specific linguistic and cultural knowledge. Finally, supervised fine-tuning (SFT) uses parallel corpora and structured question-answering data to strengthen the model's understanding of Chữ Nôm, Hán-Nôm documents, and Vietnamese linguistic and cultural knowledge, as well as its ability to follow instructions. + +### 4.1 Initialization Method for Newly Added Chữ Nôm Embeddings + +Because the original model lacks independent Token representations for many Chữ Nôm characters, while the available Hán-Nôm training corpora and computational resources are relatively limited, direct random initialization cannot adequately exploit existing linguistic knowledge. This project therefore designs an embedding initialization algorithm based on dictionary mappings, character-form conversion, and convex optimization. Before gradient-based training begins, the algorithm constructs linguistically informed initial representations for newly added Chữ Nôm characters. Let the original model's vocabulary size be \\(V_0=152064\\) and its embedding dimension be \\(d=3584\\). Denote the input embedding matrix and the language model output weight matrix by \\(E,W\in\mathbb{R}^{V_0\times d}\\), respectively. For any Token ID \\(t\\) in the original tokenizer, let \\(E_t\\) and \\(W_t\\) denote the corresponding row vectors in these two matrices. The algorithm constructs initial vectors for new characters separately in the input and output parameter spaces. + +**Character Recognition and Direct Mapping.** First, the algorithm reads a Chữ Nôm–Chữ Quốc ngữ pronunciation dictionary, applies Unicode NFC normalization to characters and pronunciations, normalizes case and whitespace, and merges duplicate pronunciations. It then uses the original tokenizer to identify known characters: a character is considered to have a valid independent representation only if it can be encoded as exactly one non-special Token and the decoded result matches the original character exactly. For Chữ Nôm characters that cannot yet be independently encoded, the algorithm first attempts character-form conversion using OpenCC's `t2s` rules. If the converted result is a different single character that already has an independent Token, the corresponding weights are copied separately from the input embedding matrix and the LM Head. All remaining characters proceed to the pronunciation-based mathematical initialization process. + +

+
+ +

+ +**Pronunciation Representations and Reference Anchors.** To exploit the correspondences between existing characters and modern Vietnamese pronunciations, the algorithm first constructs a pronunciation reference set from the dictionary. Specifically, known characters sharing the same Chữ Quốc ngữ pronunciation are grouped together, and a set of reference vectors is established for each valid pronunciation and its corresponding known-character set. Let \\(q\\) denote a particular Chữ Quốc ngữ pronunciation, and let \\(T(q)=(t_1,\ldots,t_m)\\) be the sequence of Token IDs obtained by encoding that pronunciation with the original tokenizer, where \\(m=|T(q)|\\) is the sequence length. Let \\(H(q)\\) denote the set of Token IDs corresponding to known dictionary characters that share this pronunciation and can be independently encoded by the original tokenizer. For pronunciations with valid \\(T(q)\\) and nonempty \\(H(q)\\), define: + +$$ +v_q=\frac{1}{|T(q)|}\sum_{t\in T(q)}E_t,\qquad +C_q=\frac{1}{|H(q)|}\sum_{h\in H(q)}E_h,\qquad +U_q=\frac{1}{|H(q)|}\sum_{h\in H(q)}W_h +$$ + +Here, \\(v_q\\) represents the position of the Chữ Quốc ngữ pronunciation in the original embedding space, while \\(C_q\\) and \\(U_q\\) represent the input embedding centroid and LM Head weight centroid, respectively, of known characters sharing that pronunciation. Thus, each valid pronunciation corresponds to a triplet \\((v_q,C_q,U_q)\\), referred to as a **pronunciation anchor**. Indexed by Chữ Quốc ngữ pronunciation, a pronunciation anchor connects the vector representation of a pronunciation with the input and output parameters of existing characters through the character–pronunciation correspondences recorded in the dictionary. Pronunciation vectors are obtained by averaging the embeddings of the original tokenization results, without training an additional encoder. No valid pronunciation anchor is constructed for pronunciations that cannot be encoded properly or whose encodings contain unknown or special Tokens. Reference characters are strictly limited to dictionary characters that can already be independently encoded by the original tokenizer; the algorithm does not directly use the entire Unicode CJK character range or all Chinese characters in the original vocabulary as anchors. + +**Convex Optimization and Vector Transfer.** For a target pronunciation that has no directly available same-pronunciation character reference centroid but can be represented by the original tokenizer, the algorithm reformulates its representation problem as the projection of its pronunciation vector onto the convex hull of existing pronunciation anchors. Suppose the pronunciation reference set contains \\(n\\) valid anchors, corresponding to Chữ Quốc ngữ pronunciations \\(q_1,q_2,\ldots,q_n\\), and denote their three associated vectors by \\(v_i=v_{q_i}\\), \\(C_i=C_{q_i}\\), and \\(U_i=U_{q_i}\\), respectively. For a target pronunciation \\(q\\) not included in this reference set, the algorithm first computes its pronunciation vector \\(v_q\\) as described above. It then searches for a set of combination coefficients \\(\boldsymbol{\alpha}=(\alpha_1,\ldots,\alpha_n)\\) that minimizes the Euclidean distance between the weighted sum of reference pronunciation vectors and the target pronunciation vector: + +$$ +\boldsymbol{\alpha}^{*} +=\arg\min_{\boldsymbol{\alpha}} +\frac{1}{2}\left\| +\sum_{i=1}^{n}\alpha_i v_i-v_q +\right\|_2^2, +\qquad +\alpha_i\geq0,\quad +\sum_{i=1}^{n}\alpha_i=1 +$$ + +Here, \\(\alpha_i\\) denotes the combination weight of the \\(i\\)-th pronunciation anchor, \\(\boldsymbol{\alpha}^{*}\\) denotes the optimal coefficient vector satisfying the constraints, and \\(\|\cdot\|_2\\) denotes the Euclidean norm. This is a convex quadratic optimization problem with probability simplex constraints. Its objective is to find the position within the convex hull formed by existing pronunciation reference vectors that is closest to the target pronunciation. After solving the problem, the algorithm does not directly use the convex projection vector as the character embedding. Instead, it applies the resulting combination coefficients separately to the input and output reference centroids of the corresponding pronunciation anchors: + +$$ +\widehat E_q=\sum_{i=1}^{n}\alpha_i^{*}C_i, +\qquad +\widehat W_q=\sum_{i=1}^{n}\alpha_i^{*}U_i +$$ + +Here, \\(\widehat E_q\\) and \\(\widehat W_q\\) denote the input embedding reference vector and LM Head weight reference vector constructed for the target pronunciation \\(q\\), respectively. Thus, the Chữ Quốc ngữ pronunciation vectors determine the combination relationships among different reference anchors, while the input embeddings and LM Head weights of existing characters are used to construct the actual initialization parameters. This allows the algorithm to exploit the original model's existing Vietnamese pronunciation representations and Chinese character and Chữ Nôm parameter information, rather than placing all newly added characters at random positions. + +**Numerical Solution and Convergence Control.** The implementation employs Frank–Wolfe-type conditional gradient iterations, selecting reference vertices according to the current projection residual and updating the convex combination through an analytical line search constrained to the interval \\([0,1]\\). Rather than constructing a complete large-scale anchor Gram matrix, the algorithm uses GPU-based FP64 vector inner products and matrix operations, with periodic local refinement of the active reference set using SLSQP. Reference vectors are scale-normalized according to the median of their norms. The default maximum number of iterations is 1,800, and the optimality tolerance is \\(2\times10^{-8}\\). The Frank–Wolfe gap is also used to assess the numerical convergence of the primary optimization. + +Because different convex combinations may produce the same projection vector, the algorithm further attempts minimum-norm optimization after the primary optimization satisfies its convergence conditions. Let the projection position obtained from the primary optimization be \\(p^{*}=\sum_{i=1}^{n}\alpha_i^{*}v_i\\). Keeping this projection position unchanged, the algorithm further solves: + +$$ +\min_{\boldsymbol{\alpha}} +\frac{1}{2}\|\boldsymbol{\alpha}\|_2^2, +\qquad +\sum_{i=1}^{n}\alpha_i v_i=p^{*},\quad +\sum_{i=1}^{n}\alpha_i=1,\quad +\alpha_i\geq0 +$$ + +This secondary optimization aims to select a solution with a smaller Euclidean norm from the feasible coefficient combinations corresponding to the same projection position. If the solution passes numerical validation, the refined coefficients are used to construct the aforementioned input and output reference vectors. The secondary optimization combines singular value decomposition (SVD), SLSQP, L-BFGS-B dual optimization, and Karush–Kuhn–Tucker (KKT) optimality condition checks to seek a stable coefficient solution while preserving the projection position and convex combination constraints. If full convergence is not achieved or numerical validation fails, the program retains the best feasible combination found so far and records its corresponding status, avoiding the loss of a character's initialization result solely because of a local numerical solver failure. + +**Multiple-Pronunciation Handling and Fallback Mechanism.** For Chữ Nôm characters with multiple Chữ Quốc ngữ pronunciations, the algorithm constructs input and output reference vectors separately for each pronunciation and then takes the arithmetic mean of the resulting vectors to obtain the character's initial parameters. Specifically, let \\(c\\) be a Chữ Nôm character to be initialized, and let \\(R(c)\\) be the set of distinct Chữ Quốc ngữ pronunciations recorded for that character in the dictionary. Let \\(e_c^{(0)}\\) and \\(w_c^{(0)}\\) denote the final initial input embedding and LM Head vectors of that character, respectively. For characters initialized through pronunciation-based methods, we have: + +$$ +e_c^{(0)}=\frac{1}{|R(c)|}\sum_{q\in R(c)}\widehat E_q, +\qquad +w_c^{(0)}=\frac{1}{|R(c)|}\sum_{q\in R(c)}\widehat W_q +$$ + +For pronunciations that directly match an entry in the pronunciation reference set, \\(\widehat E_q\\) and \\(\widehat W_q\\) are taken directly from the corresponding \\(C_q\\) and \\(U_q\\). For pronunciations that do not match directly but can be encoded validly, the algorithm uses the results constructed through convex optimization. If an individual pronunciation cannot be encoded validly, lacks usable reference anchors, or cannot form a valid optimization problem, the average input embedding and average LM Head weight of all known dictionary characters are used as fallback vectors for that pronunciation. Valid results from other pronunciations are still retained and included in the final average. Therefore, fallback handling operates at the pronunciation level, rather than discarding all known information about a character because one of its pronunciations is unavailable. + +**Distinguishing Duplicate Vectors.** Newly added characters with identical pronunciation combinations or reference relationships ( **variant Chữ Nôm characters** ) may receive identical vectors during initialization. To reduce such occurrences, the program separately examines input embedding and LM Head vector representations at their actual storage precision and applies the smallest effective perturbation when necessary. Specifically, a unit direction is randomly sampled from a Gaussian distribution. Based on adjacent representable values and rounding boundaries in the actual weight formats, such as FP16, BF16, or FP32, the algorithm calculates an approximately minimal step size capable of producing an effective numerical change. Binary search is then used to further reduce the perturbation magnitude. When necessary, a one-ULP (Unit in the Last Place) adjustment to a single coordinate is used as a fallback. This procedure aims to preserve the original initialization vectors as closely as possible, while maintaining valid vector-copying relationships established through direct character-form mapping. + +This stage is completed entirely through existing weights, dictionary knowledge, and numerical computation, without any training. Its primary function is to transform existing representational relationships among Chinese characters, Chữ Nôm, and modern Vietnamese into initial parameters for newly added characters. This enables subsequent CPT to begin with linguistically informed vectors and further learn character pronunciations, usage, and semantics through actual contexts. + +### 4.2 Continued Pre-Training (CPT) + +The CPT stage primarily aims to improve Hán-Nôm character representation learning, Vietnamese language modeling, and domain-specific knowledge incorporation. The training corpora include literary and historical materials such as *Truyện Kiều*, *Chinh phụ ngâm*, *Lục Vân Tiên*, *Đại Việt sử ký*, and the poetry of Hồ Xuân Hương, as well as NomNaOCR text data, Chữ Nôm dictionaries, Chữ Nôm standardization tables, Sino-Vietnamese pronunciation datasets, and modern Vietnamese dictionaries. Continuous texts, including literary works and historical documents, are used directly for autoregressive language model training. Dictionaries, pronunciation tables, and other structured resources are converted into continuous text using predefined templates to establish relationships among Chữ Nôm characters, Chữ Quốc ngữ pronunciations, Sino-Vietnamese readings, definitions, and contexts. + +This stage employs the QLoRA algorithm, with the base model weights quantized to NF4 four-bit precision, a LoRA rank of \\(r=64\\), and a text truncation length of 1,024 Tokens. Unlike conventional approaches that train only low-rank adapters, the CPT stage also unfreezes the relevant character embeddings and LM Head, allowing character-level embeddings associated with Simplified Chinese characters, Traditional Chinese characters, and Chữ Nôm to receive explicit gradient updates while also permitting the LM Head to participate in training. This configuration enables further refinement of the newly added Chữ Nôm vectors initialized mathematically in the first stage, as well as adjustment of embeddings for Chinese characters that also function as Chữ Nôm characters. + +### 4.3 Supervised Fine-Tuning (SFT) + +The SFT stage primarily uses parallel corpora, dictionaries, and other structured data to construct supervised question-answering samples. Its purpose is to strengthen the model's ability to retrieve and apply knowledge of Chữ Nôm pronunciations, definitions, Sino-Vietnamese readings, Chữ Quốc ngữ correspondences, and Vietnamese history and culture, while further training its ability to interpret Hán-Nôm texts and respond to cross-lingual instructions. Training uses the LoRA algorithm with FP8 precision, a rank of \\(r=32\\), and a text truncation length of 1,536 Tokens. + +Unlike the CPT stage, the SFT stage freezes the input embedding layer and LM Head, updating parameters only through low-rank adapters. This configuration allows the model to preserve the character representations established during the first two stages while shifting the training focus toward structured knowledge question answering, instruction understanding, and response generation. + +| | Algorithm | Rank | Quantization Precision | Truncation Length | +| --- | --- | --- | --- | --- | +| CPT | QLoRA | 64 | NF4 | 1,024 | +| SFT | LoRA | 32 | FP8 | 1,536 | + +### 4.4 Hardware and Software Environment + +VanMach-7B was fine-tuned using a single NVIDIA GeForce RTX 5060 Ti 16GB GPU, with Axolotl v0.20.0 as the training framework. CPT and SFT employ QLoRA and LoRA, respectively, to accommodate the computational resource constraints of a single GPU with 16GB of video memory. + +## 5. Usage Example + +VanMach-7B is based on the Hugging Face Transformers ecosystem and can be loaded using the standard approach for autoregressive language models. + +```python +import torch +from transformers import AutoTokenizer, AutoModelForCausalLM + +path = "./VanMach-7B" +tokenizer = AutoTokenizer.from_pretrained(path) +model = AutoModelForCausalLM.from_pretrained( + path, torch_dtype=torch.bfloat16, device_map="cuda" +) +messages = [] + +while True: + question = input("User: ") + messages.append({"role": "user", "content": question}) + inputs = tokenizer.apply_chat_template( + messages, add_generation_prompt=True, return_tensors="pt" + ).to(model.device) + outputs = model.generate(inputs, max_new_tokens=512) + answer = tokenizer.decode( + outputs[0][inputs.shape[-1]:], skip_special_tokens=True + ) + print("Assistant:", answer) + messages.append({"role": "assistant", "content": answer}) +``` + +## 6. Sources, Licensing, and Usage Statements + +### 6.1 Licensing and Redistribution + +SeaLLMs-v3-7B-Chat is distributed under the custom SeaLLMs license. As a derivative model, VanMach-7B must comply with the applicable usage and redistribution conditions of its upstream model. These terms address original rights notices, redistribution of derivative models, modification notices, attribution, usage restrictions, and other conditions. When publishing or using this model, the applicable upstream licensing requirements must also be retained and observed. + +The technical descriptions in this model card do not constitute any modification of or exemption from the licensing restrictions of the base model. + +### 6.2 Training Data Statements + +The materials used by VanMach-7B include traditional literature, historical texts, dictionaries, OCR data, and related linguistic datasets from public platforms. Different data sources may be subject to different copyright, usage, and redistribution conditions. Public release of the model does not imply that all training materials may be redistributed without restriction. The use and redistribution of training corpora must comply with their respective applicable licenses and legal requirements. + +### 6.3 Disclaimer + +VanMach-7B is primarily intended for natural language processing, Hán-Nôm studies, and related linguistic and cultural applications. Because the model relies on statistical learning methods, its outputs may contain factual errors, pronunciation confusion, incorrect definitions, or other inaccuracies. In educational settings, historical document research, professional translation, and other contexts requiring high accuracy, model outputs should be used in conjunction with reliable reference materials and human review. + +## 7. Author + +[**DU Yu**](https://faculty.lzjtu.edu.cn/chenmei/zh_CN/xsxx/2554/content/1837.htm) (Vietnamese: ĐỖ Vũ; Chinese: 杜宇, No.11250717, Email: or or <11250717@stu.lzjtu.edu.cn> ), **School of Electronic and Information Engineering, Lanzhou Jiaotong University (Chinese: 兰州交通大学电子与信息工程学院)** diff --git a/README.vi.md b/README.vi.md new file mode 100644 index 0000000..d500dc0 --- /dev/null +++ b/README.vi.md @@ -0,0 +1,239 @@ +

+
+ +

+ +# _VanMach-7B_ : Mô hình ngôn ngữ lớn Văn Mạch + +### Ngôn ngữ tài liệu + +[**Tiếng Anh**](./README.md) | [**Tiếng Trung giản thể**](./README.zh-CN.md) | [**Tiếng Trung phồn thể**](./README.zh-TW.md) | [**Tiếng Việt**](./README.vi.md) + +## 1. Giới thiệu mô hình + +**Mô hình ngôn ngữ lớn Văn Mạch (tiếng Trung: 文脉大模型; tiếng Anh: Van Mach LLM, mã mô hình: VanMach-7B)** là một mô hình ngôn ngữ lớn đa ngôn ngữ quy mô 7B, được phát triển hướng đến chữ viết truyền thống Việt Nam (Chữ Nôm), tư liệu lịch sử và các lĩnh vực ngôn ngữ, văn hóa. Mô hình được xây dựng trên nền tảng [SeaLLMs-v3-7B-Chat](https://huggingface.co/SeaLLMs/SeaLLMs-v3-7B-Chat), thông qua các bước mở rộng bộ từ vựng Chữ Nôm được thiết kế chuyên biệt, khởi tạo embedding từ bằng phương pháp tính toán toán học thuần túy, tiếp tục tiền huấn luyện (CPT) và tinh chỉnh có giám sát theo chỉ dẫn (SFT), nhằm tăng cường khả năng xử lý Chữ Nôm Việt Nam, tiếng Việt hiện đại, tư liệu lịch sử Hán Nôm và tri thức văn hóa truyền thống Việt Nam. Khác với các mô hình đa dụng chủ yếu hướng đến những tác vụ xử lý ngôn ngữ tự nhiên tiếng Việt hiện đại, VanMach-7B của chúng tôi lấy **biểu diễn tính toán ngôn ngữ học của Chữ Nôm, tri thức ngôn ngữ lịch sử và mối liên hệ giữa chúng với tiếng Việt hiện đại** làm định hướng cốt lõi trong quá trình phát triển mô hình. Mô hình hỗ trợ ba ngôn ngữ cùng các hình thức chữ viết tương ứng: **tiếng Việt** 【Chữ Quốc ngữ và Chữ Nôm được sử dụng trong lịch sử】, **tiếng Trung** 【chữ Hán giản thể và chữ Hán phồn thể】, **tiếng Anh**. + +Chữ Nôm là một hệ thống chữ viết quan trọng từng được sử dụng để ghi chép tiếng Việt trong lịch sử. Hình thể của Chữ Nôm có mối liên hệ mật thiết với hệ thống chữ Hán, nhưng đồng thời mang những đặc điểm riêng về ý nghĩa, cách đọc, cấu tạo hình chữ và cách sử dụng thực tế. Nhiều chữ Nôm xuất hiện với tần suất cực kỳ thấp trong ngữ liệu huấn luyện của các mô hình ngôn ngữ lớn đa dụng hiện đại, thậm chí một số ký tự không thể có được biểu diễn Token độc lập và hoàn chỉnh thông qua các bộ tách Token hiện có. Trong khi đó, nguồn ngữ liệu huấn luyện Chữ Nôm đã được số hóa còn tương đối hạn chế, đặc biệt thiếu dữ liệu đối sánh với tiếng Việt hiện đại có quy mô lớn, chất lượng cao và được biên soạn một cách có hệ thống. Điều này khiến các phương pháp tinh chỉnh mô hình ngôn ngữ lớn truyền thống phải đối mặt với những thách thức đáng kể: + +1. **Biểu diễn chữ viết chưa đầy đủ**: Nhiều chữ Nôm không có Token độc lập, dễ bị tách thành nhiều Token cấp từ con hoặc cấp byte, gây khó khăn cho việc hình thành biểu diễn ngữ nghĩa ổn định ở cấp độ từng chữ. +2. **Dữ liệu huấn luyện khan hiếm**: Tư liệu Hán Nôm và từ điển Chữ Nôm có giá trị quan trọng về ngôn ngữ học và lịch sử, nhưng quy mô dữ liệu có thể trực tiếp sử dụng để huấn luyện mô hình ngôn ngữ lớn còn tương đối hạn chế. +3. **Khởi tạo ngẫu nhiên hội tụ chậm**: Nếu trực tiếp khởi tạo ngẫu nhiên embedding cho các chữ Nôm mới được bổ sung, mô hình phải đồng thời học biểu diễn cơ bản của chữ viết, mối liên hệ về cách đọc và ngữ nghĩa theo ngữ cảnh từ nguồn ngữ liệu hạn chế. +4. **Khó khăn trong căn chỉnh giữa các hệ thống chữ viết**: Chữ Nôm, chữ Hán và Chữ Quốc ngữ tiếng Việt hiện đại có những mối quan hệ lịch sử và ngôn ngữ phức tạp, khó có thể thiết lập đầy đủ các mối liên hệ này nếu chỉ dựa vào việc huấn luyện trên văn bản thông thường. +5. **Hạn chế về tài nguyên tính toán**: Việc mở rộng bộ từ vựng ở quy mô lớn và tiếp tục huấn luyện thường đòi hỏi thêm bộ nhớ GPU và chi phí tính toán, đặc biệt bất lợi trong môi trường chỉ có một GPU. + +Để giải quyết những vấn đề trên, VanMach-7B áp dụng một hướng tiếp cận kỹ thuật khác với việc chỉ khởi tạo ngẫu nhiên rồi trực tiếp tinh chỉnh: + +**Trước hết, thông qua tri thức từ điển, các vector chữ Hán hiện có, biểu diễn cách đọc tiếng Việt và phương pháp tối ưu hóa lồi, mô hình xây dựng biểu diễn khởi tạo có cơ sở ngôn ngữ học cho các chữ Nôm mới được bổ sung trước khi bắt đầu huấn luyện (đưa tri thức vào embedding ở cấp độ từng chữ). Sau đó, thông qua CPT và SFT, mô hình từng bước học cách sử dụng thực tế của Chữ Nôm, các mối quan hệ tương ứng với tiếng Việt hiện đại và tri thức văn hóa liên quan.** + +## 2. Thông tin cơ bản về mô hình + +### 2.1 Thông số kỹ thuật của mô hình + +| Hạng mục | Thông số | +|---|---| +| Tên mô hình | Văn Mạch (tiếng Trung: 文脉大模型; tiếng Anh: Van Mach) | +| Mã mô hình | VanMach-7B | +| Loại mô hình | Mô hình ngôn ngữ nhân quả tự hồi quy | +| Kiến trúc mô hình | Qwen2ForCausalLM | +| Mô hình nền tảng | SeaLLMs-v3-7B-Chat | +| Quy mô mô hình | **7.71B** (7,713,187,328) | +| Dung lượng dữ liệu trọng số mô hình | Khoảng **14.37 GiB** (15,426,374,656 byte) | +| Kích thước bộ từ vựng | 165,676 (kích thước ban đầu 152,064) | +| Số lượng Token Chữ Nôm mới được bổ sung | **13,612** | +| Số chiều embedding từ | 3,584 | +| Số tham số embedding từ và tầng đầu ra được bổ sung | Không chia sẻ trọng số, khoảng 97.57M (97,570,816) | +| Ngôn ngữ được hỗ trợ | Tiếng Việt, tiếng Trung, tiếng Anh | +| Các lĩnh vực được tăng cường | Chữ Nôm, tư liệu Hán Nôm, tiếng Việt hiện đại, lịch sử và văn hóa Việt Nam | + +### 2.2 Nguồn gốc mô hình và hệ thống kế thừa kỹ thuật + +VanMach-7B được phát triển trực tiếp trên cơ sở SeaLLMs-v3-7B-Chat. + +

+
+ +

+ +SeaLLMs-v3-7B-Chat là một mô hình hội thoại đa ngôn ngữ hướng đến các ngôn ngữ Đông Nam Á. Theo bài báo kỹ thuật chính thức của SeaLLMs 3, mô hình nền tảng của nó có nguồn gốc từ **dòng mô hình Qwen2**. + +## 3. Ngữ liệu huấn luyện và nguồn tri thức + +Ngữ liệu huấn luyện của VanMach-7B tập trung vào chữ viết truyền thống Việt Nam, văn học lịch sử, từ điển Hán Nôm, dữ liệu nhận dạng chữ viết và tri thức từ vựng tiếng Việt hiện đại. Khác với các mô hình ngôn ngữ đa dụng chỉ dựa vào lượng lớn văn bản Internet để huấn luyện, dự án này tận dụng triệt để các từ điển và tư liệu chữ viết có cấu trúc ngôn ngữ học rõ ràng, sử dụng chúng cho quá trình khởi tạo embedding từ, tiếp tục tiền huấn luyện và tinh chỉnh có giám sát theo chỉ dẫn. + +#### Tự Điển Chữ Nôm Dẫn Giải + +《Tự Điển Chữ Nôm Dẫn Giải》(tiếng Trung: 喃字释义辞典) là một trong những nguồn tri thức ngôn ngữ Chữ Nôm quan trọng của dự án. Loại tư liệu này chứa các chữ Nôm cùng những thông tin liên quan về cách đọc, giải nghĩa và chữ viết, có giá trị quan trọng đối với việc thiết lập mối liên hệ giữa Chữ Nôm và tiếng Việt hiện đại. Trong quá trình phát triển mô hình, dữ liệu có tính chất từ điển chủ yếu được sử dụng để thiết lập quan hệ tương ứng giữa chữ Nôm và cách đọc bằng Chữ Quốc ngữ, cung cấp tri thức ngôn ngữ cần thiết cho việc khởi tạo toán học các Token Chữ Nôm mới được bổ sung, đồng thời xây dựng văn bản huấn luyện có cấu trúc. + +#### Bảng tiêu chuẩn Chữ Nôm của Ủy ban Phục sinh Hán Nôm Việt Nam + +Dự án cũng sử dụng bảng tiêu chuẩn Chữ Nôm do **Ủy ban Phục sinh Hán Nôm Việt Nam(tiếng Trung: 越南汉喃复兴委员会)** công bố. Các tài nguyên liên quan được sử dụng để bổ sung và hệ thống hóa thông tin về ký tự Chữ Nôm, cung cấp cơ sở tham khảo cho phạm vi bao phủ ký tự, mở rộng bộ từ vựng và xử lý chuẩn hóa chữ viết. + +#### Các bộ dữ liệu Hán Nôm và âm Hán Việt trên Hugging Face + +Ngoài ra, quá trình huấn luyện còn sử dụng một số bộ dữ liệu Hán Nôm và âm Hán Việt trên nền tảng Hugging Face. Những dữ liệu này được dùng để bổ sung các mối liên hệ về chữ viết và ngữ âm giữa Chữ Nôm, chữ Hán, âm Hán Việt và tiếng Việt. + +#### Văn học Việt Nam cổ điển + +Để mô hình có thể tiếp xúc với các hình thức ngôn ngữ trong bối cảnh lịch sử thực tế, VanMach-7B đưa vào nhiều tác phẩm văn học cổ điển Việt Nam. + +Các tác phẩm chính bao gồm: + +| Ngữ liệu | Nội dung và giá trị huấn luyện | +|---|---| +| _Truyện Kiều_(tiếng Trung: 金云翘传) | Tác phẩm tiêu biểu của văn học cổ điển Việt Nam, được sử dụng để xây dựng ngữ liệu song song Chữ Quốc ngữ - Chữ Nôm, bổ sung cách diễn đạt tiếng Việt cổ và từ vựng văn học | +| _Chinh phụ ngâm_(tiếng Trung: 征妇吟) | Được sử dụng để học ngôn ngữ văn học cổ điển, cách diễn đạt trong thơ ca và tri thức văn hóa liên quan | +| _Lục Vân Tiên_(tiếng Trung: 蓼云仙) | Được sử dụng để bổ sung văn học tự sự truyền thống Việt Nam và tư liệu ngôn ngữ lịch sử | +| _Tập thơ Hồ Xuân Hương_ | Được sử dụng để bổ sung thơ ca cổ điển Việt Nam, ngôn ngữ văn học, hình tượng văn hóa và cách diễn đạt truyền thống | +| _Đại Việt sử ký_(tiếng Trung: 大越史记) | Được sử dụng để bổ sung kiến thức về lịch sử Việt Nam, chế độ truyền thống, nhân vật, địa danh, sự kiện lịch sử, cũng như các hình thức chữ viết Hán văn và Hán Nôm liên quan. | + +#### Dữ liệu văn bản OCR + +Dự án sử dụng dữ liệu văn bản do **NomNaOCR** công bố. + +## 4. Huấn luyện mô hình + +Quá trình huấn luyện VanMach-7B được chia thành ba giai đoạn. Trước hết, từ điển Chữ Nôm, không gian embedding của mô hình gốc và phương pháp tối ưu hóa lồi được sử dụng để khởi tạo embedding đầu vào và trọng số LM Head cho 13,612 Token Chữ Nôm mới được bổ sung. Tiếp theo, thông qua tiếp tục tiền huấn luyện (CPT), mô hình kết hợp tư liệu Hán Nôm, tiếng Việt hiện đại và ngữ liệu từ điển có cấu trúc để tiếp tục huấn luyện biểu diễn của các chữ Nôm mới và những chữ Hán liên quan, đồng thời đưa vào tri thức ngôn ngữ và văn hóa chuyên ngành. Cuối cùng, tinh chỉnh có giám sát theo chỉ dẫn (SFT) được thực hiện bằng cách sử dụng ngữ liệu song song và dữ liệu hỏi đáp có cấu trúc, nhằm tăng cường khả năng hiểu và phản hồi chỉ dẫn của mô hình đối với Chữ Nôm, tư liệu Hán Nôm và tri thức ngôn ngữ, văn hóa Việt Nam. + +### 4.1 Phương pháp khởi tạo embedding cho các chữ Nôm mới được bổ sung + +Do mô hình gốc thiếu biểu diễn Token độc lập cho nhiều chữ Nôm, trong khi ngữ liệu huấn luyện Hán Nôm và tài nguyên tính toán có thể sử dụng đều tương đối hạn chế, việc trực tiếp áp dụng khởi tạo ngẫu nhiên khó có thể tận dụng đầy đủ tri thức ngôn ngữ học hiện có. Vì vậy, dự án này thiết kế một thuật toán khởi tạo embedding từ dựa trên ánh xạ từ điển, chuyển đổi hình chữ và tối ưu hóa lồi, nhằm xây dựng biểu diễn khởi tạo có cơ sở ngôn ngữ học cho các chữ Nôm mới được bổ sung trước khi bắt đầu huấn luyện bằng gradient. Giả sử kích thước bộ từ vựng của mô hình gốc là \\(V_0=152064\\) , số chiều embedding từ là \\(d=3584\\) , ma trận embedding đầu vào và ma trận trọng số đầu ra của mô hình ngôn ngữ lần lượt được ký hiệu là \\(E,W\in\mathbb{R}^{V_0\times d}\\) . Đối với một Token ID bất kỳ \\(t\\) trong bộ tách Token gốc, ký hiệu \\(E_t\\) và \\(W_t\\) lần lượt là các vector hàng tương ứng trong hai ma trận này. Thuật toán xây dựng các vector khởi tạo cho ký tự mới một cách riêng biệt trong không gian tham số đầu vào và đầu ra. + +**Nhận dạng ký tự và ánh xạ trực tiếp.** Trước hết, thuật toán đọc từ điển ánh xạ giữa Chữ Nôm và cách đọc bằng Chữ Quốc ngữ, thực hiện chuẩn hóa Unicode NFC đối với ký tự và cách đọc, chuẩn hóa chữ hoa, chữ thường và khoảng trắng, đồng thời hợp nhất các cách đọc trùng lặp. Sau đó, bộ tách Token gốc được sử dụng để nhận dạng các ký tự đã biết: chỉ khi một ký tự có thể được mã hóa thành đúng một Token không đặc biệt và kết quả giải mã hoàn toàn trùng khớp với ký tự ban đầu thì ký tự đó mới được coi là có biểu diễn độc lập hợp lệ. Đối với những chữ Nôm chưa thể được mã hóa độc lập, thuật toán ưu tiên thử chuyển đổi hình chữ bằng quy tắc `t2s` của OpenCC; nếu kết quả chuyển đổi là một ký tự đơn khác với ký tự ban đầu và đã có Token độc lập, trọng số của ký tự đó trong ma trận embedding đầu vào và LM Head sẽ được sao chép riêng biệt. Các ký tự còn lại được chuyển sang quy trình khởi tạo toán học dựa trên cách đọc. + +

+
+ +

+ +**Biểu diễn cách đọc và các điểm neo tham chiếu.** Để tận dụng mối quan hệ tương ứng giữa các ký tự hiện có và cách đọc tiếng Việt hiện đại, trước hết thuật toán xây dựng tập tham chiếu cách đọc dựa trên từ điển. Cụ thể, các ký tự đã biết có cùng cách đọc bằng Chữ Quốc ngữ trong từ điển được nhóm lại với nhau, đồng thời một nhóm vector tham chiếu được thiết lập cho mỗi cách đọc hợp lệ cùng tập ký tự đã biết tương ứng. Giả sử \\(q\\) biểu thị một cách đọc bằng Chữ Quốc ngữ, \\(T(q)=(t_1,\ldots,t_m)\\) là chuỗi Token ID thu được khi bộ tách Token gốc mã hóa cách đọc đó, trong đó \\(m=|T(q)|\\) là độ dài chuỗi; \\(H(q)\\) là tập hợp Token ID tương ứng với những ký tự đã biết trong từ điển có cùng cách đọc đó và có thể được bộ tách Token gốc mã hóa độc lập. Đối với các cách đọc có \\(T(q)\\) hợp lệ và \\(H(q)\\) không rỗng, định nghĩa: + +$$ +v_q=\frac{1}{|T(q)|}\sum_{t\in T(q)}E_t,\qquad +C_q=\frac{1}{|H(q)|}\sum_{h\in H(q)}E_h,\qquad +U_q=\frac{1}{|H(q)|}\sum_{h\in H(q)}W_h +$$ + +Trong đó, \\(v_q\\) biểu thị vị trí của cách đọc bằng Chữ Quốc ngữ trong không gian embedding gốc, còn \\(C_q\\) và \\(U_q\\) lần lượt biểu thị tâm embedding đầu vào và tâm trọng số LM Head của các ký tự đã biết có cùng cách đọc. Như vậy, mỗi cách đọc hợp lệ tương ứng với một quan hệ tham chiếu bộ ba được tạo thành từ \\((v_q,C_q,U_q)\\) , gọi là **điểm neo cách đọc** . Điểm neo cách đọc sử dụng cách đọc bằng Chữ Quốc ngữ làm chỉ mục, thông qua quan hệ tương ứng giữa chữ và âm trong từ điển để liên kết biểu diễn vector của cách đọc với các tham số đầu vào và đầu ra của những ký tự hiện có. Vector cách đọc được tạo ra bằng cách lấy trung bình embedding của kết quả tách Token gốc mà không cần huấn luyện thêm bộ mã hóa; đối với những cách đọc chứa Token không xác định hoặc Token đặc biệt, hoặc không thể mã hóa hợp lệ, thuật toán không xây dựng điểm neo cách đọc hợp lệ. Các ký tự tham chiếu được giới hạn nghiêm ngặt trong những ký tự thuộc từ điển đã có thể được bộ tách Token gốc mã hóa độc lập, thay vì trực tiếp sử dụng toàn bộ vùng chữ Hán Unicode hoặc tất cả chữ Hán trong bộ từ vựng gốc làm điểm neo. + +**Tối ưu hóa lồi và chuyển giao vector.** Đối với cách đọc mục tiêu không thể trực tiếp thiết lập tâm tham chiếu từ các ký tự đồng âm nhưng có thể tính được vector cách đọc thông qua bộ tách Token gốc, thuật toán chuyển bài toán biểu diễn thành bài toán chiếu vector cách đọc lên bao lồi của các điểm neo cách đọc hiện có. Giả sử tập tham chiếu cách đọc chứa \\(n\\) điểm neo hợp lệ, có các cách đọc bằng Chữ Quốc ngữ tương ứng lần lượt là \\(q_1,q_2,\ldots,q_n\\) , đồng thời ký hiệu ngắn gọn ba vector của mỗi điểm neo là \\(v_i=v_{q_i}\\) , \\(C_i=C_{q_i}\\) và \\(U_i=U_{q_i}\\) . Đối với cách đọc mục tiêu \\(q\\) không nằm trong tập tham chiếu này, trước hết thuật toán tính vector cách đọc \\(v_q\\) theo phương pháp đã trình bày, sau đó tìm một tập hệ số tổ hợp \\(\boldsymbol{\alpha}=(\alpha_1,\ldots,\alpha_n)\\) sao cho khoảng cách Euclid giữa tổng có trọng số của các vector cách đọc tham chiếu và vector cách đọc mục tiêu đạt giá trị nhỏ nhất: + +$$ +\boldsymbol{\alpha}^{*} +=\arg\min_{\boldsymbol{\alpha}} +\frac{1}{2}\left\| +\sum_{i=1}^{n}\alpha_i v_i-v_q +\right\|_2^2, +\qquad +\alpha_i\geq0,\quad +\sum_{i=1}^{n}\alpha_i=1 +$$ + +Trong đó, \\(\alpha_i\\) biểu thị trọng số tổ hợp của điểm neo cách đọc thứ \\(i\\) , \\(\boldsymbol{\alpha}^{*}\\) biểu thị vector hệ số tối ưu thỏa mãn các điều kiện ràng buộc, còn \\(\|\cdot\|_2\\) biểu thị chuẩn Euclid. Đây là một bài toán tối ưu hóa bậc hai lồi với ràng buộc đơn hình xác suất, có mục tiêu tìm vị trí gần nhất với cách đọc mục tiêu trong bao lồi được tạo bởi các vector cách đọc tham chiếu hiện có. Sau khi giải bài toán, thuật toán không trực tiếp sử dụng vector hình chiếu lồi làm embedding ký tự, mà áp dụng các hệ số tổ hợp thu được lần lượt lên các tâm tham chiếu đầu vào và đầu ra của những điểm neo cách đọc tương ứng: + +$$ +\widehat E_q=\sum_{i=1}^{n}\alpha_i^{*}C_i, +\qquad +\widehat W_q=\sum_{i=1}^{n}\alpha_i^{*}U_i +$$ + +Trong đó, \\(\widehat E_q\\) và \\(\widehat W_q\\) lần lượt biểu thị vector tham chiếu embedding đầu vào và vector tham chiếu trọng số LM Head được xây dựng dựa trên cách đọc mục tiêu \\(q\\) . Do đó, vector cách đọc bằng Chữ Quốc ngữ đảm nhiệm việc xác định quan hệ tổ hợp giữa các điểm neo tham chiếu khác nhau, trong khi embedding đầu vào và trọng số LM Head của những ký tự hiện có được sử dụng để xây dựng các tham số khởi tạo thực tế. Điều này cho phép thuật toán tận dụng biểu diễn cách đọc tiếng Việt cùng thông tin tham số chữ Hán và Chữ Nôm đã có trong mô hình gốc, thay vì đặt tất cả ký tự mới vào những vị trí ngẫu nhiên. + +**Giải số và kiểm soát hội tụ.** Trong quá trình triển khai thực tế, thuật toán sử dụng phương pháp lặp gradient có điều kiện kiểu Frank–Wolfe, lựa chọn đỉnh tham chiếu dựa trên phần dư hình chiếu hiện tại và cập nhật tổ hợp lồi thông qua phép tìm kiếm bước giải tích bị ràng buộc trong khoảng \\([0,1]\\) . Thuật toán không xây dựng toàn bộ ma trận Gram của tập điểm neo quy mô lớn, mà sử dụng GPU để thực hiện tích vô hướng vector và các phép toán ma trận ở độ chính xác FP64, đồng thời định kỳ sử dụng SLSQP để hiệu chỉnh cục bộ tập tham chiếu đang hoạt động. Các vector tham chiếu được chuẩn hóa tỷ lệ theo trung vị chuẩn của chúng. Số vòng lặp tối đa mặc định là 1,800, dung sai tối ưu là \\(2\times10^{-8}\\) , đồng thời khoảng cách tối ưu Frank–Wolfe được sử dụng để đánh giá mức độ hội tụ số của quá trình tối ưu hóa chính. + +Do các tổ hợp lồi khác nhau có thể tạo ra cùng một vector hình chiếu, sau khi quá trình tối ưu hóa chính đáp ứng điều kiện hội tụ, thuật toán tiếp tục thử thực hiện tối ưu hóa chuẩn nhỏ nhất. Giả sử vị trí hình chiếu thu được từ quá trình tối ưu hóa chính là \\(p^{*}=\sum_{i=1}^{n}\alpha_i^{*}v_i\\) , khi giữ nguyên vị trí hình chiếu này, thuật toán tiếp tục giải bài toán: + +$$ +\min_{\boldsymbol{\alpha}} +\frac{1}{2}\|\boldsymbol{\alpha}\|_2^2, +\qquad +\sum_{i=1}^{n}\alpha_i v_i=p^{*},\quad +\sum_{i=1}^{n}\alpha_i=1,\quad +\alpha_i\geq0 +$$ + +Bước tối ưu hóa thứ cấp này nhằm lựa chọn nghiệm có chuẩn Euclid nhỏ hơn trong số các tổ hợp hệ số khả thi tương ứng với cùng một vị trí hình chiếu. Nếu nghiệm vượt qua quá trình kiểm tra số, các hệ số đã hiệu chỉnh sẽ được sử dụng để xây dựng các vector tham chiếu đầu vào và đầu ra nêu trên. Quá trình tối ưu hóa thứ cấp kết hợp phân rã giá trị kỳ dị (SVD), SLSQP, tối ưu hóa đối ngẫu L-BFGS-B và kiểm tra các điều kiện tối ưu Karush–Kuhn–Tucker (KKT), nhằm tìm kiếm nghiệm hệ số ổn định trong khi vẫn giữ nguyên vị trí hình chiếu và các ràng buộc tổ hợp lồi. Đối với các trường hợp chưa đạt hội tụ hoàn toàn hoặc không vượt qua kiểm tra số, chương trình giữ lại tổ hợp khả thi tốt hơn đã tìm được và ghi nhận trạng thái tương ứng, tránh việc trực tiếp làm mất kết quả khởi tạo ký tự chỉ vì quá trình giải số cục bộ thất bại. + +**Xử lý nhiều cách đọc và cơ chế dự phòng.** Đối với các chữ Nôm có nhiều cách đọc bằng Chữ Quốc ngữ, thuật toán xây dựng riêng các vector tham chiếu đầu vào và đầu ra tương ứng với từng cách đọc, sau đó lấy trung bình số học của kết quả từ các cách đọc để thu được tham số khởi tạo của ký tự đó. Cụ thể, giả sử \\(c\\) là chữ Nôm cần khởi tạo, \\(R(c)\\) là tập hợp các cách đọc bằng Chữ Quốc ngữ khác nhau được ghi nhận cho ký tự này trong từ điển, còn \\(e_c^{(0)}\\) và \\(w_c^{(0)}\\) lần lượt là vector embedding đầu vào và vector LM Head khởi tạo cuối cùng của ký tự đó. Đối với những ký tự được khởi tạo dựa trên cách đọc, ta có: + +$$ +e_c^{(0)}=\frac{1}{|R(c)|}\sum_{q\in R(c)}\widehat E_q, +\qquad +w_c^{(0)}=\frac{1}{|R(c)|}\sum_{q\in R(c)}\widehat W_q +$$ + +Trong đó, đối với cách đọc có thể khớp trực tiếp với tập tham chiếu cách đọc, \\(\widehat E_q\\) và \\(\widehat W_q\\) được lấy trực tiếp từ \\(C_q\\) và \\(U_q\\) tương ứng; đối với cách đọc không khớp trực tiếp nhưng vẫn có thể được mã hóa hợp lệ, thuật toán sử dụng kết quả được xây dựng thông qua tối ưu hóa lồi. Nếu một cách đọc riêng lẻ không thể được mã hóa hợp lệ, thiếu điểm neo tham chiếu khả dụng hoặc không thể thiết lập bài toán tối ưu hóa hợp lệ, vector embedding đầu vào trung bình và vector trọng số LM Head trung bình của tất cả ký tự đã biết trong từ điển sẽ được sử dụng làm vector dự phòng cho cách đọc đó; các kết quả hợp lệ đã có từ những cách đọc khác vẫn được giữ lại và tham gia vào phép tính trung bình cuối cùng. Vì vậy, cơ chế dự phòng của thuật toán được thực hiện ở cấp độ cách đọc, thay vì loại bỏ toàn bộ thông tin đã biết của một ký tự chỉ vì thiếu một cách đọc. + +**Phân biệt các vector trùng lặp.** Đối với các ký tự mới được bổ sung có cùng tổ hợp cách đọc hoặc quan hệ tham chiếu ( **các dị thể Chữ Nôm** ), quá trình khởi tạo có thể tạo ra những vector giống nhau. Để giảm thiểu tình trạng này, chương trình kiểm tra riêng biểu diễn vector của embedding đầu vào và LM Head ở độ chính xác lưu trữ thực tế, đồng thời thực hiện nhiễu loạn hiệu quả nhỏ nhất khi cần thiết. Cụ thể, thuật toán lấy mẫu ngẫu nhiên một hướng đơn vị từ phân phối Gauss, dựa trên các giá trị có thể biểu diễn liền kề và ranh giới làm tròn của những định dạng trọng số thực tế như FP16, BF16 hoặc FP32 để tính toán kích thước bước nhỏ nhất xấp xỉ có khả năng tạo ra thay đổi số học có hiệu lực, sau đó sử dụng tìm kiếm nhị phân để tiếp tục thu nhỏ biên độ nhiễu loạn; khi cần thiết, phép điều chỉnh một ULP (Unit in the Last Place, tức đơn vị ở vị trí chữ số cuối cùng) trên một tọa độ đơn lẻ được sử dụng làm phương án dự phòng. Quá trình này tuân theo nguyên tắc bảo toàn vector khởi tạo ban đầu ở mức tối đa có thể, đồng thời giữ nguyên các quan hệ sao chép vector hợp lệ được thiết lập thông qua ánh xạ trực tiếp hình chữ. + +Giai đoạn này được hoàn thành hoàn toàn dựa trên các trọng số hiện có, tri thức từ điển và tính toán số, không thực hiện huấn luyện. Vai trò chủ yếu của nó là chuyển đổi các mối quan hệ biểu diễn hiện có giữa chữ Hán, Chữ Nôm và tiếng Việt hiện đại thành các tham số khởi tạo cho ký tự mới, giúp giai đoạn CPT tiếp theo có thể bắt đầu từ các vector có cơ sở ngôn ngữ học, rồi tiếp tục học cách đọc, cách sử dụng và ngữ nghĩa của ký tự thông qua ngữ cảnh thực tế. + +### 4.2 Tiếp tục tiền huấn luyện (CPT) + +Giai đoạn CPT chủ yếu hướng đến việc học biểu diễn chữ Hán Nôm, mô hình hóa ngôn ngữ tiếng Việt và đưa tri thức chuyên ngành vào mô hình. Ngữ liệu huấn luyện bao gồm các tư liệu văn học và lịch sử như 《Truyện Kiều》《Chinh phụ ngâm》《Lục Vân Tiên》《Đại Việt sử ký》《Tập thơ Hồ Xuân Hương》, dữ liệu văn bản NomNaOCR, cùng các từ điển Chữ Nôm, bảng tiêu chuẩn Chữ Nôm, bộ dữ liệu âm Hán Việt và từ điển tiếng Việt hiện đại. Đối với các văn bản liên tục như tác phẩm văn học và tư liệu lịch sử, quá trình huấn luyện mô hình ngôn ngữ tự hồi quy được thực hiện trực tiếp; đối với từ điển, bảng cách đọc và các tài liệu có cấu trúc khác, dữ liệu được chuyển đổi thành văn bản liên tục theo các mẫu định nghĩa trước, nhằm thiết lập mối liên hệ giữa ký tự Chữ Nôm, cách đọc bằng Chữ Quốc ngữ, âm Hán Việt, giải nghĩa và ngữ cảnh. + +Giai đoạn này sử dụng thuật toán QLoRA, với trọng số mô hình nền tảng được lượng tử hóa bốn bit theo định dạng NF4, hạng LoRA được đặt là \\(r=64\\) , và độ dài cắt ngắn văn bản là 1,024 Token. Khác với phương pháp thông thường chỉ huấn luyện các bộ thích ứng hạng thấp, giai đoạn CPT còn bỏ trạng thái đóng băng đối với các embedding ký tự liên quan và LM Head, cho phép embedding ở cấp độ từng chữ của các chữ Hán giản thể, chữ Hán phồn thể và Chữ Nôm được cập nhật gradient một cách trực tiếp, đồng thời cho phép LM Head tham gia huấn luyện. Cách thiết lập này vừa có thể tiếp tục hiệu chỉnh các vector Chữ Nôm mới được khởi tạo bằng phương pháp toán học ở giai đoạn đầu tiên, vừa có thể điều chỉnh embedding của các chữ Hán đồng thời được sử dụng làm chữ Nôm. + +### 4.3 Tinh chỉnh có giám sát theo chỉ dẫn (SFT) + +Giai đoạn SFT chủ yếu sử dụng ngữ liệu song song, từ điển và các dữ liệu có cấu trúc khác để xây dựng các mẫu hỏi đáp có giám sát, nhằm tăng cường khả năng vận dụng tri thức của mô hình về cách đọc Chữ Nôm, giải nghĩa, âm Hán Việt, quan hệ tương ứng với Chữ Quốc ngữ và lịch sử, văn hóa Việt Nam, đồng thời tiếp tục huấn luyện khả năng giải thích văn bản Hán Nôm và phản hồi các chỉ dẫn xuyên ngôn ngữ. Quá trình huấn luyện sử dụng thuật toán LoRA với độ chính xác FP8, hạng được đặt là \\(r=32\\) , và độ dài cắt ngắn văn bản là 1,536 Token. + +Khác với giai đoạn CPT, giai đoạn SFT đóng băng tầng embedding đầu vào và LM Head, chỉ cập nhật tham số thông qua các bộ thích ứng hạng thấp. Thiết lập này cho phép mô hình duy trì các biểu diễn ký tự đã được hình thành trong hai giai đoạn trước, đồng thời chuyển trọng tâm huấn luyện sang hỏi đáp tri thức có cấu trúc, hiểu chỉ dẫn và sinh câu trả lời. + +| | Thuật toán | Hạng | Độ chính xác lượng tử hóa | Độ dài cắt ngắn | +| --- | --- | --- | --- | --- | +| CPT | QLoRA | 64 | NF4 | 1,024 | +| SFT | LoRA | 32 | FP8 | 1,536 | + +### 4.4 Môi trường phần cứng và phần mềm + +VanMach-7B được tinh chỉnh bằng một GPU NVIDIA GeForce RTX 5060 Ti 16GB duy nhất, sử dụng framework huấn luyện Axolotl v0.20.0. Hai giai đoạn CPT và SFT lần lượt sử dụng QLoRA và LoRA nhằm thích ứng với giới hạn tài nguyên tính toán của môi trường một GPU có bộ nhớ đồ họa 16GB. + +## 5. Ví dụ sử dụng + +VanMach-7B được xây dựng trên hệ sinh thái Hugging Face Transformers và có thể được tải bằng phương pháp tiêu chuẩn dành cho mô hình ngôn ngữ tự hồi quy. + +```python +import torch +from transformers import AutoTokenizer, AutoModelForCausalLM + +path = "./VanMach-7B" +tokenizer = AutoTokenizer.from_pretrained(path) +model = AutoModelForCausalLM.from_pretrained( + path, torch_dtype=torch.bfloat16, device_map="cuda" +) +messages = [] + +while True: + question = input("User: ") + messages.append({"role": "user", "content": question}) + inputs = tokenizer.apply_chat_template( + messages, add_generation_prompt=True, return_tensors="pt" + ).to(model.device) + outputs = model.generate(inputs, max_new_tokens=512) + answer = tokenizer.decode( + outputs[0][inputs.shape[-1]:], skip_special_tokens=True + ) + print("Assistant:", answer) + messages.append({"role": "assistant", "content": answer}) +``` + +## 6. Nguồn gốc, giấy phép và tuyên bố sử dụng + +### 6.1 Giấy phép và phân phối lại + +SeaLLMs-v3-7B-Chat sử dụng giấy phép tùy chỉnh của SeaLLMs. Là một mô hình phái sinh từ mô hình này, VanMach-7B phải tuân thủ các điều kiện sử dụng và phân phối lại hiện hành áp dụng cho mô hình gốc. Các điều khoản liên quan bao gồm tuyên bố quyền sở hữu ban đầu, phân phối lại mô hình phái sinh, thông báo sửa đổi, ghi nhận nguồn gốc và tác giả, hạn chế sử dụng cùng các điều kiện khác. Khi công bố và sử dụng mô hình này, các yêu cầu cấp phép áp dụng từ mô hình gốc cũng phải được giữ nguyên và tuân thủ. + +Các mô tả kỹ thuật trong thẻ mô hình này không cấu thành bất kỳ sự sửa đổi hoặc miễn trừ nào đối với những hạn chế cấp phép của mô hình nền tảng. + +### 6.2 Tuyên bố liên quan đến dữ liệu huấn luyện + +Các tài liệu được VanMach-7B sử dụng bao gồm văn học truyền thống, văn bản lịch sử, từ điển, dữ liệu OCR và các bộ dữ liệu ngôn ngữ liên quan trên những nền tảng công khai. Các nguồn dữ liệu khác nhau có thể chịu sự điều chỉnh của những điều kiện khác nhau về bản quyền, sử dụng và phân phối lại. Việc công bố rộng rãi mô hình không đồng nghĩa với việc tất cả tài liệu huấn luyện đều có thể được phân phối lại mà không bị hạn chế. Việc sử dụng và phân phối lại ngữ liệu huấn luyện phải tuân thủ các giấy phép và yêu cầu pháp luật tương ứng áp dụng cho từng nguồn dữ liệu. + +### 6.3 Tuyên bố miễn trừ trách nhiệm + +VanMach-7B chủ yếu được sử dụng trong xử lý ngôn ngữ tự nhiên, nghiên cứu chữ viết Hán Nôm và các ứng dụng ngôn ngữ, văn hóa liên quan. Do mô hình sử dụng các phương pháp học thống kê, kết quả đầu ra có thể chứa sai sót về sự kiện, nhầm lẫn cách đọc, giải nghĩa không chính xác hoặc những nội dung thiếu chính xác khác. Trong các lĩnh vực giáo dục, nghiên cứu tư liệu lịch sử, dịch thuật chuyên nghiệp và những trường hợp khác đòi hỏi độ chính xác cao, kết quả do mô hình tạo ra cần được sử dụng kết hợp với tài liệu tham khảo đáng tin cậy và quá trình kiểm tra của con người. + +## 7. Tác giả + +**Học Viện Điện Tử Và Công Nghệ Thông Tin, Đại Học Giao thông Lan Châu** [**ĐỖ Vũ**](https://faculty.lzjtu.edu.cn/chenmei/zh_CN/xsxx/2554/content/1837.htm)(tiếng Trung: 杜宇, tiếng Anh: DU Yu, No.11250717, email: hoặc hoặc <11250717@stu.lzjtu.edu.cn> ) + diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 0000000..f59192a --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,238 @@ +

+
+ +

+ +# 文脉大模型 VanMach-7B + +### 文档语言 + +[**英语**](./README.md) | [**简体中文**](./README.zh-CN.md) | [**繁体中文**](./README.zh-TW.md) | [**越南语**](./README.vi.md) + +## 1. 模型简介 + +**文脉大模型(越南语:Văn Mạch;英语:Van Mach,模型编号:VanMach-7B)** 是一款面向越南传统文字(喃字)、历史文献与语言文化领域的 7B 量级多语言大语言模型。模型以 [SeaLLMs-v3-7B-Chat](https://huggingface.co/SeaLLMs/SeaLLMs-v3-7B-Chat) 为基座,通过专门设计的喃字词表扩展、纯数学计算的词嵌入初始化、增量预训练(CPT)以及指令监督微调(SFT)等步骤,增强模型对越南喃字(Chữ Nôm)、现代越南语、汉喃历史文献及越南传统文化知识的处理能力。不同于主要针对现代越南语自然语言处理任务的通用模型,我们的 VanMach-7B 将 **喃字的语言学计算表示、历史语言知识与现代越南语之间的关联** 作为模型开发的核心方向。模型支持以下三种语言及其相应书写形式: **越南语** 【国语字(Chữ Quốc ngữ)以及历史上使用的喃字(Chữ Nôm)】、**中文** 【简体中文与繁体中文】、**英语**。 + +喃字是越南历史上用于书写越南语的重要文字系统,其字形与汉字体系具有密切联系,但在字义、读音、字形构成以及实际用法方面又具有自身的特点。大量喃字在现代通用大模型的训练语料中出现频率极低,部分字符甚至无法通过已有分词器获得独立、完整的 Token 表示。与此同时,喃字可利用的数字化训练语料相对有限,尤其缺少大规模、经过系统整理的高质量现代语对齐数据。这使得传统的大模型微调方法面临较为突出的挑战: + +1. **文字表示不足**:大量喃字缺少独立 Token,容易被拆分为多个子词或字节级 Token,难以直接形成稳定的单字语义表示。 +2. **训练数据稀缺**:汉喃文献及喃字辞书具有重要的语言学和历史价值,但可直接用于大模型训练的规模相对有限。 +3. **随机初始化收敛缓慢**:如果直接为新增喃字随机初始化词嵌入,则模型需要在有限语料中同时学习文字的基本表示、读音关联和上下文语义。 +4. **跨文字系统对齐困难**:喃字、汉字以及现代越南语国语字之间具有复杂的历史和语言关系,难以仅依赖普通文本训练充分建立联系。 +5. **计算资源受限**:大规模词表扩展与持续训练通常需要额外显存及计算开销,对单卡环境尤其不利。 + +针对上述问题,VanMach-7B 采用了一条不同于单纯随机初始化与直接微调的技术路线: + +**首先通过辞书知识、已有汉字向量、越南语读音表示与凸优化方法,在训练开始前为新增喃字构造具有语言学依据的初始表示(注入单字的词嵌入),随后通过CPT与SFT逐步学习喃字的实际用法、现代越南语对应关系以及相关文化知识。** + +## 2. 模型基本信息 + +### 2.1 模型规格 + +| 项目 | 规格 | +|---|---| +| 模型名称 | 文脉大模型(越:Văn Mạch;英:Van Mach) | +| 模型编号 | VanMach-7B | +| 模型类型 | 自回归因果语言模型 | +| 模型架构 | Qwen2ForCausalLM | +| 基座模型 | SeaLLMs-v3-7B-Chat | +| 模型规模 | 7.71B (7,713,187,328) | +| 模型权重数据大小 | 约 14.37 GiB (15,426,374,656 字节) | +| 词表大小 | 165,676 (原始大小 152,064) | +| 新增喃字 Token 数量 | 13,612 | +| 词嵌入维度 | 3,584 | +| 新增词嵌入及输出层参数 | 不共享,约 97.57M (97,570,816) | +| 支持语言 | 越南语、中文、英语 | +| 强化领域 | 喃字、汉喃文献、现代越南语、越南历史文化 | + +### 2.2 模型来源与技术谱系 + +VanMach-7B 直接基于 SeaLLMs-v3-7B-Chat 进行开发。 + +

+
+ +

+ +SeaLLMs-v3-7B-Chat 是面向东南亚语言的多语言对话模型,根据 SeaLLMs 3 官方技术论文,其基础模型来源为 **Qwen2 系列**。 + +## 3. 训练语料与知识来源 + +VanMach-7B 的训练语料重点覆盖越南传统文字、历史文学、汉喃辞书、文字识别数据以及现代越南语词汇知识。与仅依靠大规模网络文本训练的通用语言模型不同,本项目充分利用具有明确语言学结构的辞书和文字资料,将其用于词嵌入初始化、增量预训练和指令监督微调。 + +#### Tự Điển Chữ Nôm Dẫn Giải + +《Tự Điển Chữ Nôm Dẫn Giải》(喃字释义辞典)是本项目的重要喃字语言知识来源之一。这类资料包含喃字及其相关读音、释义和文字信息,对于建立喃字与现代越南语之间的联系具有重要价值。在模型开发中,辞书性质的数据主要用于建立喃字与越南语国语字读音之间的对应关系、为新扩展的喃字 Token 构建数学初始化所需的语言知识,以及构造结构化训练文本。 + +#### 越南汉喃复兴委员会喃字标准表 + +项目还使用了由 **Ủy ban Phục sinh Hán Nôm Việt Nam(越南汉喃复兴委员会)** 发布的喃字标准表。相关资源用于补充和整理喃字字符信息,为字符覆盖、词表扩展及文字标准化处理提供参考。 + +#### Hugging Face 汉喃与汉越音数据集 + +此外,训练还使用了 Hugging Face 平台上的若干汉喃数据集及汉越音数据集,这些数据用于补充喃字、汉字、汉越音与越南语之间的文字和语音关联。 + +#### 古代越南文学 + +为了使模型能够接触真实历史语境中的语言形式,VanMach-7B 引入了多部越南古典文学作品。 + +主要包括: + +| 语料 | 内容与训练价值 | +|---|---| +| 《金云翘传》(Truyện Kiều) | 越南古典文学中的代表性作品,用于构造国语字-喃字平行语料、补充古代越南语表达和文学词汇 | +| 《征妇吟》(Chinh phụ ngâm) | 用于学习古典文学语言、诗歌表达及相关文化知识 | +| 《蓼云仙》(Lục Vân Tiên) | 用于补充越南传统叙事文学及历史语言资料 | +| 《胡春香诗集》 | 用于补充越南古典诗歌、文学语言、文化意象及传统表达 | +| 《大越史记》 | 用于补充越南历史、传统制度、人物、地名、历史事件以及相关文言与汉喃书写形式。 | + +#### OCR 文本数据 + +项目使用了 **NomNaOCR** 发布的文本数据。 + +## 4. 模型训练 + +VanMach-7B 的训练分为三个阶段:首先利用喃字辞书、原始模型的词嵌入空间和凸优化方法,为新增的 13,612 个喃字 Token 初始化输入词嵌入及 LM Head 权重。随后通过增量预训练(CPT),结合汉喃文献、现代越南语及结构化辞书语料,进一步训练新增喃字和相关汉字的表示,并注入领域语言与文化知识。最后采用指令监督微调(SFT),利用平行语料及结构化问答数据强化模型对喃字、汉喃文献和越南语言文化知识的理解与指令响应能力。 + +### 4.1 新增喃字词嵌入初始化方法 + +由于原始模型对大量喃字缺乏独立的 Token 表示,而汉喃文献的可用训练语料和计算资源均较为有限,直接采用随机初始化难以充分利用已有的语言学知识。本项目因此设计了一套基于辞书映射、字形转换与凸优化的词嵌入初始化算法,在正式梯度训练之前,为新增喃字构造具有语言学依据的初始表示。设原始模型的词表大小为 \\(V_0=152064\\) ,词嵌入维度为 \\(d=3584\\) ,输入词嵌入矩阵与语言模型输出权重矩阵分别记为 \\(E,W\in\mathbb{R}^{V_0\times d}\\) 。对于原始分词器中的任意 Token ID \\(t\\) ,以 \\(E_t\\) 和 \\(W_t\\) 分别表示两个矩阵中对应的行向量。算法分别在输入与输出参数空间中构造新增字符的初始向量。 + +**字符识别与直接映射。** 首先读取喃字—国语字读音字典,对字符和读音进行 Unicode NFC 规范化、大小写及空白归一化,并合并重复读音。随后使用原始分词器识别已知字符:仅当某字符能够被编码为一个非特殊 Token,且解码结果与原始字符完全一致时,才认为其具有有效的独立表示。对于尚未被独立编码的喃字,优先通过 OpenCC 的 `t2s` 规则进行字形转换;若转换结果为不同的单字符,且已存在独立 Token,则分别复制该字符在输入词嵌入矩阵和 LM Head 中的权重。其余字符进入基于读音的数学初始化流程。 + +

+
+ +

+ +**读音表示与参考锚点。** 为利用已有字符与现代越南语读音之间的对应关系,算法首先根据字典构建读音参考集合。具体而言,将字典中具有相同国语字读音的已知字符归为一组,并以每一种有效读音及其对应的已知字符集合建立一组参考向量。设 \\(q\\) 表示某一国语字读音, \\(T(q)=(t_1,\ldots,t_m)\\) 为原始分词器对该读音编码得到的 Token ID 序列,其中 \\(m=|T(q)|\\) 为序列长度; \\(H(q)\\) 为字典中具有该读音、且能够被原始分词器独立编码的已知字符所对应的 Token ID 集合。对于 \\(T(q)\\) 有效且 \\(H(q)\\) 非空的读音,定义: + +$$ +v_q=\frac{1}{|T(q)|}\sum_{t\in T(q)}E_t,\qquad +C_q=\frac{1}{|H(q)|}\sum_{h\in H(q)}E_h,\qquad +U_q=\frac{1}{|H(q)|}\sum_{h\in H(q)}W_h +$$ + +其中, \\(v_q\\) 表示国语字读音在原始词嵌入空间中的位置, \\(C_q\\) 和 \\(U_q\\) 分别表示同音已知字符的输入嵌入中心和 LM Head 权重中心。由此,每一种有效读音均对应一个由 \\((v_q,C_q,U_q)\\) 构成的三元参考关系,称为 **读音锚点** 。读音锚点以国语字读音为索引,通过字典中的字音对应关系,将读音的向量表示与已有字符的输入、输出参数联系起来。读音向量通过对原始分词结果取嵌入均值获得,不额外训练编码器;对于包含未知 Token 或特殊 Token、无法有效编码的读音,则不构建有效读音锚点。参考字符严格限定为字典中已被原始分词器独立编码的字符,不直接使用整个 Unicode 汉字区或原始词表中的全部汉字作为锚点。 + +**凸优化与向量迁移。** 对于无法直接建立同音字符参考中心、但能够通过原始分词器计算读音向量的目标读音,算法将其表示问题转化为读音向量在已有读音锚点凸包上的投影问题。设读音参考集合包含 \\(n\\) 个有效锚点,其对应的国语字读音依次为 \\(q_1,q_2,\ldots,q_n\\) ,并简记各锚点的三个向量为 \\(v_i=v_{q_i}\\) 、 \\(C_i=C_{q_i}\\) 和 \\(U_i=U_{q_i}\\) 。对于未包含在该参考集合中的目标读音 \\(q\\) ,首先按照前述方法计算其读音向量 \\(v_q\\) ,然后寻找一组组合系数 \\(\boldsymbol{\alpha}=(\alpha_1,\ldots,\alpha_n)\\) ,使参考读音向量的加权和与目标读音向量之间的欧氏距离最小: + +$$ +\boldsymbol{\alpha}^{*} +=\arg\min_{\boldsymbol{\alpha}} +\frac{1}{2}\left\| +\sum_{i=1}^{n}\alpha_i v_i-v_q +\right\|_2^2, +\qquad +\alpha_i\geq0,\quad +\sum_{i=1}^{n}\alpha_i=1 +$$ + +其中, \\(\alpha_i\\) 表示第 \\(i\\) 个读音锚点的组合权重, \\(\boldsymbol{\alpha}^{*}\\) 表示满足约束条件的最优系数向量, \\(\|\cdot\|_2\\) 表示欧氏范数。该问题是具有概率单纯形约束的凸二次优化问题,其目标是在已有读音参考向量构成的凸包中寻找最接近目标读音的位置。求解后,算法并不直接以凸投影向量作为字符嵌入,而是将得到的组合系数分别应用于对应读音锚点的输入、输出参考中心: + +$$ +\widehat E_q=\sum_{i=1}^{n}\alpha_i^{*}C_i, +\qquad +\widehat W_q=\sum_{i=1}^{n}\alpha_i^{*}U_i +$$ + +其中, \\(\widehat E_q\\) 和 \\(\widehat W_q\\) 分别表示根据目标读音 \\(q\\) 构造的输入嵌入参考向量和 LM Head 权重参考向量。因此,国语字读音向量负责确定不同参考锚点之间的组合关系,而已有字符的输入嵌入与 LM Head 权重则用于构造实际的初始化参数。这使算法能够利用原始模型已有的越南语读音表示和汉字、喃字参数信息,而不是将所有新增字符置于随机位置。 + +**数值求解与收敛控制。** 实际实现采用 Frank–Wolfe 型条件梯度迭代,以当前投影残差为依据选择参考顶点,并通过约束在 \\([0,1]\\) 区间内的解析线搜索更新凸组合。算法不构造完整的大规模锚点 Gram 矩阵,而是利用 GPU 执行 FP64 向量内积与矩阵运算,并对活动参考集合定期使用 SLSQP 进行局部修正。参考向量按照其范数中位数进行尺度归一化,默认最大迭代次数为 1,800,最优性容差为 \\(2\times10^{-8}\\) ,同时依据 Frank–Wolfe 间隙判断主优化的数值收敛情况。 + +考虑到不同凸组合可能产生相同的投影向量,算法在主优化满足收敛条件后进一步尝试最小范数优化。设主优化得到的投影位置为 \\(p^{*}=\sum_{i=1}^{n}\alpha_i^{*}v_i\\) ,则在保持该投影位置不变的条件下,进一步求解: + +$$ +\min_{\boldsymbol{\alpha}} +\frac{1}{2}\|\boldsymbol{\alpha}\|_2^2, +\qquad +\sum_{i=1}^{n}\alpha_i v_i=p^{*},\quad +\sum_{i=1}^{n}\alpha_i=1,\quad +\alpha_i\geq0 +$$ + +该次级优化旨在从对应同一投影位置的可行系数组合中选择欧氏范数较小的解;若其通过数值验证,则使用修正后的系数进行前述输入和输出参考向量的构造。次级优化结合奇异值分解(SVD)、SLSQP、L-BFGS-B 对偶优化及 Karush–Kuhn–Tucker(KKT)最优性条件检查,在保持投影位置与凸组合约束的前提下尝试获得稳定的系数解。对于未达到完整收敛或数值验证未通过的情况,程序保留已经找到的较优可行组合,并记录相应状态,避免因局部数值求解失败而直接丢失字符的初始化结果。 + +**多读音处理与回退机制。** 对于具有多个国语字读音的喃字,算法分别构造每个读音对应的输入与输出参考向量,再对各读音结果取算术平均,得到该字符的初始参数。具体而言,设 \\(c\\) 为待初始化的喃字, \\(R(c)\\) 为字典中记录的该字符的不同国语字读音集合, \\(e_c^{(0)}\\) 和 \\(w_c^{(0)}\\) 分别为该字符最终得到的输入词嵌入与 LM Head 初始向量,则对于采用读音初始化的字符,有: + +$$ +e_c^{(0)}=\frac{1}{|R(c)|}\sum_{q\in R(c)}\widehat E_q, +\qquad +w_c^{(0)}=\frac{1}{|R(c)|}\sum_{q\in R(c)}\widehat W_q +$$ + +其中,对于能够在读音参考集合中直接匹配的读音, \\(\widehat E_q\\) 与 \\(\widehat W_q\\) 直接取其对应的 \\(C_q\\) 和 \\(U_q\\) ;对于未直接匹配但可有效编码的读音,则使用凸优化构造的结果。若个别读音无法有效编码、缺少可用参考锚点或无法建立有效的优化问题,则以字典中全部已知字符的平均输入嵌入及平均 LM Head 权重作为该读音的回退向量;其他读音已有的有效结果仍予保留并参与最终平均。因此,算法的回退处理发生在读音层面,而不会因为某一读音缺失就放弃整个字符的已知信息。 + +**重复向量区分。** 对于具有相同读音组合或参考关系的新增字符( **异体喃字** ),初始化可能得到相同的向量。为减少这种情况,程序分别检查输入嵌入与 LM Head 在实际存储精度下的向量表示,并在需要时进行最小有效扰动。具体方法是从高斯分布中随机采样单位方向,根据 FP16、BF16 或 FP32 等实际权重格式的相邻可表示数与舍入边界,计算能够产生有效数值变化的近似最小步长,再通过二分搜索进一步缩小扰动幅度;必要时采用单个坐标的一 ULP(Unit in the Last Place,即末位单位)调整作为回退方案。该过程以尽可能保留原始初始化向量为原则,直接字形映射的合法向量复制关系予以保留。 + +这一阶段完全基于既有权重、字典知识和数值计算完成,不进行训练。其主要作用是将已有汉字、喃字和现代越南语的表示关系转化为新增字符的初始参数,使后续 CPT 能够从具有语言学依据的向量出发,进一步通过实际上下文学习字符的读音、用法与语义。 + +### 4.2 增量预训练(CPT) + +CPT 阶段以汉喃文字表示学习、越南语语言建模及领域知识注入为主要目标。训练语料包括《金云翘传》《征妇吟》《蓼云仙》《大越史记》《胡春香诗集》等文学与历史资料、NomNaOCR 文本数据,以及喃字辞书、喃字标准表、汉越音数据集和现代越南语词典。对于文学作品、历史文献等连续文本,直接进行自回归语言模型训练;对于辞书、读音表和其他结构化资料,则按照预定义模板转换为连续文本,以建立喃字字符、国语字读音、汉越音、释义及上下文之间的联系。 + +本阶段采用 QLoRA 算法,基础模型权重使用 NF4 四位量化,LoRA 秩设为 \\(r=64\\) ,文本截断长度为 1,024 Token。与仅训练低秩适配器的常规方法不同,CPT 阶段还解除相关字符嵌入及 LM Head 的冻结状态,使简体汉字、繁体汉字和喃字等相关单字词嵌入能够显式接受梯度更新,同时也允许 LM Head 参与训练。这样既可以继续修正第一阶段由数学方法初始化的新增喃字向量,也能够调整同时为喃字的汉字其嵌入向量。 + +### 4.3 指令监督微调(SFT) + +SFT 阶段主要利用平行语料和辞书等结构化数据构建监督问答样本,以强化模型对喃字读音、释义、汉越音、国语字对应关系及越南历史文化知识的调用能力,并进一步训练其对汉喃文本解释和跨语言指令的响应。训练采用 LoRA 算法,以 FP8 精度进行微调,秩设为 \\(r=32\\) ,文本截断长度为 1,536 Token。 + +与 CPT 阶段不同,SFT 阶段冻结输入词嵌入层和 LM Head,仅通过低秩适配器进行参数更新。这一设置使模型在保留前两个阶段已形成的字符表示基础上,将训练重点转向结构化知识问答、指令理解及回答生成。 + +| | 算法 | 秩 | 量化精度 | 截断长度 | +| --- | --- | --- | --- | --- | +| CPT | QLoRA | 64 | NF4 | 1,024 | +| SFT | LoRA | 32 | FP8 | 1,536 | + +### 4.4 软硬件环境 + +VanMach-7B 使用单张 NVIDIA GeForce RTX 5060 Ti 16GB 显卡完成微调,训练框架为 Axolotl v0.20.0。CPT 与 SFT 分别使用 QLoRA 和 LoRA,以适应单卡 16GB 显存的计算资源限制。 + +## 5. 使用示例 + +VanMach-7B 基于 Hugging Face Transformers 生态,可使用标准的自回归语言模型加载方式。 + +```python +import torch +from transformers import AutoTokenizer, AutoModelForCausalLM + +path = "./VanMach-7B" +tokenizer = AutoTokenizer.from_pretrained(path) +model = AutoModelForCausalLM.from_pretrained( + path, torch_dtype=torch.bfloat16, device_map="cuda" +) +messages = [] + +while True: + question = input("User: ") + messages.append({"role": "user", "content": question}) + inputs = tokenizer.apply_chat_template( + messages, add_generation_prompt=True, return_tensors="pt" + ).to(model.device) + outputs = model.generate(inputs, max_new_tokens=512) + answer = tokenizer.decode( + outputs[0][inputs.shape[-1]:], skip_special_tokens=True + ) + print("Assistant:", answer) + messages.append({"role": "assistant", "content": answer}) +``` + +## 6. 来源、许可与使用声明 + +### 6.1 许可与再分发 + +SeaLLMs-v3-7B-Chat 采用 SeaLLMs 自定义许可协议。本模型作为其衍生模型,应遵守上游模型适用的使用及再分发条件。相关条款涉及原始权利声明、衍生模型再分发、修改说明、署名、使用限制及其他条件。发布和使用本模型时,应同时保留并遵守适用的上游许可要求。 + +本模型卡中的技术说明不构成对基础模型许可限制的修改或豁免。 + +### 6.2 训练数据相关声明 + +VanMach-7B 使用的资料包含传统文学、历史文本、辞书、OCR 数据及公开平台上的相关语言数据集。不同数据来源可能具有不同的版权、使用和再分发条件。模型的公开发布不意味着所有训练资料均可以不受限制地再次分发。对训练语料的使用和再分发,应遵循其各自适用的许可及法律要求。 + +### 6.3 免责声明 + +VanMach-7B 主要用于自然语言处理、汉喃文字研究及相关语言文化应用。由于模型采用统计学习方法,其输出可能存在事实错误、读音混淆、错误释义或其他不准确内容。在教育、历史文献研究、专业翻译以及其他要求高度准确性的场景中,应结合可信资料与人工审查使用模型输出。 + +## 7. 作者 + +**兰州交通大学电子与信息工程学院** [**杜宇**](https://faculty.lzjtu.edu.cn/chenmei/zh_CN/xsxx/2554/content/1837.htm)(英语:DU Yu,越南语:ĐỖ Vũ,No.11250717,电邮: 或 或 <11250717@stu.lzjtu.edu.cn> ) \ No newline at end of file diff --git a/README.zh-TW.md b/README.zh-TW.md new file mode 100644 index 0000000..334cec4 --- /dev/null +++ b/README.zh-TW.md @@ -0,0 +1,238 @@ +

+
+ +

+ +# 文脈大模型 VanMach-7B + +### 文件語言 + +[**英語**](./README.md) | [**簡體中文**](./README.zh-CN.md) | [**繁體中文**](./README.zh-TW.md) | [**越南語**](./README.vi.md) + +## 1. 模型簡介 + +**文脈大模型(越南語:Văn Mạch;英語:Van Mach,模型編號:VanMach-7B)** 是一款面向越南傳統文字(喃字)、歷史文獻與語言文化領域的 7B 規模多語言大型語言模型。模型以 [SeaLLMs-v3-7B-Chat](https://huggingface.co/SeaLLMs/SeaLLMs-v3-7B-Chat) 為基礎模型,透過專門設計的喃字詞彙表擴充、純數學計算的詞嵌入初始化、增量預訓練(CPT)以及指令監督微調(SFT)等步驟,增強模型對越南喃字(Chữ Nôm)、現代越南語、漢喃歷史文獻及越南傳統文化知識的處理能力。不同於主要針對現代越南語自然語言處理任務的通用模型,我們的 VanMach-7B 將 **喃字的語言學計算表示、歷史語言知識與現代越南語之間的關聯** 作為模型開發的核心方向。模型支援以下三種語言及其相應書寫形式: **越南語** 【國語字(Chữ Quốc ngữ)以及歷史上使用的喃字(Chữ Nôm)】、**中文** 【簡體中文與繁體中文】、**英語**。 + +喃字是越南歷史上用於書寫越南語的重要文字系統,其字形與漢字體系具有密切關聯,但在字義、讀音、字形構成以及實際用法方面又具有自身的特點。大量喃字在現代通用大型語言模型的訓練語料中出現頻率極低,部分字元甚至無法透過既有分詞器獲得獨立、完整的 Token 表示。與此同時,喃字可利用的數位化訓練語料相對有限,尤其缺乏大規模、經過系統整理的高品質現代語對齊資料。這使得傳統的大型語言模型微調方法面臨較為突出的挑戰: + +1. **文字表示不足**:大量喃字缺乏獨立 Token,容易被拆分為多個子詞或位元組級 Token,難以直接形成穩定的單字語意表示。 +2. **訓練資料稀缺**:漢喃文獻及喃字辭書具有重要的語言學和歷史價值,但可直接用於大型語言模型訓練的規模相對有限。 +3. **隨機初始化收斂緩慢**:如果直接為新增喃字隨機初始化詞嵌入,則模型需要在有限語料中同時學習文字的基本表示、讀音關聯和上下文語意。 +4. **跨文字系統對齊困難**:喃字、漢字以及現代越南語國語字之間具有複雜的歷史和語言關係,難以僅依賴一般文字訓練充分建立關聯。 +5. **運算資源受限**:大規模詞彙表擴充與持續訓練通常需要額外的顯示記憶體及運算開銷,對單張顯示卡環境尤其不利。 + +針對上述問題,VanMach-7B 採用了一條不同於單純隨機初始化與直接微調的技術路線: + +**首先透過辭書知識、既有漢字向量、越南語讀音表示與凸最佳化方法,在訓練開始前為新增喃字建構具有語言學依據的初始表示(注入單字的詞嵌入),隨後透過CPT與SFT逐步學習喃字的實際用法、現代越南語對應關係以及相關文化知識。** + +## 2. 模型基本資訊 + +### 2.1 模型規格 + +| 項目 | 規格 | +|---|---| +| 模型名稱 | 文脈大模型(越:Văn Mạch;英:Van Mach) | +| 模型編號 | VanMach-7B | +| 模型類型 | 自迴歸因果語言模型 | +| 模型架構 | Qwen2ForCausalLM | +| 基礎模型 | SeaLLMs-v3-7B-Chat | +| 模型規模 | 7.71B (7,713,187,328) | +| 模型權重資料大小 | 約 14.37 GiB (15,426,374,656 位元組) | +| 詞彙表大小 | 165,676 (原始大小 152,064) | +| 新增喃字 Token 數量 | 13,612 | +| 詞嵌入維度 | 3,584 | +| 新增詞嵌入及輸出層參數 | 不共享,約 97.57M (97,570,816) | +| 支援語言 | 越南語、中文、英語 | +| 強化領域 | 喃字、漢喃文獻、現代越南語、越南歷史文化 | + +### 2.2 模型來源與技術譜系 + +VanMach-7B 直接基於 SeaLLMs-v3-7B-Chat 進行開發。 + +

+
+ +

+ +SeaLLMs-v3-7B-Chat 是面向東南亞語言的多語言對話模型,根據 SeaLLMs 3 官方技術論文,其基礎模型來源為 **Qwen2 系列**。 + +## 3. 訓練語料與知識來源 + +VanMach-7B 的訓練語料重點涵蓋越南傳統文字、歷史文學、漢喃辭書、文字辨識資料以及現代越南語詞彙知識。與僅依靠大規模網路文字訓練的通用語言模型不同,本專案充分利用具有明確語言學結構的辭書和文字資料,將其用於詞嵌入初始化、增量預訓練和指令監督微調。 + +#### Tự Điển Chữ Nôm Dẫn Giải + +《Tự Điển Chữ Nôm Dẫn Giải》(喃字釋義辭典)是本專案的重要喃字語言知識來源之一。這類資料包含喃字及其相關讀音、釋義和文字資訊,對於建立喃字與現代越南語之間的關聯具有重要價值。在模型開發中,辭書性質的資料主要用於建立喃字與越南語國語字讀音之間的對應關係、為新擴充的喃字 Token 建構數學初始化所需的語言知識,以及建構結構化訓練文字。 + +#### 越南漢喃復興委員會喃字標準表 + +專案還使用了由 **Ủy ban Phục sinh Hán Nôm Việt Nam(越南漢喃復興委員會)** 發布的喃字標準表。相關資源用於補充和整理喃字字元資訊,為字元涵蓋範圍、詞彙表擴充及文字標準化處理提供參考。 + +#### Hugging Face 漢喃與漢越音資料集 + +此外,訓練還使用了 Hugging Face 平台上的若干漢喃資料集及漢越音資料集,這些資料用於補充喃字、漢字、漢越音與越南語之間的文字和語音關聯。 + +#### 古代越南文學 + +為了使模型能夠接觸真實歷史語境中的語言形式,VanMach-7B 引入了多部越南古典文學作品。 + +主要包括: + +| 語料 | 內容與訓練價值 | +|---|---| +| 《金雲翹傳》(Truyện Kiều) | 越南古典文學中的代表性作品,用於建構國語字-喃字平行語料、補充古代越南語表達和文學詞彙 | +| 《征婦吟》(Chinh phụ ngâm) | 用於學習古典文學語言、詩歌表達及相關文化知識 | +| 《蓼雲仙》(Lục Vân Tiên) | 用於補充越南傳統敘事文學及歷史語言資料 | +| 《胡春香詩集》 | 用於補充越南古典詩歌、文學語言、文化意象及傳統表達 | +| 《大越史記》 | 用於補充越南歷史、傳統制度、人物、地名、歷史事件以及相關文言與漢喃書寫形式。 | + +#### OCR 文字資料 + +專案使用了 **NomNaOCR** 發布的文字資料。 + +## 4. 模型訓練 + +VanMach-7B 的訓練分為三個階段:首先利用喃字辭書、原始模型的詞嵌入空間和凸最佳化方法,為新增的 13,612 個喃字 Token 初始化輸入詞嵌入及 LM Head 權重。隨後透過增量預訓練(CPT),結合漢喃文獻、現代越南語及結構化辭書語料,進一步訓練新增喃字和相關漢字的表示,並注入領域語言與文化知識。最後採用指令監督微調(SFT),利用平行語料及結構化問答資料強化模型對喃字、漢喃文獻和越南語言文化知識的理解與指令回應能力。 + +### 4.1 新增喃字詞嵌入初始化方法 + +由於原始模型對大量喃字缺乏獨立的 Token 表示,而漢喃文獻的可用訓練語料和運算資源均較為有限,直接採用隨機初始化難以充分利用既有的語言學知識。本專案因此設計了一套基於辭書映射、字形轉換與凸最佳化的詞嵌入初始化演算法,在正式梯度訓練之前,為新增喃字建構具有語言學依據的初始表示。設原始模型的詞彙表大小為 \\(V_0=152064\\) ,詞嵌入維度為 \\(d=3584\\) ,輸入詞嵌入矩陣與語言模型輸出權重矩陣分別記為 \\(E,W\in\mathbb{R}^{V_0\times d}\\) 。對於原始分詞器中的任意 Token ID \\(t\\) ,以 \\(E_t\\) 和 \\(W_t\\) 分別表示兩個矩陣中對應的列向量。演算法分別在輸入與輸出參數空間中建構新增字元的初始向量。 + +**字元辨識與直接映射。** 首先讀取喃字—國語字讀音字典,對字元和讀音進行 Unicode NFC 正規化、大小寫及空白正規化,並合併重複讀音。隨後使用原始分詞器辨識已知字元:僅當某字元能夠被編碼為一個非特殊 Token,且解碼結果與原始字元完全一致時,才認為其具有有效的獨立表示。對於尚未被獨立編碼的喃字,優先透過 OpenCC 的 `t2s` 規則進行字形轉換;若轉換結果為不同的單一字元,且已存在獨立 Token,則分別複製該字元在輸入詞嵌入矩陣和 LM Head 中的權重。其餘字元進入基於讀音的數學初始化流程。 + +

+
+ +

+ +**讀音表示與參考錨點。** 為利用既有字元與現代越南語讀音之間的對應關係,演算法首先根據字典建構讀音參考集合。具體而言,將字典中具有相同國語字讀音的已知字元歸為一組,並以每一種有效讀音及其對應的已知字元集合建立一組參考向量。設 \\(q\\) 表示某一國語字讀音, \\(T(q)=(t_1,\ldots,t_m)\\) 為原始分詞器對該讀音編碼得到的 Token ID 序列,其中 \\(m=|T(q)|\\) 為序列長度; \\(H(q)\\) 為字典中具有該讀音、且能夠被原始分詞器獨立編碼的已知字元所對應的 Token ID 集合。對於 \\(T(q)\\) 有效且 \\(H(q)\\) 非空的讀音,定義: + +$$ +v_q=\frac{1}{|T(q)|}\sum_{t\in T(q)}E_t,\qquad +C_q=\frac{1}{|H(q)|}\sum_{h\in H(q)}E_h,\qquad +U_q=\frac{1}{|H(q)|}\sum_{h\in H(q)}W_h +$$ + +其中, \\(v_q\\) 表示國語字讀音在原始詞嵌入空間中的位置, \\(C_q\\) 和 \\(U_q\\) 分別表示同音已知字元的輸入嵌入中心和 LM Head 權重中心。由此,每一種有效讀音均對應一個由 \\((v_q,C_q,U_q)\\) 構成的三元參考關係,稱為 **讀音錨點** 。讀音錨點以國語字讀音為索引,透過字典中的字音對應關係,將讀音的向量表示與既有字元的輸入、輸出參數聯繫起來。讀音向量透過對原始分詞結果取嵌入平均值獲得,不額外訓練編碼器;對於包含未知 Token 或特殊 Token、無法有效編碼的讀音,則不建構有效讀音錨點。參考字元嚴格限定為字典中已被原始分詞器獨立編碼的字元,不直接使用整個 Unicode 漢字區或原始詞彙表中的全部漢字作為錨點。 + +**凸最佳化與向量遷移。** 對於無法直接建立同音字元參考中心、但能夠透過原始分詞器計算讀音向量的目標讀音,演算法將其表示問題轉化為讀音向量在既有讀音錨點凸包上的投影問題。設讀音參考集合包含 \\(n\\) 個有效錨點,其對應的國語字讀音依序為 \\(q_1,q_2,\ldots,q_n\\) ,並簡記各錨點的三個向量為 \\(v_i=v_{q_i}\\) 、 \\(C_i=C_{q_i}\\) 和 \\(U_i=U_{q_i}\\) 。對於未包含在該參考集合中的目標讀音 \\(q\\) ,首先按照前述方法計算其讀音向量 \\(v_q\\) ,然後尋找一組組合係數 \\(\boldsymbol{\alpha}=(\alpha_1,\ldots,\alpha_n)\\) ,使參考讀音向量的加權和與目標讀音向量之間的歐氏距離最小: + +$$ +\boldsymbol{\alpha}^{*} +=\arg\min_{\boldsymbol{\alpha}} +\frac{1}{2}\left\| +\sum_{i=1}^{n}\alpha_i v_i-v_q +\right\|_2^2, +\qquad +\alpha_i\geq0,\quad +\sum_{i=1}^{n}\alpha_i=1 +$$ + +其中, \\(\alpha_i\\) 表示第 \\(i\\) 個讀音錨點的組合權重, \\(\boldsymbol{\alpha}^{*}\\) 表示滿足約束條件的最優係數向量, \\(\|\cdot\|_2\\) 表示歐氏範數。該問題是具有機率單純形約束的凸二次最佳化問題,其目標是在既有讀音參考向量構成的凸包中尋找最接近目標讀音的位置。求解後,演算法並不直接以凸投影向量作為字元嵌入,而是將得到的組合係數分別應用於對應讀音錨點的輸入、輸出參考中心: + +$$ +\widehat E_q=\sum_{i=1}^{n}\alpha_i^{*}C_i, +\qquad +\widehat W_q=\sum_{i=1}^{n}\alpha_i^{*}U_i +$$ + +其中, \\(\widehat E_q\\) 和 \\(\widehat W_q\\) 分別表示根據目標讀音 \\(q\\) 建構的輸入嵌入參考向量和 LM Head 權重參考向量。因此,國語字讀音向量負責決定不同參考錨點之間的組合關係,而既有字元的輸入嵌入與 LM Head 權重則用於建構實際的初始化參數。這使演算法能夠利用原始模型既有的越南語讀音表示和漢字、喃字參數資訊,而不是將所有新增字元置於隨機位置。 + +**數值求解與收斂控制。** 實際實作採用 Frank–Wolfe 型條件梯度迭代,以目前投影殘差為依據選擇參考頂點,並透過約束在 \\([0,1]\\) 區間內的解析線搜尋更新凸組合。演算法不建構完整的大規模錨點 Gram 矩陣,而是利用 GPU 執行 FP64 向量內積與矩陣運算,並對作用中的參考集合定期使用 SLSQP 進行局部修正。參考向量按照其範數中位數進行尺度正規化,預設最大迭代次數為 1,800,最優性容差為 \\(2\times10^{-8}\\) ,同時依據 Frank–Wolfe 間隙判斷主要最佳化過程的數值收斂情況。 + +考慮到不同凸組合可能產生相同的投影向量,演算法在主要最佳化過程滿足收斂條件後進一步嘗試最小範數最佳化。設主要最佳化過程得到的投影位置為 \\(p^{*}=\sum_{i=1}^{n}\alpha_i^{*}v_i\\) ,則在保持該投影位置不變的條件下,進一步求解: + +$$ +\min_{\boldsymbol{\alpha}} +\frac{1}{2}\|\boldsymbol{\alpha}\|_2^2, +\qquad +\sum_{i=1}^{n}\alpha_i v_i=p^{*},\quad +\sum_{i=1}^{n}\alpha_i=1,\quad +\alpha_i\geq0 +$$ + +該次級最佳化旨在從對應同一投影位置的可行係數組合中選擇歐氏範數較小的解;若其通過數值驗證,則使用修正後的係數進行前述輸入和輸出參考向量的建構。次級最佳化結合奇異值分解(SVD)、SLSQP、L-BFGS-B 對偶最佳化及 Karush–Kuhn–Tucker(KKT)最優性條件檢查,在保持投影位置與凸組合約束的前提下嘗試獲得穩定的係數解。對於未達到完整收斂或數值驗證未通過的情況,程式保留已經找到的較佳可行組合,並記錄相應狀態,避免因局部數值求解失敗而直接丟失字元的初始化結果。 + +**多讀音處理與回退機制。** 對於具有多個國語字讀音的喃字,演算法分別建構每個讀音對應的輸入與輸出參考向量,再對各讀音結果取算術平均值,得到該字元的初始參數。具體而言,設 \\(c\\) 為待初始化的喃字, \\(R(c)\\) 為字典中記錄的該字元的不同國語字讀音集合, \\(e_c^{(0)}\\) 和 \\(w_c^{(0)}\\) 分別為該字元最終得到的輸入詞嵌入與 LM Head 初始向量,則對於採用讀音初始化的字元,有: + +$$ +e_c^{(0)}=\frac{1}{|R(c)|}\sum_{q\in R(c)}\widehat E_q, +\qquad +w_c^{(0)}=\frac{1}{|R(c)|}\sum_{q\in R(c)}\widehat W_q +$$ + +其中,對於能夠在讀音參考集合中直接匹配的讀音, \\(\widehat E_q\\) 與 \\(\widehat W_q\\) 直接取其對應的 \\(C_q\\) 和 \\(U_q\\) ;對於未直接匹配但可有效編碼的讀音,則使用凸最佳化建構的結果。若個別讀音無法有效編碼、缺乏可用參考錨點或無法建立有效的最佳化問題,則以字典中全部已知字元的平均輸入嵌入及平均 LM Head 權重作為該讀音的回退向量;其他讀音已有的有效結果仍予保留並參與最終平均。因此,演算法的回退處理發生在讀音層面,而不會因為某一讀音缺失就放棄整個字元的已知資訊。 + +**重複向量區分。** 對於具有相同讀音組合或參考關係的新增字元( **異體喃字** ),初始化可能得到相同的向量。為減少這種情況,程式分別檢查輸入嵌入與 LM Head 在實際儲存精度下的向量表示,並在需要時進行最小有效擾動。具體方法是從高斯分布中隨機取樣單位方向,根據 FP16、BF16 或 FP32 等實際權重格式的相鄰可表示數值與捨入邊界,計算能夠產生有效數值變化的近似最小步長,再透過二分搜尋進一步縮小擾動幅度;必要時採用單一座標的一 ULP(Unit in the Last Place,即末位單位)調整作為回退方案。該過程以盡可能保留原始初始化向量為原則,直接字形映射的合法向量複製關係予以保留。 + +這一階段完全基於既有權重、字典知識和數值計算完成,不進行訓練。其主要作用是將既有漢字、喃字和現代越南語的表示關係轉化為新增字元的初始參數,使後續 CPT 能夠從具有語言學依據的向量出發,進一步透過實際上下文學習字元的讀音、用法與語意。 + +### 4.2 增量預訓練(CPT) + +CPT 階段以漢喃文字表示學習、越南語語言建模及領域知識注入為主要目標。訓練語料包括《金雲翹傳》《征婦吟》《蓼雲仙》《大越史記》《胡春香詩集》等文學與歷史資料、NomNaOCR 文字資料,以及喃字辭書、喃字標準表、漢越音資料集和現代越南語詞典。對於文學作品、歷史文獻等連續文字,直接進行自迴歸語言模型訓練;對於辭書、讀音表和其他結構化資料,則按照預先定義的範本轉換為連續文字,以建立喃字字元、國語字讀音、漢越音、釋義及上下文之間的關聯。 + +本階段採用 QLoRA 演算法,基礎模型權重使用 NF4 四位元量化,LoRA 秩設為 \\(r=64\\) ,文字截斷長度為 1,024 Token。與僅訓練低秩適配器的常規方法不同,CPT 階段還解除相關字元嵌入及 LM Head 的凍結狀態,使簡體漢字、繁體漢字和喃字等相關單字詞嵌入能夠明確接受梯度更新,同時也允許 LM Head 參與訓練。這樣既可以繼續修正第一階段由數學方法初始化的新增喃字向量,也能夠調整同時作為喃字的漢字之嵌入向量。 + +### 4.3 指令監督微調(SFT) + +SFT 階段主要利用平行語料和辭書等結構化資料建構監督問答樣本,以強化模型對喃字讀音、釋義、漢越音、國語字對應關係及越南歷史文化知識的運用能力,並進一步訓練其對漢喃文字解釋和跨語言指令的回應。訓練採用 LoRA 演算法,以 FP8 精度進行微調,秩設為 \\(r=32\\) ,文字截斷長度為 1,536 Token。 + +與 CPT 階段不同,SFT 階段凍結輸入詞嵌入層和 LM Head,僅透過低秩適配器進行參數更新。這一設定使模型在保留前兩個階段已形成的字元表示基礎上,將訓練重點轉向結構化知識問答、指令理解及回答生成。 + +| | 演算法 | 秩 | 量化精度 | 截斷長度 | +| --- | --- | --- | --- | --- | +| CPT | QLoRA | 64 | NF4 | 1,024 | +| SFT | LoRA | 32 | FP8 | 1,536 | + +### 4.4 軟硬體環境 + +VanMach-7B 使用單張 NVIDIA GeForce RTX 5060 Ti 16GB 顯示卡完成微調,訓練框架為 Axolotl v0.20.0。CPT 與 SFT 分別使用 QLoRA 和 LoRA,以適應單張顯示卡 16GB 顯示記憶體的運算資源限制。 + +## 5. 使用範例 + +VanMach-7B 基於 Hugging Face Transformers 生態系統,可使用標準的自迴歸語言模型載入方式。 + +```python +import torch +from transformers import AutoTokenizer, AutoModelForCausalLM + +path = "./VanMach-7B" +tokenizer = AutoTokenizer.from_pretrained(path) +model = AutoModelForCausalLM.from_pretrained( + path, torch_dtype=torch.bfloat16, device_map="cuda" +) +messages = [] + +while True: + question = input("User: ") + messages.append({"role": "user", "content": question}) + inputs = tokenizer.apply_chat_template( + messages, add_generation_prompt=True, return_tensors="pt" + ).to(model.device) + outputs = model.generate(inputs, max_new_tokens=512) + answer = tokenizer.decode( + outputs[0][inputs.shape[-1]:], skip_special_tokens=True + ) + print("Assistant:", answer) + messages.append({"role": "assistant", "content": answer}) +``` + +## 6. 來源、授權與使用聲明 + +### 6.1 授權與再散布 + +SeaLLMs-v3-7B-Chat 採用 SeaLLMs 自訂授權條款。本模型作為其衍生模型,應遵守上游模型適用的使用及再散布條件。相關條款涉及原始權利聲明、衍生模型再散布、修改說明、署名、使用限制及其他條件。發布和使用本模型時,應同時保留並遵守適用的上游授權要求。 + +本模型卡中的技術說明不構成對基礎模型授權限制的修改或豁免。 + +### 6.2 訓練資料相關聲明 + +VanMach-7B 使用的資料包含傳統文學、歷史文字、辭書、OCR 資料及公開平台上的相關語言資料集。不同資料來源可能具有不同的著作權、使用和再散布條件。模型的公開發布不代表所有訓練資料均可以不受限制地再次散布。對訓練語料的使用和再散布,應遵循其各自適用的授權條款及法律要求。 + +### 6.3 免責聲明 + +VanMach-7B 主要用於自然語言處理、漢喃文字研究及相關語言文化應用。由於模型採用統計學習方法,其輸出可能存在事實錯誤、讀音混淆、錯誤釋義或其他不準確內容。在教育、歷史文獻研究、專業翻譯以及其他要求高度準確性的情境中,應結合可信資料與人工審查使用模型輸出。 + +## 7. 作者 + +**蘭州交通大學電子與信息工程學院** [**杜宇**](https://faculty.lzjtu.edu.cn/chenmei/zh_CN/xsxx/2554/content/1837.htm)(英語:DU Yu,越南語:ĐỖ Vũ,No.11250717,電子郵件: 或 或 <11250717@stu.lzjtu.edu.cn> ) \ No newline at end of file diff --git a/chat_template.jinja b/chat_template.jinja new file mode 100644 index 0000000..9e623f4 --- /dev/null +++ b/chat_template.jinja @@ -0,0 +1,7 @@ +{% set system_message = 'You are a helpful assistant.' %}{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% endif %}{% if system_message is defined %}{{ '<|im_start|>system +' + system_message + '<|im_end|> +' }}{% endif %}{% for message in messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '<|im_start|>user +' + content + '<|im_end|> +<|im_start|>assistant +' }}{% elif message['role'] == 'assistant' %}{{ content + '<|im_end|>' + ' +' }}{% endif %}{% endfor %} \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..e1c1863 --- /dev/null +++ b/config.json @@ -0,0 +1,61 @@ +{ + "architectures": [ + "Qwen2ForCausalLM" + ], + "attention_dropout": 0.0, + "bos_token_id": null, + "dtype": "bfloat16", + "eos_token_id": 151645, + "hidden_act": "silu", + "hidden_size": 3584, + "initializer_range": 0.02, + "intermediate_size": 18944, + "layer_types": [ + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention" + ], + "max_position_embeddings": 131072, + "max_window_layers": 28, + "model_type": "qwen2", + "num_attention_heads": 28, + "num_hidden_layers": 28, + "num_key_value_heads": 4, + "pad_token_id": null, + "rms_norm_eps": 1e-06, + "rope_parameters": { + "rope_theta": 1000000.0, + "rope_type": "default" + }, + "sliding_window": null, + "tie_word_embeddings": false, + "transformers_version": "5.17.0", + "use_cache": true, + "use_sliding_window": false, + "vocab_size": 165676 +} diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..61b0e54 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,12 @@ +{ + "bos_token_id": 151643, + "do_sample": true, + "eos_token_id": [ + 151645, + 151643 + ], + "pad_token_id": 151643, + "repetition_penalty": 1.05, + "temperature": 0.7, + "transformers_version": "5.17.0" +} diff --git a/images/VanMach.ai b/images/VanMach.ai new file mode 100644 index 0000000..cb1a4ab --- /dev/null +++ b/images/VanMach.ai @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3438c382fd39619d6bf0bef62ff10d1a56efd40af2ebe07f0cf43b732ff038d7 +size 1207403 diff --git a/images/VanMach.svg b/images/VanMach.svg new file mode 100644 index 0000000..5aba97d --- /dev/null +++ b/images/VanMach.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/vm_semantic_geometry.svg b/images/vm_semantic_geometry.svg new file mode 100644 index 0000000..ac3f2d4 --- /dev/null +++ b/images/vm_semantic_geometry.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + +VANMACH / GEOMETRIC INTUITION +One meaning, two writing systems +Disjoint language manifolds intersected by a common semantic hyperplane +MATHEMATICAL ONLY + + + + + + + + + + + + + + + + + + + + +q₁q₂q₃ + + +\bar{v} + + +\Phi_s + +e_0(c) +LATIN-SCRIPT MANIFOLD\mathcal{M}_{Q}LOGOGRAPHIC MANIFOLD\mathcal{M}_{N}\Pi_sSEMANTIC HYPERPLANE + + + + \gamma_Q = \Pi_s \cap \mathcal{M}_Q\Phi_s : \gamma_Q \rightarrow \gamma_N\gamma_N = \Pi_s \cap \mathcal{M}_N + +\bar{v}=\frac{1}{m}\sum_{i=1}^{m} v(q_i)\quad\longrightarrow\quad e_0(c)=\Phi_s(\bar{v})Schematic geometric abstraction; not an assertion of exact isometry or the implementation order of per-reading optimization. + \ No newline at end of file diff --git a/images/vm_training_pipeline.svg b/images/vm_training_pipeline.svg new file mode 100644 index 0000000..774a2c1 --- /dev/null +++ b/images/vm_training_pipeline.svg @@ -0,0 +1,35 @@ + + + + + + + + + +VANMACH / MODEL DEVELOPMENT +From foundation model to domain-specific language model +7.71B parameters + + + + SeaLLMs-v3-7B-ChatQwen2 foundation + Vocabulary expansion+ Mathematical initialization + CPTContinued pre-training + SFTSupervised fine-tuning + VanMach-7BDomain-specialized model + + + + +0001020304 + + Pretrained weights& tokenizer + Dictionary + convex geometry13,612 tokens · no gradients + QLoRA / NF4 / r = 64Embedding + LM Head updates + LoRA / FP8 / r = 32Adapter-only updates + Chữ Nôm / Hán-NômVietnamese culture + + +The initialization stage constructs input embeddings and untied LM Head vectors before gradient-based training. + \ No newline at end of file diff --git a/model-00001-of-00004.safetensors b/model-00001-of-00004.safetensors new file mode 100644 index 0000000..2ce98b0 --- /dev/null +++ b/model-00001-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21dd4c133a171648c532882a98e11eaf59e4c696108b87457cbc3b76936dbf4e +size 3909280216 diff --git a/model-00002-of-00004.safetensors b/model-00002-of-00004.safetensors new file mode 100644 index 0000000..a8c339d --- /dev/null +++ b/model-00002-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:973dbca8682c6cd2db3c3ed799d4eaea43603c9884cab5222ded43045a4e333c +size 3864726328 diff --git a/model-00003-of-00004.safetensors b/model-00003-of-00004.safetensors new file mode 100644 index 0000000..b18f858 --- /dev/null +++ b/model-00003-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb19306957f20cf3bc2638b76314f24e4c594a90e9bb52aa59c5139e90ea470e +size 3923471248 diff --git a/model-00004-of-00004.safetensors b/model-00004-of-00004.safetensors new file mode 100644 index 0000000..7d0c208 --- /dev/null +++ b/model-00004-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:504e2067b686b870a04c42dd92f6e5131bd35260f1cf4d61bc9969658b845a01 +size 3728935680 diff --git a/model.safetensors.index.json b/model.safetensors.index.json new file mode 100644 index 0000000..d1b3197 --- /dev/null +++ b/model.safetensors.index.json @@ -0,0 +1,347 @@ +{ + "metadata": { + "total_parameters": 7713187328, + "total_size": 15426374656 + }, + "weight_map": { + "lm_head.weight": "model-00001-of-00004.safetensors", + "model.embed_tokens.weight": "model-00001-of-00004.safetensors", + "model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors", + "model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors", + "model.layers.0.self_attn.k_proj.bias": "model-00001-of-00004.safetensors", + "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.0.self_attn.q_proj.bias": "model-00001-of-00004.safetensors", + "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.0.self_attn.v_proj.bias": "model-00001-of-00004.safetensors", + "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors", + "model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors", + "model.layers.1.self_attn.k_proj.bias": "model-00001-of-00004.safetensors", + "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.1.self_attn.q_proj.bias": "model-00001-of-00004.safetensors", + "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.1.self_attn.v_proj.bias": "model-00001-of-00004.safetensors", + "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors", + "model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors", + "model.layers.2.self_attn.k_proj.bias": "model-00001-of-00004.safetensors", + "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.2.self_attn.q_proj.bias": "model-00001-of-00004.safetensors", + "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.2.self_attn.v_proj.bias": "model-00001-of-00004.safetensors", + "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors", + "model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors", + "model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.10.self_attn.k_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.10.self_attn.q_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.10.self_attn.v_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.3.mlp.gate_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.3.mlp.up_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.3.post_attention_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.3.self_attn.k_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.3.self_attn.k_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.3.self_attn.o_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.3.self_attn.q_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.3.self_attn.q_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.3.self_attn.v_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.3.self_attn.v_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.4.input_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.4.mlp.down_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.4.mlp.gate_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.4.mlp.up_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.4.post_attention_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.4.self_attn.k_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.4.self_attn.k_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.4.self_attn.o_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.4.self_attn.q_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.4.self_attn.q_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.4.self_attn.v_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.4.self_attn.v_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.5.input_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.5.mlp.down_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.5.mlp.gate_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.5.mlp.up_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.5.post_attention_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.5.self_attn.k_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.5.self_attn.k_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.5.self_attn.o_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.5.self_attn.q_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.5.self_attn.q_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.5.self_attn.v_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.5.self_attn.v_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.6.input_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.6.mlp.down_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.6.mlp.gate_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.6.mlp.up_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.6.post_attention_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.6.self_attn.k_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.6.self_attn.k_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.6.self_attn.o_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.6.self_attn.q_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.6.self_attn.q_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.6.self_attn.v_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.6.self_attn.v_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.7.input_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.7.mlp.down_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.7.mlp.gate_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.7.mlp.up_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.7.post_attention_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.7.self_attn.k_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.7.self_attn.k_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.7.self_attn.o_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.7.self_attn.q_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.7.self_attn.q_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.7.self_attn.v_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.7.self_attn.v_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.8.input_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.8.mlp.down_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.8.mlp.gate_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.8.mlp.up_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.8.self_attn.k_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.8.self_attn.k_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.8.self_attn.q_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.8.self_attn.q_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.8.self_attn.v_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.8.self_attn.v_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors", + "model.layers.9.self_attn.k_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.9.self_attn.k_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.9.self_attn.q_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.9.self_attn.v_proj.bias": "model-00002-of-00004.safetensors", + "model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors", + "model.layers.11.mlp.up_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.11.post_attention_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.11.self_attn.k_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.11.self_attn.k_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.11.self_attn.o_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.11.self_attn.q_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.11.self_attn.q_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.11.self_attn.v_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.11.self_attn.v_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.12.input_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.12.mlp.down_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.12.mlp.gate_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.12.mlp.up_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.12.post_attention_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.12.self_attn.k_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.12.self_attn.k_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.12.self_attn.o_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.12.self_attn.q_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.12.self_attn.q_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.12.self_attn.v_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.12.self_attn.v_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.13.input_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.13.mlp.down_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.13.mlp.gate_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.13.mlp.up_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.13.post_attention_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.13.self_attn.k_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.13.self_attn.k_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.13.self_attn.o_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.13.self_attn.q_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.13.self_attn.q_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.13.self_attn.v_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.13.self_attn.v_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.14.input_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.14.mlp.down_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.14.mlp.gate_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.14.mlp.up_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.14.post_attention_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.14.self_attn.k_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.14.self_attn.k_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.14.self_attn.o_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.14.self_attn.q_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.14.self_attn.q_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.14.self_attn.v_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.14.self_attn.v_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.15.input_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.15.mlp.down_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.15.mlp.gate_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.15.mlp.up_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.15.post_attention_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.15.self_attn.k_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.15.self_attn.k_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.15.self_attn.o_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.15.self_attn.q_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.15.self_attn.q_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.15.self_attn.v_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.15.self_attn.v_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.16.input_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.16.mlp.down_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.16.mlp.gate_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.16.mlp.up_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.16.post_attention_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.16.self_attn.k_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.16.self_attn.k_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.16.self_attn.o_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.16.self_attn.q_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.16.self_attn.q_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.16.self_attn.v_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.16.self_attn.v_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.17.input_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.17.mlp.down_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.17.mlp.gate_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.17.mlp.up_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.17.post_attention_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.17.self_attn.k_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.17.self_attn.k_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.17.self_attn.o_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.17.self_attn.q_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.17.self_attn.q_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.17.self_attn.v_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.17.self_attn.v_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.18.input_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.18.mlp.down_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.18.mlp.gate_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.18.mlp.up_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.18.self_attn.k_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.18.self_attn.k_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.18.self_attn.o_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.18.self_attn.q_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.18.self_attn.q_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.18.self_attn.v_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.18.self_attn.v_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.19.input_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.19.mlp.down_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.19.mlp.up_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.19.self_attn.k_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.19.self_attn.k_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.19.self_attn.o_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.19.self_attn.q_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.19.self_attn.q_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.19.self_attn.v_proj.bias": "model-00003-of-00004.safetensors", + "model.layers.19.self_attn.v_proj.weight": "model-00003-of-00004.safetensors", + "model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors", + "model.layers.20.mlp.down_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.20.mlp.gate_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.20.mlp.up_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.20.post_attention_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.20.self_attn.k_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.20.self_attn.k_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.20.self_attn.o_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.20.self_attn.q_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.20.self_attn.q_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.20.self_attn.v_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.20.self_attn.v_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.21.input_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.21.mlp.down_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.21.mlp.gate_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.21.mlp.up_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.21.post_attention_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.21.self_attn.k_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.21.self_attn.k_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.21.self_attn.o_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.21.self_attn.q_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.21.self_attn.q_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.21.self_attn.v_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.21.self_attn.v_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.22.input_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.22.mlp.down_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.22.mlp.gate_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.22.mlp.up_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.22.post_attention_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.22.self_attn.k_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.22.self_attn.k_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.22.self_attn.o_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.22.self_attn.q_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.22.self_attn.q_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.22.self_attn.v_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.22.self_attn.v_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.23.input_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.23.mlp.down_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.23.mlp.gate_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.23.mlp.up_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.23.post_attention_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.23.self_attn.k_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.23.self_attn.k_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.23.self_attn.o_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.23.self_attn.q_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.23.self_attn.q_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.23.self_attn.v_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.23.self_attn.v_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.24.input_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.24.mlp.down_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.24.mlp.gate_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.24.mlp.up_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.24.post_attention_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.24.self_attn.k_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.24.self_attn.k_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.24.self_attn.o_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.24.self_attn.q_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.24.self_attn.q_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.24.self_attn.v_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.24.self_attn.v_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.25.input_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.25.mlp.down_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.25.mlp.gate_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.25.mlp.up_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.25.post_attention_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.25.self_attn.k_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.25.self_attn.k_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.25.self_attn.o_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.25.self_attn.q_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.25.self_attn.q_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.25.self_attn.v_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.25.self_attn.v_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.26.input_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.26.mlp.down_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.26.mlp.gate_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.26.mlp.up_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.26.post_attention_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.26.self_attn.k_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.26.self_attn.k_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.26.self_attn.o_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.26.self_attn.q_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.26.self_attn.q_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.26.self_attn.v_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.26.self_attn.v_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.27.input_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.27.mlp.down_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.27.mlp.gate_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.27.mlp.up_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.27.post_attention_layernorm.weight": "model-00004-of-00004.safetensors", + "model.layers.27.self_attn.k_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.27.self_attn.k_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.27.self_attn.o_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.27.self_attn.q_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.27.self_attn.q_proj.weight": "model-00004-of-00004.safetensors", + "model.layers.27.self_attn.v_proj.bias": "model-00004-of-00004.safetensors", + "model.layers.27.self_attn.v_proj.weight": "model-00004-of-00004.safetensors", + "model.norm.weight": "model-00004-of-00004.safetensors" + } +} \ No newline at end of file diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..405ce4c --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f0cf8262a26e2e0a1a5d7e6696b724329381ef9877e2191290163f5a88b9d66 +size 13966317 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..9c8b53c --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,20 @@ +{ + "add_prefix_space": false, + "backend": "tokenizers", + "bos_token": null, + "clean_up_tokenization_spaces": false, + "eos_token": "<|im_end|>", + "errors": "replace", + "extra_special_tokens": [ + "<|im_start|>", + "<|im_end|>" + ], + "is_local": true, + "local_files_only": false, + "model_max_length": 32768, + "pad_token": "<|endoftext|>", + "padding_side": "right", + "split_special_tokens": false, + "tokenizer_class": "Qwen2Tokenizer", + "unk_token": null +}