Generative AI Hands-On Practice: Core Principles, Local Setup, and Prompting

    This article presents a practical, hands-on approach to learning generative AI through a reusable workflow: understanding the principles, preparing a local runtime, applying prompt engineering methods, validating results on real tasks, and building risk and compliance awareness. It covers the shift from rule-based systems to large pretrained models, the role of attention and multimodal generation, the benefits and trade-offs of running models locally, model sizing and deployment steps, structured prompt design, typical use cases with agent collaboration, and ethical and legal safeguards. Readers will gain a clear framework for turning generative AI into a dependable tool for study and productivity.

    1. Why Learn Generative AI by Doing in a General Education Course

    Generative AI has moved from research labs into everyday production workflows. For university students, instructors, and working professionals, the real skill is not memorizing a list of terms. It is building a repeatable practice chain: understand the principles → prepare the runtime environment → master prompting methods → validate results on real tasks → develop judgment about risk and compliance.

    The value of learning by doing is that it ties abstract concepts to observable operational results. Every difference between input and output is a measurement of the model’s behavioral boundaries. Following this idea, this article is reorganized into four layers: technical evolution and capability boundaries, local deployment and interactive interfaces, prompt engineering methods, and scenario-based applications with governance.

    2. Technical Evolution: From Rule-Based Systems to Large Pretrained Models

    2.1 Three Major Paradigm Shifts

    The technical path of AI has gone through roughly three stages. Early work was dominated by symbolic approaches and expert systems, which relied on manually written rule bases. These systems were highly interpretable but generalized poorly, and the cost of maintaining rules rose sharply as scenario complexity increased. Statistical learning then introduced a data-driven approach, with performance highly sensitive to feature engineering. In the deep learning stage, multi-layer networks learned representations automatically, achieving breakthroughs in vision, speech, and natural language processing tasks.

    2.2 The Key Change Brought by Attention

    The core foundation of large language models is the self-attention structure. It lets any two positions in a sequence connect directly, easing the long-range dependency problem, and it is naturally suited to parallel computation. On top of this, pretraining plus fine-tuning became the mainstream paradigm: first learn general language patterns from massive unlabeled corpora, then adapt to a specific task with a small amount of labeled data. This paradigm significantly reduced the sample requirements of downstream tasks.

    2.3 Multimodal Expansion of Generative Capabilities

    The capabilities of generative models have expanded from plain text to images, audio, and code, forming multimodal content generation. A rational point to keep in mind is that model output is essentially a sample drawn from a probability distribution. As a result, factual bias and content that “looks reasonable but is not correct” can occur. Any output used in decision-making, medical, legal, or financial scenarios must go through human review and source verification.

    3. Running Large Models Locally: Benefits, Selection, and Workflow

    3.1 Practical Benefits of Local Deployment

    In some teaching and intranet scenarios, local deployment offers clear value: data stays inside the network, which helps meet compliance requirements; it can be used offline with low network dependency; it makes it easy to demonstrate the model’s inference process in class; and long-term costs are more controllable. The trade-off is hardware requirements, and model capability is usually weaker than that of very large cloud-hosted models.

    3.2 Matching Model Size to Resources

    When choosing a model, three dimensions matter most: parameter count, quantization precision, and context length. More parameters generally require more VRAM or memory; quantization can significantly reduce resource usage but may bring some precision loss; context length determines how much material can be processed in a single pass. The practical recommendation is to start with a smaller size, validate task results, and then increase the size step by step.

    An illustrative way to estimate resources (not an exact formula, only to build a sense of scale):

    1. Required memory ≈ parameter count × bytes per parameter × runtime overhead factor
    2. # For example, 7B parameters, 16-bit weights, overhead factor of 1.2–1.5
    3. # With 4-bit quantization, bytes per parameter drop significantly, and resource needs fall accordingly

    3.3 Standard Deployment Workflow

    1. Environment check: confirm the OS version, memory and VRAM capacity, and remaining disk space.
    2. Runtime framework preparation: install unified model runtime and inference service components, then pull and verify the model.
    3. Graphical interface setup: prepare a Python runtime first, add the necessary build and runtime libraries, then connect an open-source-style chat interface service.
    4. Service parameter tuning: set the listening address, concurrency limit, context window, and batching strategy.
    5. Acceptance testing: use a fixed set of questions to verify response correctness, time to first token, and sustained throughput.

    Common problems fall into three categories: a port already in use, dependency version conflicts, and insufficient VRAM causing load failures. The recommended handling order is to check the service logs → locate the first error → rule out issues one by one, rather than blindly reinstalling the environment.

    4. Prompt Engineering: From Asking to Asking Precisely

    4.1 The Three-Layer Structure of a Prompt

    A robust prompt usually contains three parts: role setting, task description, and constraints, with output format and examples added when necessary. The role setting affects terminology style, the task description defines the goal, and the constraints draw the boundaries.

    1. You are [role].
    2. Please complete [task].
    3. Requirements: [constraint 1, constraint 2, word count/format].
    4. Reference example: [input → output].
    5. If information is insufficient, first list the questions that need clarification.

    4.2 Common Advanced Techniques

    • Few-shot examples: provide two or three input-output pairs to stabilize the output structure.
    • Task decomposition: ask for key points first and then the full text, reducing the chance of omissions.
    • Self-checking: ask the model to flag uncertain content and list verification methods.
    • Structured output: agree on JSON or table fields to make later program processing easier.
    • Iterative convergence: change only one variable at a time, observe the output change, and keep reproducible experiment records.

    4.3 Frequent Beginner Problems and Fixes

    Vague output is often caused by missing audience and scenario limits; format drift is often caused by not providing examples; inaccurate content is often caused by not requiring uncertain items to be flagged; off-topic answers are often caused by mixing the task and constraints in one long sentence. The fix is to split the prompt into structured blocks and keep version records for traceability.

    5. Typical Use Cases and Agent Collaboration

    In learning scenarios, generative AI can be used for concept explanation, step-by-step problem walkthroughs, review plan generation, and error-cause analysis. In research scenarios, it can help summarize key points from literature, brainstorm research directions, debug code, and organize experiment records, but citations must be verified against the original sources. In office scenarios, it can work with document, spreadsheet, and presentation tools to produce summaries, first drafts, and formatting cleanup. Going further, combining prompts, knowledge retrieval, and external tool calls forms an AI agent: the model handles planning and expression, retrieval handles factual sources, and tools handle executing actions.

    In general capability systems on cloud platforms such as Baidu AI Cloud, this kind of practice can typically rely on a container platform to host inference services, object storage to hold datasets, a message queue to decouple tasks, and logging plus monitoring and alerting to ensure observability, turning a single demo into an application that can run sustainably.

    6. Ethics, Law, and Risk Control

    Compliant use requires four bottom lines: do not input unauthorized personal information or trade secrets; fact-check generated content and review copyright; clearly label AI-generated content; and establish a human final review step. At the same time, attention should be paid to algorithmic bias, data authorization, and responsibility attribution. Teaching and enterprise management should form written usage guidelines rather than relying on individual habits.

    7. Conclusion

    General education competency in generative AI comes down to three verifiable things: being able to explain the principles and boundaries, being able to independently complete deployment and debugging, and being able to use structured prompts to reliably produce usable results. Practicing in the order of principles → deployment → prompting → scenarios → governance builds a complete cognitive loop within limited class hours and genuinely turns the tool into a gain in study and productivity.