How to Use Large Language Models Effectively: Prompt Engineering and Practical Implementation

    This article explains why the same large language model can produce very different output quality depending on how it is prompted, and presents a practical workflow for getting reliable results. It covers precise prompting techniques such as role assignment, structured constraints, and few-shot examples; pre-setting output formats with format seeds, LaTeX conventions, and maintainable code requirements; controlling variability with temperature settings, step-by-step decomposition, and self-check instructions; and exporting generated content into deliverable documents without formatting loss. A list of common mistakes and a pre-delivery checklist are included to help turn LLM output into a stable productivity asset.

    1. The Starting Problem: Why the Same Model Produces Very Different Output Quality

    In real-world development, data analysis, and document writing, the difficulty people face with large language models is usually not that “the model is not strong enough,” but that “the input is not precise enough.” The same model can produce output with several times the difference in usability depending on whether it receives a vague instruction or a rigorous one. Vague questions tend to return generic sample code or broad conclusions, while well-designed prompts can directly produce implementations that can be embedded into a project.

    The core of efficient usage, therefore, is not memorizing the special operations of a particular product, but mastering general prompt engineering methods. The following five stages form a complete chain: precise prompting → content optimization → format stability → error prevention → practical export.

    2. Precise Prompting: Aligning the Model with Your Actual Intent

    2.1 Role Assignment: Giving the Model Professional Context

    An inefficient prompt is typically “help me write some code,” which leaves the model with no way to determine the tech stack, business scenario, or acceptance criteria. The effective approach is to explicitly assign a role and task boundaries:

    1. You are a senior backend engineer who needs to implement a user behavior statistics function for an e-commerce scenario.
    2. Requirements:
    3. 1. Input: a list of user IDs; output: each user's purchase frequency and average order value;
    4. 2. Implement it with a tabular data processing library, compatible with mainstream Python 3 versions;
    5. 3. Comment the key logic, and provide sample input and expected output.

    Role assignment serves two purposes. First, it activates the expressions and engineering habits associated with a “senior engineer” in the model’s training corpus (exception handling, boundary checks, naming conventions). Second, acceptance criteria turn “runnable” into a hard constraint, reducing rework later.

    2.2 Structured Constraints: Drawing Boundaries with Explicit Markers

    Words like “preferably” and “as much as possible” in natural language exert weak constraint on the model. Switching to symbolic markers noticeably increases constraint strength:

    1. Analyze three major technology trends in new energy vehicles.
    2. # Must include: battery technology, charging efficiency, intelligence
    3. # Must not include: macro policy background unrelated to the trends
    4. # Format requirement: bullet points, each point no more than 100 words

    The three marker types have distinct roles: “must include” guarantees information coverage, “must not include” compresses redundancy, and “format requirement” locks the output shape. Combined, they turn open-ended Q&A into predictable structured deliverables.

    2.3 Adding Context and Examples (Few-shot)

    If the task style is highly fixed, providing one or two input-output examples is more effective than long strings of adjectives. Examples should cover a typical case and one boundary case, and the model will infer the implicit rules from them.

    3. Content Optimization: Pre-set the Format, Ready to Use

    3.1 The Format Seed Method

    Writing the target skeleton during the prompting stage and letting the model only “fill in the blanks” eliminates a great deal of later adjustment:

    1. Generate a framework for an annual marketing plan, filled in according to the following template:
    2. ## 1. Target Audience
    3. [audience profile and core needs]
    4. ## 2. Core Strategy
    5. [List 3 strategies as bullet points, each with a goal and a measurement metric]
    6. ## 3. Budget Allocation
    7. [Present as a table: Channel | Share | Amount | Expected Outcome]

    This approach is especially effective for proposals, reports, and review materials, because reviewers usually care about structural completeness rather than rhetorical polish.

    3.2 An Error-Safe Way to Write Mathematical Formulas

    Formulas should use standard LaTeX syntax wrapped in dollar signs to avoid parsing ambiguity:

    1. Derive the loss function of linear regression, presented in LaTeX:
    2. $ J(\theta) = \frac{1}{2m}\sum_{i=1}^{m}\left(h_\theta(x^{(i)}) - y^{(i)}\right)^2 $

    It is also important to distinguish “inline formulas” from “display formulas,” otherwise later typesetting can easily break formulas across lines or misalign superscripts and subscripts.

    3.3 Maintainability Requirements for Code Output

    1. Implement quicksort in Python, with the following requirements:
    2. - Label the ```python code block language type
    3. - State the time and space complexity in the comments
    4. - Include at least one boundary case (empty list, duplicate elements)

    Specifying the language identifier improves readability and makes it easier for downstream tools to apply syntax highlighting and static checks.

    4. Stability Control: Confining Uncertainty

    Model output is inherently random, and three methods are commonly used in engineering to converge results:

    1. Temperature and sampling control: lower randomness when you need stable, reproducible results; raise it when you need creative divergence.
    2. Step-by-step decomposition: split “research + design + coding + self-testing” into multiple conversation turns, each solving only one thing, which makes deviations easier to locate.
    3. Self-check instructions: ask the model to list assumptions, risks, and uncovered scenarios at the end, making implicit premises explicit.

    In addition, when enterprise data is involved, follow the principle of minimum necessity and desensitize data before input to avoid leaking sensitive information.

    5. The Last Mile: From Generation to Deliverable Documents

    Model output is mostly Markdown or LaTeX text. Pasting it directly into office software commonly causes three problems: garbled formula symbols, lost code indentation, and broken table alignment. A workable path is as follows:

    1. Use the dedicated copy function provided in the answer area to preserve the original markup, rather than selecting text with the mouse and copying;
    2. Use an editor or conversion service that supports format conversion to turn Markdown/LaTeX into a standard document format;
    3. After export, check three things: whether formulas remain editable, whether code blocks retain highlighting and indentation, and whether table column widths are aligned.

    When conditions allow, a more robust approach is to put the content under version control in a repository, maintain it as documentation-as-code, and then use continuous integration to render deliverables automatically, fundamentally avoiding the format loss caused by manual pasting. The required capabilities can typically be provided by general cloud services, for example object storage for build artifacts, and logging services with monitoring and alerting to track rendering task status.

    6. Common Mistakes and a Checklist

    • Mistake 1: Cramming too many goals into a single prompt. Split them into multiple turns, each with a single clear acceptance criterion.
    • Mistake 2: Describing only expectations without boundaries. Adding “must not include” is often more effective than piling on more adjectives.
    • Mistake 3: Ignoring output shape. Setting the template first and then generating saves more time than reformatting after generation.
    • Mistake 4: Treating model output as a source of truth. Key data and conclusions need secondary verification.

    Pre-delivery checklist: Are the role and task clear? Are the constraints verifiable? Is the format template pre-set? Are the formula and code syntax standard? Are the three format checks completed after export? Practicing this workflow turns large language models from a “demo tool” into a stable productivity component.