How to Choose an LLM: From Intent Understanding to Exclusive Lock Design

    Model selection is usually framed as a benchmark comparison, but in real projects it is an engineering decision. This article explains why compliance and controllability set the candidate boundary first, why intent understanding rather than parameter count is the real dividing line between small and large models, and how a single poorly placed exclusive lock illustrates the gap: a small model locked the archive folder and still passed tests, while the correct design locks the data record that acts as the aggregate root. It closes with practical guidance on writing prompts that state the locking target and domain relationships explicitly, and on choosing small, large, or mixed model strategies per task.

    1. Introduction: Why Choosing the Right Model Is an Engineering Decision

    In real projects, a model is only a tool, but which model you use and how you use it often determines delivery quality directly. Given the same requirement — “add an exclusive lock to this data operation” — models of different parameter sizes can produce wildly different code. One version passes the tests yet carries a hidden defect; another hits the original design intent precisely. Understanding that difference is more valuable than comparing benchmark scores.

    2. The Overlooked Prerequisite: Compliance and Controllability Define the Boundary

    Before discussing model capability, one hard constraint is often ignored: compliance and controllability.

    In regulated sectors such as government, state-owned enterprises, and parts of the financial industry, technical standards frequently place explicit restrictions on which models and toolchains may be used, driven by data security and supply-chain controllability concerns. Certain external models and tools are simply not permitted in these environments. This is not a matter of capability but of admission — it defines the candidate set outright. Self-developed ecosystems from domestic model service platforms such as Baidu AI Cloud exist precisely to meet the deployment and invocation needs of these controlled scenarios.

    So the first step in selection is not “who scores higher,” but “who is within the compliance boundary.” Capability and cost are weighed only inside that boundary.

    3. Beyond Parameter Count: Intent Understanding Is the Real Dividing Line

    A common misconception among teams is that if benchmark scores are close, the experience will be similar. It usually isn’t.

    Smaller models depend heavily on prompt quality. They can get the job done, but only if you spell out every boundary condition and every instruction, leaving no room for ambiguity. They behave like an instruction-following executor: the more precisely you specify, the more precisely they deliver.

    Larger models bring stronger contextual reasoning. They take the background, context, and domain conventions you provide into account and infer what you actually want, rather than mechanically executing the literal instruction. The result is a counterintuitive phenomenon: even when two models score similarly on benchmarks, the larger model generally understands your intent better — at a higher cost.

    In short: small models excel at executing instructions; large models excel at grasping intent. When requirements are explicit, the gap is small; when requirements carry implicit semantics, the gap widens quickly.

    4. A Real Pitfall: The Exclusive Lock Went on the Wrong Object

    The following case is a textbook example of that gap.

    Background: An enterprise system manages two kinds of entities, “data” and “archives.” In the domain model, archives are dependent on data — each data record can be associated with several archive files, and the lifecycle of an archive belongs to its data record. To keep concurrent operations safe, an exclusive lock is required on the relevant operations.

    The small model’s default implementation: When the prompt only said “add an exclusive lock to this operation” without naming the locking target, the small model locked the archive folder ID by default:

    1. -- Small model's default: lock placed on the archive folder
    2. BEGIN;
    3. SELECT id FROM archive_folder WHERE folder_id = ? FOR UPDATE; -- wrong aggregate object locked
    4. UPDATE archive_file SET status = 'archived' WHERE folder_id = ?;
    5. COMMIT;

    Why it “looks usable”: The code is internally consistent and passes the test cases. Run single-threaded under ordinary conditions, it raises no error. But it deviates from the design intent.

    The correct implementation: Place the exclusive lock directly on the data record’s primary key, so all archive operations depend on the data record as the aggregate root:

    1. -- Correct approach: lock the data primary key (aggregate root); archive operations are protected within the same transaction
    2. BEGIN;
    3. SELECT id FROM biz_data WHERE id = ? FOR UPDATE; -- lock the aggregate root
    4. UPDATE archive_file SET status = 'archived' WHERE data_id = ?; -- dependent on the data lock
    5. COMMIT;

    The hidden risk behind the difference — a race condition: From a domain-driven design perspective, data and archives form one aggregate. Data is the aggregate root and archives are internal entities. The lock belongs on the aggregate root, not on one of the internal entities.

    If the lock sits on the archive folder, as the small model did, the following happens:

    • Thread A is running an archive operation and holds the folder lock.
    • Meanwhile, thread B deletes the data record — because the data itself is not locked, the delete is not blocked.
    • Result: the data is gone, but the archive operation continues against an already-invalid record, producing orphaned archives or inconsistent data.

    When the lock is on the data primary key, thread B’s delete blocks on the same row lock and is serialized naturally, eliminating the problem at its source.

    Why this is better: Locking at the aggregate root not only avoids the race above but also greatly simplifies the code and transaction boundaries. There is no longer any complex relationship between a folder lock and a data lock to maintain; the logic is clearer and correctness is easier to guarantee.

    5. From Case to Method: How to Write High-Quality Prompts

    The root cause of this pitfall is half the model and half the prompt. To get consistent intent understanding out of a large model, prompts should cover the following:

    • State the locking object explicitly. Don’t just say “add a lock”; say which primary key on which table. Lock granularity and target are where models improvise most freely and fail most easily.
    • Explain the domain relationships. Only when you tell the model that archives depend on data and that data is the aggregate root can it infer that the lock belongs on data rather than on archives.
    • Give the design intent, not just mechanical steps. Stating the goal — “I want simpler logic and no concurrency between background operations and deletes” — lets the model verify whether its implementation has drifted.
    • Fill in the boundary conditions. Concurrency scenarios, transaction boundaries, failure rollback: the more implicit the constraint, the more important it is to write into the prompt.

    This matters even more for small models. Treat the prompt as an interface contract and make every implicit semantic explicit, and you can approach the “zero-prompt” experience of a large model.

    6. Selection Guidance: Trade-offs by Scenario

    Bringing it together, selection can follow a few practical principles:

    • Clear, mechanical, high-volume tasks (formatting, template-based code generation): prefer smaller models with better cost efficiency, paired with detailed prompts, to control cost.
    • Tasks involving domain modeling, implicit semantics, concurrency safety, or architectural trade-offs: prefer larger models and rely on their intent understanding to reduce the error rate; spend the budget on the critical path.
    • A mixed strategy: run routine low-difficulty work on small models and escalate key design decisions to a large model for review — a common way to balance cost and quality.
    • Compliance first, capability second: any selection is conditional on satisfying data security and controllability requirements.

    7. Conclusion

    Model selection is not an arms race over parameter counts. It is a rational allocation of the capability to understand intent. Parameter size sets the ceiling on how well intent can be grasped; prompt quality determines whether that ceiling is actually reached. Returning to the locking case at the start: what ultimately determines a system’s robustness is not only whether the model is smart enough, but also whether the developer has clearly communicated a key intent like “lock at the aggregate root.” Understanding this matters more than chasing any single benchmark score.