[KongchangAI]
· 2 min read· 1,345 words

Fine-tuning Qwen on a 16GB GPU: Making the Model Answer Without the Letter e

Fine-tuning Qwen on a 16GB GPU: Making the Model Answer Without the Letter e

Fine-tuning Qwen on a 16GB GPU to avoid the letter e in replies, exploring constrained generation and small-VRAM fine-tuning.

This article introduces an amusing experiment: fine-tuning a Qwen model on a 16GB GPU so its generated replies contain no letter "e". It analyzes the challenge this task poses to vocabulary selection and syntactic structure, discusses the feasibility of model customization on 16GB VRAM through parameter-efficient fine-tuning techniques such as LoRA, and details the difficulties of constructing training data (rewriting to remove the letter e) and issues at the tokenization level. The article notes that such constraint-satisfaction generation tasks can test the model's ability to follow hard rules, while also reflecting the growing prevalence of small-VRAM fine-tuning. Finally, it emphasizes that the original share lacks details, making the effects difficult to quantify, and suggests that follow-up work establish an evaluation set for reproduction.

An Interesting Constraint: When a Language Model Must Avoid the Letter e

On Hacker News, a developer shared a rather amusing experiment: fine-tuning a Qwen model on a 16GB GPU so that its generated replies contain no letter "e" at all. This seemingly simple constraint actually poses a considerable challenge to the language model's vocabulary selection, syntactic structure, and generation strategy. The letter "e" is one of the most frequent letters in English, and banning it means the model has to work around a large number of common words—such as "the", "be", "are", "we", "they"—forcing it to use more roundabout or less common expressions.

The core value of this experiment lies not in producing a practical dialogue system, but in exploring the model's adaptability under extreme constraints. It is like a language game, yet it can reveal the model's degree of adherence to character-level instructions, the design techniques for fine-tuning data, and the feasibility of training in a small-VRAM environment.

Hardware Threshold: The Reality of Fine-tuning on 16GB of VRAM

Fine-tuning a language model on a 16GB GPU is a task that places high demands on VRAM management. The Qwen series includes versions of different parameter scales, and developers need to choose a model size that matches the VRAM and use parameter-efficient fine-tuning techniques (such as LoRA) to reduce training overhead. The original information is limited and does not disclose the specific Qwen version, fine-tuning method, or training data scale, but it is certain that 16GB of VRAM is sufficient to support lightweight fine-tuning of small- to medium-sized models.

The significance of this practice lies in lowering the barrier to experimentation. Not everyone has a multi-GPU A100 cluster, but a single consumer-grade or workstation-grade 16GB graphics card can complete a fine-tuning task with clear constraints, allowing more developers to try out their ideas.

Parameter-Efficient Fine-Tuning (PEFT) and LoRA

LoRA (Low-Rank Adaptation) is a representative method of parameter-efficient fine-tuning. It does not modify the original weights of the pre-trained model; instead, it injects low-rank matrices into the attention modules of the Transformer layers, and during training only these small-scale parameters are updated. For example, for a d×d weight matrix, LoRA decomposes it into two low-rank matrices A (d×r) and B (r×d), where the rank r is typically 8, 16, or 64, far smaller than d. This reduces the trainable parameters from d² to 2dr, greatly lowering VRAM usage and computation. On a 16GB GPU, LoRA makes fine-tuning models at the 7B parameter level possible, because most of the VRAM is occupied by the frozen model weights, while the optimizer states and gradients are only for a small number of LoRA parameters.

Quantization Techniques

Quantization is another key VRAM optimization technique. It reduces VRAM usage by lowering the numerical precision of model weights and activations, with common forms including 8-bit integer (INT8) and 4-bit integer (INT4) quantization. For example, quantizing FP16 weights to INT4 can reduce VRAM usage to a quarter of the original. Combined with LoRA, quantized low-rank adaptation (QLoRA) further lowers the fine-tuning threshold, making it possible to fine-tune larger models on a single 16GB GPU.

Banning the Letter e: How the Model Learns the "Word Game"

To make the model stably output text without the letter "e", relying solely on prompt constraints during inference is often not reliable enough; fine-tuning is a more direct approach. The core idea is to construct training data: input conventional questions, and output replies that have been processed manually or programmatically to remove the letter "e". Through supervised fine-tuning, the model learns this mapping relationship and gradually internalizes the generation habit of "avoiding e".

The difficulty here lies in the quality of data construction. Simply deleting e leads to spelling errors and semantic breaks; sentences need to be rewritten and vocabulary replaced while maintaining semantic fluency. The workload of this data cleaning and rewriting may far exceed that of training itself. In addition, the model still needs to deal with issues at the tokenization level during generation—the letter e may be hidden within subword units, and the model needs to learn to avoid specific characters during the decoding stage.

Tokenization and Character-Level Constraints

Language models do not process characters directly; instead, they use a tokenizer to split text into subword units (tokens). The letter "e" may appear as an independent token or be embedded in longer subwords (such as the "e" in "the"). Therefore, requiring the model to avoid the letter "e" is actually a character-level constraint, whereas the model's generation process is token-based. To avoid specific characters during the decoding stage, it is necessary to establish a token-to-character mapping and dynamically mask token candidates containing the target character during generation. During fine-tuning, the model learns from the training data which token sequences satisfy the constraint, but the granularity of tokenization may still lead to cases where "e" is accidentally included, which increases the difficulty of the task.

Insights from Such Experiments

Constrained generation is a touchstone for testing model capabilities. Tasks like "banning a certain letter" belong to constraint-satisfaction generation, which tests not only language fluency but also the model's ability to follow hard rules. This capability has corresponding value in practical scenarios that require format control, sensitive-word avoidance, or style restrictions.

Fine-tuning with small VRAM is becoming widespread. Completing Qwen fine-tuning on a 16GB GPU shows that the maturity of parameter-efficient methods and quantization techniques allows individual developers to perform meaningful model customization. The threshold for experimentation has dropped from "owning a cluster" to "owning a decent graphics card".

Fun projects drive technical dissemination. Using creative tasks like banning the letter e as a vehicle makes it easier to spark community discussion than dry benchmark tests. It packages knowledge points such as the fine-tuning workflow, VRAM optimization, and data construction into a shareable topic, which has a positive effect on technical popularization.

Constraint-Satisfaction Generation

Constraint-satisfaction generation (Constrained Generation) refers to the model having to satisfy specific hard conditions when generating text, such as banning certain words, following a specific format, or controlling emotional polarity. Unlike conventional generation tasks, it requires the model to actively avoid outputs that violate the constraints during decoding, rather than merely pursuing fluency or relevance. Such tasks have broad applications in industry, for example generating marketing copy without sensitive words, API responses conforming to JSON format, or text avoiding gender bias. Evaluation usually requires measuring both the constraint satisfaction rate and language quality (such as perplexity, human ratings), and there is often a trade-off between the two.

Limitations and Open Questions

The original share provided only a title and a small amount of interaction data, lacking the model version, training details, evaluation methods, and actual results. Therefore, it is impossible to judge how high an accuracy the model achieved on the task of banning e, nor is it clear whether there was any decline in semantic quality. The true value of such experiments needs to be supported by more complete reproduction records. For developers who want to try, it is recommended to start from a clear evaluation set and quantify the model's performance on both dimensions: constraint adherence and language quality.

One-line Summary

Fine-tuning a Qwen model on a 16GB GPU to make its replies avoid the letter e, exploring constraint-satisfaction generation and small-VRAM fine-tuning.

Paragraph Summary

This article introduces an amusing experiment: fine-tuning a Qwen model on a 16GB GPU, requiring its generated replies to contain no letter "e" at all. The article analyzes the challenge this task poses to vocabulary selection and syntactic structure, discusses the feasibility of model customization on 16GB VRAM through parameter-efficient fine-tuning techniques such as LoRA, and details the difficulties of constructing training data (rewriting to remove the letter e) and issues at the tokenization level. The article points out that such constraint-satisfaction generation tasks can test the model's ability to follow hard rules, while also reflecting the growing prevalence of small-VRAM fine-tuning. Finally, it emphasizes that the original share lacks details and that the effects are difficult to quantify, suggesting that follow-up work establish an evaluation set for reproduction.

#Qwen fine-tuning#16GB GPU#constrained generation#LoRA#tokenization#parameter-efficient fine-tuning
Share:

Related articles