Practical Guide to Teaching LLMs and RAG in Vocational AI Education

    As AI education in vocational schools shifts from basic theory to hands-on application, this guide breaks down what students need to master for AI-focused skills competitions and real-world development. It covers competition-level capability requirements, the end-to-end workflow of building applications on top of large language models (including prompt engineering and API integration), and the implementation of Retrieval-Augmented Generation (RAG) systems—from offline document indexing to online retrieval and generation. It also shares teaching strategies such as combining lectures, hands-on labs, and team-based project work, along with competition preparation tips like the MVP approach. The article includes illustrative code examples for LLM API calls and RAG prompt assembly.

    With the rapid evolution of artificial intelligence—driven above all by breakthroughs in large language models (LLMs)—AI education in vocational schools is facing a pivotal transition from foundational theory toward comprehensive, applied practice. A key challenge for educators is helping students quickly grasp cutting-edge AI technologies and build the practical skills needed to compete in high-level vocational skills competitions. This guide walks through four modules: interpreting AI competition requirements, the workflow for building LLM-based applications, implementing RAG pipelines, and teaching and coaching strategies.

    1. Interpreting AI Competition Requirements and Core Competencies

    AI tracks at major vocational skills competitions have evolved from early image recognition and simple data analysis tasks to LLM application development and complex system construction. The core assessment areas now include:

    1. Scenario understanding and requirements decomposition: Contestants must translate real business scenarios (such as intelligent customer service, assisted diagnosis, or smart agriculture) into clearly defined AI task boundaries.
    2. LLM application development: Rather than writing low-level algorithms, the focus is on integrating applications via LLM APIs—including prompt engineering, multi-turn conversation management, and Function Calling.
    3. Retrieval-Augmented Generation (RAG): Competitions increasingly emphasize combining LLMs with private domain knowledge. Contestants are expected to build a complete RAG system that mitigates hallucinations and improves answer accuracy in specialized domains.
    4. Engineering deployment and presentation: Entries must include a complete interactive interface, a stable backend service, and a clear system architecture explanation.

    Analysis of past award-winning entries shows that winning projects typically excel in two areas: knowledge base construction quality and prompt tuning strategies. This points the way for everyday teaching: strengthen students’ ability to process real business data and to fine-tune model behavior.

    2. Building LLM Applications: The Core Technical Workflow

    At the vocational education level, “building a large model” usually means application-level development on top of industry-standard solutions or mature cloud services (for example, Baidu AI Cloud’s LLM platform). The process covers the full lifecycle from requirements analysis to business integration.

    2.1 Requirements Analysis and Model Selection

    First, determine the task type based on the application scenario (text summarization, sentiment analysis, information extraction, etc.). For vocational teaching, it is advisable to choose a foundation model with strong general capabilities and solid API support. Developers can test different models on specific tasks via the provider’s console and select the option with the best cost-effectiveness and performance.

    2.2 Prompt Engineering Best Practices

    The prompt is what steers an LLM toward the desired output, so teaching should emphasize structured prompt writing. A well-crafted prompt typically includes:

    • Role setting: Define the model’s identity, e.g., “You are an experienced computer science instructor at a vocational school.”
    • Task description: State clearly what needs to be done, e.g., “Generate a beginner-friendly lab handout based on the provided lesson plan.”
    • Context/background information: Supply necessary reference material.
    • Output format constraints: Require the model to output in a specific format such as JSON or Markdown for easy programmatic parsing.

    2.3 API Calls and Business Integration

    Technically, LLM capabilities are accessed through standard RESTful API interfaces. The following pseudocode shows how a business backend interacts with a model service:

    1. import requests
    2. import json
    3. def call_llm_api(prompt, api_key, endpoint):
    4. headers = {
    5. "Content-Type": "application/json",
    6. "Authorization": f"Bearer {api_key}"
    7. }
    8. payload = {
    9. "messages": [
    10. {"role": "user", "content": prompt}
    11. ],
    12. "temperature": 0.7, # Controls output randomness
    13. "max_tokens": 1024
    14. }
    15. response = requests.post(endpoint, headers=headers, data=json.dumps(payload))
    16. if response.status_code == 200:
    17. return response.json().get("choices")[0].get("message").get("content")
    18. else:
    19. raise Exception(f"API call failed: {response.status_code}")

    3. Implementing a RAG Workflow and How It Works

    Retrieval-Augmented Generation (RAG) is currently the most important technical paradigm in LLM application development. By introducing an external knowledge base, it compensates for the LLM’s lack of domain-specific knowledge and its tendency to hallucinate. Implementing a RAG workflow involves two phases: offline indexing and online retrieval-and-generation.

    3.1 Offline Data Preparation and Index Building

    This is where RAG systems succeed or fail—data quality directly determines the final generation quality.

    • Document parsing and cleaning: Convert unstructured documents (PDF, Word, TXT, etc.) into plain text, removing noise such as headers, footers, and special characters.
    • Text chunking: Split long documents into semantically coherent short segments. Common strategies include fixed-length chunking and splitting by paragraph or punctuation. Oversized chunks can hurt retrieval precision; undersized chunks may lose context.
    • Embedding: Use an embedding model to convert text chunks into high-dimensional vectors, capturing the deep semantic features of the text.
    • Vector storage: Store the vectors and original text in a vector database (for example, a cloud provider’s vector retrieval service). To improve retrieval efficiency, an approximate nearest-neighbor (ANN) index such as HNSW is typically built as well.

    3.2 Online Retrieval and Generation

    When a user asks a question, the system enters the online phase:

    • Query embedding: Convert the user’s natural-language question into a vector using the same embedding model as in the offline phase.
    • Similarity retrieval: Compute the distance (e.g., cosine similarity) between the question vector and knowledge base vectors in the vector database, recalling the Top-K most relevant text chunks.
    • Reranking (optional): Score the initially retrieved results a second time to filter out low-relevance chunks and improve precision.
    • Context assembly and generation: Combine the retrieved text chunks with the user’s original question into an augmented prompt, which is sent to the LLM to generate the final answer.

    Here is a simplified example of RAG context assembly:

    1. def generate_rag_prompt(user_question, retrieved_docs):
    2. context = "\n".join([f"Document chunk {i+1}: {doc}" for i, doc in enumerate(retrieved_docs)])
    3. prompt = f"""
    4. You are a professional intelligent assistant. Answer the user's question based on the reference information provided below.
    5. If the reference information does not contain the answer, simply say "I don't know" — do not fabricate content.
    6. [Reference Information]
    7. {context}
    8. [User Question]
    9. {user_question}
    10. [Your Answer]
    11. """
    12. return prompt

    4. Teaching Strategies and Competition Coaching Insights

    To help vocational students truly master these complex technical workflows, teaching must move beyond slide-based lecturing and adopt a three-in-one model: theory instruction + hands-on labs + group workshops.

    1. Theory instruction focused on fundamentals and logic: Industry experts and university faculty should focus on explaining technical principles in accessible terms. For example, when teaching vector retrieval, the everyday analogy of “finding the nearest point on a coordinate plane” helps students grasp similarity computation in high-dimensional spaces.
    2. Hands-on labs on cloud platforms: Instructors should guide students through practice on low-code LLM development platforms or cloud-native environments—from configuring environment variables and debugging API calls to building a simple knowledge Q&A bot. Letting students hit and troubleshoot real engineering problems builds practical experience. Free tiers and sandbox environments offered by cloud platforms such as Baidu AI Cloud make excellent training vehicles.
    3. Group workshops centered on problem solving: Organize students into teams of 3–4 that simulate agile development teams. Have them brainstorm solutions to past competition problems—how to optimize document chunking strategies or design more robust prompts. The teacher acts as technical mentor and Scrum Master.

    During competition preparation, time management and engineering trade-offs are critical. Coaches should guide students to follow the MVP (minimum viable product) principle: first build a prototype with the basic RAG pipeline and get the data loop working end-to-end, then iteratively refine retrieval algorithms and UI interactions. When analyzing past entries, train students to evaluate projects from a “judge’s perspective”—innovation, technical difficulty, and business value—building their technical communication and pitching skills.

    Conclusion

    Teaching AI applications in vocational schools is about more than delivering a programming language or a single algorithm—it is about cultivating versatile, skilled talent with engineering mindsets and the ability to solve complex problems. By deeply unpacking the core workflows of LLM applications and RAG, and tightly integrating theory, hands-on practice, and group discussion, educators can build a solid bridge for students from classroom to competition, and from campus to career. As the technology keeps evolving, educators must also continuously refresh their own knowledge and keep exploring new possibilities in AI education.