## 3 Materials and Methods
### Phase 3: RAG Pipeline (Core)  
This phase focused on designing and implementing the RAG pipeline, which is the core mechanism for generating contextually grounded educational content in response to user queries. The pipeline comprises four main components: model selection, semantic retrieval, integration of prompt engineering, and the orchestration of content generation flows for different academic resources. All prompts, user inputs, and system outputs were developed and evaluated in Spanish, ensuring full alignment with the instructional language of the course and facilitating broader adoption across Latin American institutions. The first component involved the selection of LLMs suitable for the assistant's architecture. GPT-40 mini was chosen as the primary model for handling complex queries due to its robust comprehension capacity and operational efficiency [34], along with support for up to one hundred twenty-eight thousand input tokens and a benchmark score of eighty-two percent on the Massive Multitask Language Understanding (MMLU) [35]. For lightweight tasks, the assistant employed Gemini _Flash 2.0_, a high-speed model suitable for prompt responses with lower cognitive demand [36]. To complement the generation process, a semantic retrieval module was developed to extract the most relevant information from the vector database prior to generation. The assistant uses a vector similarity search in Qdrant to retrieve the five most relevant content fragments based on the user's query, filtered by metadata parameters such as unit and topic. These filters, defined at the moment of document ingestion, ensure that the language model receives highly contextualized input. Figure 3 shows the workflow of the question-and-answer generation process. Once the relevant context is retrieved, prompt engineering plays a critical role in shaping the interaction with the language model. Custom prompt templates were designed for each type of academic resource. In the case of the question-and-answer flow, the assistant is instructed to explain the concept in detail, provide a sample code, and present an interactive explanation aligned with the topic selected by the student. An example of the prompt structure applied in this flow is shown in Algorithm 1. In the quiz generation flow, a structured prompt is used to create both theoretical and coding questions. The assistant is guided to generate a problem statement with a real-world use case, provide a traditional solution, and suggest a parallel computing code base to be completed by the student. The results are returned in JSON format and stored for later review. This process is shown in Figure 4.  
The final generation flow supports the creation of practical guides. These prompts are structured to generate a detailed problem description, a list of functional requirements, and a rubric of evaluation based on a total score of ten points. Unlike previous flows, the context in this case is restricted exclusively to documents tagged as laboratory practices, ensuring thematic and instructional alignment. Each response is saved and associated with metadata for future evaluation and analysis, as illustrated in Figure 5.  
The integration of all components, language model selection, semantic retrieval, and task-specific prompt engineering resulted in a flexible, scalable architecture capable of delivering educational responses tailored to the course structure and instructional goals. This phase concluded with the deployment of a fully functional RAG pipeline, forming the intelligent core of the educational assistant and enabling real-time, pedagogically relevant interactions between students and the system. Figure 3: Workflow for the generation of questions and answers. The assistant receives a student query, retrieves relevant fragments based on metadata, and returns a contextualized explanation with code examples.