LLMs in Programming and Research: Practical Capabilities and Boundaries

    This article explores the practical applications and limitations of Large Language Models (LLMs) in programming, formal mathematics, and hardware design. It highlights that while LLMs significantly enhance efficiency in code migration, proof strategy generation, and drafting HDL code, their outputs require rigorous validation through testing, proof assistants, or expert review. The article also covers safety tiering, inference performance considerations, a deployment checklist, and common failure modes to help teams integrate LLMs into production environments safely and effectively.

    To start with the conclusions: First, LLMs can save significant manual time in cross-file code understanding and code migration, but outputs still require testing and validation. Second, in formal mathematics, models primarily handle proof strategy generation and lemma decomposition, while the final correctness is checked by a proof assistant. Third, improvements in inference speed and cost depend on specific configurations, with no uniform margin of increase. Before use, note two limitations: models have a weak grasp of niche languages and obscure frameworks, and the accuracy of visual recognition on complex diagrams is unstable.

    1. Code Understanding and Migration: Clear Efficiency Gains, Validation Required

    Early code models mostly completed single functions. Current general-purpose models can receive longer contexts, allowing them to read multiple files simultaneously and understand their call relationships. Some tools first use abstract syntax trees or static analysis to extract symbols, dependencies, and interfaces, then pass this structured information to the model to reduce hallucinated guesses.

    When migrating legacy systems, the model’s advantage lies in batch processing repetitive patterns. For example, changing a batch of data access code from one ORM syntax to another, or unifying interface error handling to a new standard. Its weakness is that business rules are often implicit in historical code without documentation. This logic is easily lost during translation, and the translated syntax is usually correct, making it hard to detect.

    Recommended approach: First, let the model output a migration plan and dependency list, then migrate in module batches. Each batch must pass existing unit and integration tests, and boundary conditions require additional test cases. Modules with insufficient test coverage should be supplemented with tests before migration.

    1. Formal Mathematics: Models Provide Ideas, Provers Verify

    Formal proofs usually involve four steps: rewriting natural language propositions into formal languages, constructing proof strategies, calling a proof assistant (like Lean) for step-by-step verification, and modifying strategies based on errors. The model helps most in the second and fourth steps, as it can propose candidate lemmas and adjust proofs based on error messages.

    The proof assistant checks the consistency between the proof and the stated theorem. If the theorem statement is incorrect—for example, missing an assumption—the prover will still pass validation, but the conclusion will no longer match the original proposition. Therefore, manual verification of the theorem statement is an indispensable step in this process.

    The complete formalization of Fermat’s Last Theorem is a long-term engineering project requiring extensive math libraries and years of team effort. Describing it as a task a model can complete in a short time is inaccurate and misleading. A more realistic use case is having models assist in completing intermediate lemmas in math libraries or helping researchers quickly test small-scale instances of a conjecture.

    1. Visual Understanding: Can Generate Drafts, Not Ready for Direct Production

    Multimodal models can identify components, connections, and labels in circuit schematics, and read dimension and view relationships in structural sketches. In hardware design, models can generate initial drafts of Hardware Description Language (HDL) based on recognition results, such as register definitions, interface modules, or state machine frameworks.

    There are three main risks with these drafts. First, when lines cross, symbols are similar, or resolution is low in a diagram, the model may misidentify connection relationships. Second, the generated code might pass syntax checks but fail to meet timing constraints or power requirements. Third, circuits related to safety must be processed according to enterprise review procedures. Therefore, model output should be treated as a design reference, double-checked item by item by engineers, and verified through simulation and synthesis before entering subsequent processes.

    1. Safety Tiering: Two Permission Levels for the Same Base Model

    Powerful capabilities also bring misuse risks, with cybersecurity and biology being two sensitive areas. A common practice is to set safety restrictions for general-purpose models during both training alignment and inference filtering stages, refusing to generate malicious code, attack scripts, or synthesis steps for dangerous agents that could directly cause harm.

    Versions for professional research usually require separate application. Applicants must state their research purpose and affiliated institution, sign a usage agreement, and make API calls within a controlled environment. The platform will log calls, limit accessible data ranges, and set rate limits. In vulnerability research, the authorized scope should specify the target system and testing time; testing beyond this scope is not permitted.

    When building similar mechanisms internally, enterprises can check the following: whether the accessor’s identity is verified; whether the purpose aligns with job responsibilities; whether call logs are saved and regularly reviewed by designated personnel; whether sensitive outputs require secondary review; and whether the sandbox is isolated from the production network. These measures cannot replace human judgment but make violations easier to detect.

    1. Inference Performance: Test Speed and Cost Yourself

    Improvements in inference speed primarily come from three technologies. First, memory management, such as PagedAttention in vLLM, which splits the key-value cache into smaller blocks to reduce memory fragmentation. Second, Continuous Batching, which immediately inserts new requests after one finishes, improving GPU utilization. Third, quantization, reducing weights from 16-bit to 8-bit or 4-bit to decrease memory usage. The trade-off is that output quality for some tasks may degrade.

    The actual benefits of these technologies depend on model size, input length, concurrency, and hardware model, with no uniform improvement ratio. Any claim about “how much faster” should be accompanied by test conditions: model version, hardware model, batch size, quantization configuration, input/output length, and measurement method.

    Costs also need to be calculated independently. API fees are typically determined by input tokens, output tokens, and cache hit conditions, and different vendors have inconsistent billing metrics. When calculating, use real business request samples to compute the total cost per 1,000 calls and periodically update against the latest price lists.

    1. Deployment Checklist

    Before integrating an LLM into a production environment, it is recommended to confirm the following items one by one:

    1. The model version is fixed, and a regression test set exists before upgrades.
    2. The inference framework and its version are recorded, and the GPU model and memory capacity are confirmed.
    3. Maximum concurrency and the longest context for a single request have been stress-tested.
    4. The quality evaluation results corresponding to the quantization precision have been compared and deemed acceptable.
    5. Metrics including first token latency, overall latency, throughput, error rate, and cost per call are monitored.
    6. A rollback plan is in place to switch to the previous version or a backup model in case of quality issues.
    7. Every change to prompts and configurations is versioned for easier troubleshooting.

    8. Common Failure Modes

    In practice, several types of problems recur. First, cross-file dependency judgment errors, where the model misses relationships established through configuration files or reflection calls. Second, key information in long contexts is ignored, especially constraints located in the middle of the document. Third, theorem statements in formal proofs are written incorrectly. Fourth, recognition omissions occur in complex layout diagrams. Fifth, focusing only on single output effects without building a stable evaluation set, leading to silent quality degradation after version upgrades.

    These issues can be avoided through processes: batch processing, retaining manual review nodes, establishing fixed evaluation sets, and recording every change.

    1. Conclusion

    The value of LLMs in programming and research mainly lies in reducing repetitive labor and accelerating exploration. Their outputs can serve as working drafts and candidate solutions, but correctness still requires confirmation through testing, proof assistants, simulation, or expert review. As long as teams first clarify capability boundaries, validation methods, and cost data, they can more safely decide which steps to hand over to the model and which to retain for human completion.