Show a desktop notification when the AI TA finishes replying
Notify me when classmates post messages in the forum
Play an alert sound whenever there is a new notification
Explain how Uedu uses Retrieval-Augmented Generation (RAG) to ensure the AI TA's replies are grounded in teaching materials uploaded by Instructors, improving answer accuracy and teaching relevance.
The AI teaching assistants (UeduGPTs) on the Uedu platform support the AI knowledge base function: Instructors upload Course materials (PDF, DOCX, PPTX), and the system automatically chunks and vectorises the materials. When students ask questions, it performs semantic retrieval and injects the most relevant material excerpts into the AI's System Prompt so that the AI's replies can be grounded in the Course materials.
This mechanism is known as RAG (Retrieval-Augmented Generation), which is the current mainstream method used in the industry to enable LLMs to answer with evidence. This document explains the implementation details of Uedu's RAG for researchers to understand the data generation process.
RAG (Retrieval-Augmented Generation) is an architecture that combines information retrieval and text generation (Lewis et al., 2020). Its core concept is:
Compared with answers that rely only on an LLM’s built-in knowledge, RAG allows AI replies to be grounded in specific teaching materials, reducing the risk of hallucination and ensuring the content remains relevant to the Course.
After the Teacher uploads course materials, the system carries out the following processing steps in the background:
The system supports three file formats, and uses the corresponding Python packages to extract the full text:
| Format | Extraction tool | Page tracking |
|---|---|---|
| pypdf | Retain original page numbers | |
| DOCX | python-docx | No page numbers (paragraphs merged) |
| PPTX | python-pptx | Retain slide numbers |
The extracted full text is tokenised into chunks at token level using the tiktoken cl100k_base tokenizer:
Chunking is carried out page by page (or slide by slide). If the text on a single page is no more than 800 tokens, treat the page as one whole chunk; otherwise, use token-level sliding segmentation.
The text of each chunk is converted by OpenAI text-embedding-3-small into a 1536-dimensional dense vector, stored in the database BLOB field as float32.
When a student submits a question, the system carries out the following retrieval steps before replying:
text-embedding-3-small)Cosine similarity measures the degree of directional closeness between two vectors, with a range of [-1, 1]. In embedding space, texts with similar meanings will have higher similarity scores. The system uses numpy for efficient matrix operations.
| Parameter | Value | Description |
|---|---|---|
EMBEDDING_MODEL | text-embedding-3-small | OpenAI embedding model |
EMBEDDING_DIMENSIONS | 1536 | Vector dimension |
CHUNK_MAX_TOKENS | 800 | Maximum token count per chunk |
CHUNK_OVERLAP_TOKENS | 100 | Number of overlapping tokens between adjacent chunks |
CHUNK_MIN_TOKENS | 20 | Minimum chunk length (discard if below this value) |
RETRIEVAL_TOP_K | 3 | Maximum number of chunks returned per retrieval |
RETRIEVAL_THRESHOLD | 0.3 | Minimum cosine similarity threshold |
CACHE_TTL | 300 seconds | Memory cache retention time |
Uedu supports advanced GraphRAG mode. When the Instructor turns on this mode, the system will not only use standard vector retrieval, but will also useKnowledge graphProceedGraph expansion retrieval:
When expanding the graph, the edge weights for prerequisite (prior knowledge) and contains (containment relationship) will receive a 1.2x boost, and teaching materials for these two types of links will be prioritised.
Standard RAG relies only on vector-similarity retrieval, and may miss teaching materials that are not directly similar in meaning but are conceptually related. GraphRAG supplements these fragments through structured links in the knowledge graph, improving the completeness of answers.
Detailed logs for each retrieval are stored in the rag_retrieval_log table, including:
These records allow researchers to analyse “which textbook segments AI referred to when answering” and “the degree of semantic match between Student questions and the teaching materials”.
The AI Teaching Assistant’s replies are grounded in teacher-uploaded materials via Retrieval-Augmented Generation (RAG; Lewis et al., 2020). After text extraction, material files (PDF/DOCX/PPTX) are semantically chunked with the tiktoken cl100k_base tokenizer (up to 800 tokens per chunk, with 100 tokens overlap between adjacent chunks), then converted by the OpenAI text-embedding-3-small model into 1,536-dimensional dense vectors. When a Student asks a question, the system retrieves the most semantically relevant material passages using cosine similarity (top-3, threshold 0.3) and injects them into the AI System Prompt as the basis for its reply. Each retrieval record (matched passages, similarity scores) is retained for research analysis. See the detailed methodology at https://uedu.tw/doc/rag.
It is recommended to add the following information as a note as well: