NLP · LLM · Prompt Engineering · Python

LLM-Based
Course Planner

Personalized academic course planning system powered by a locally-hosted LLM — using structured JSON prompting, retry logic, Chain-of-Thought reasoning, and multi-step decomposition to generate reliable learning paths.

4prompting techniques
3retry attempts
CoTchain-of-thought
JSONstructured output
00

Overview

This project builds a course planning assistant that takes a student's academic background and target course, then queries a local LLM API to generate structured, step-by-step learning path recommendations. Four progressively sophisticated prompting strategies were implemented and compared.

Python Prompt Engineering LLM API JSON Parsing Chain-of-Thought Multi-step Reasoning Retry Logic Error Handling

System Pipeline

01
Student Input
Department, degree level, completed courses, target course
02
Prompt Build
Dynamic prompt with course catalog, constraints, and output format
03
LLM Query
POST to local API with retry logic on malformed responses
04
Structured Plan
Parsed JSON learning path with ordered prerequisite steps
01

Four Prompting Strategies

1
Zero-Shot JSON Prompting
Single prompt instructing the LLM to return only a valid JSON object with prerequisites and learning path. No examples provided.
structured output
2
Retry Logic + JSON Repair
Added automatic retry on malformed JSON — strips comments, sanitizes response, re-queries up to 3 times before fallback. Handles LLM hallucinations gracefully.
error handling
3a
Chain-of-Thought (CoT)
Explicit multi-step reasoning — LLM identifies required concepts, compares with student background, identifies gaps, then recommends only courses from the catalog.
CoT reasoning
3b
Multi-Step Decomposition
Breaks the task into 3 independent LLM calls: (1) required knowledge topics, (2) gap analysis, (3) course recommendations — each step feeds the next.
pipeline decomposition
02

Prompts & Outputs

Part 1 — Zero-Shot JSON Prompt

System Prompt
You are an academic advisor. Based on the student profile and available courses, return only a valid JSON object. Do not add any explanation, notes, or markdown.

Student Profile:
Department: Computer Science
Level: Undergraduate
Completed: CSCI 256, CSCI 356, CSCI 343
Target Course: Deep Learning
LLM Response — Parsed JSON
"target_course": "CSCI 492 Deep Learning (Undergraduate)",
"recommended_prerequisites": [
  { "course_number": "CSCI 356", "course_name": "Data Structures in Python" },
  { "course_number": "CSCI 343", "course_name": "Fundamentals of Data Science" }
],
"suggested_learning_path": [
  { "step": 1, "course_number": "CSCI 343" },
  { "step": 2, "course_number": "CSCI 632", "course_name": "Machine Learning" },
  { "step": 3, "course_number": "CSCI 492", "course_name": "Deep Learning" }
]

Part 3b — Multi-Step Decomposition Output

Step 1 — Required Knowledge Topics
Programming in Python
Machine Learning
Optimization Algorithms (e.g., Gradient Descent)
Data Handling and Preprocessing
Neural Networks (basic architecture, backpropagation)
Step 2 — Gap Analysis
Python — covered via CSCI 256
Data Science basics — covered via CSCI 343
✗ Machine Learning — not taken, gap identified
✗ Neural Networks — not taken, gap identified
✗ Optimization Algorithms — gap identified
Step 3 — Final Learning Path
Step 1: CSCI 632 — Machine Learning
Step 2: CSCI 356 — Data Structures in Python
Final: CSCI 492 — Deep Learning (Target)
03

Technique Comparison

4prompting strategies
3max retry attempts
3decomposed LLM calls
PartTechniqueOutput FormatReliabilityKey Feature
1Zero-shot JSONJSONModerateSimple, fast
2Retry + JSON repairJSONHighHandles malformed responses
3aChain-of-ThoughtFree text → structuredHighExplicit reasoning steps
3bMulti-step decomposition3 × JSONHighestEach step verifiable

Multi-step decomposition (Part 3b) produced the most reliable and explainable results — breaking the problem into independent LLM calls means each step can be validated separately, hallucinations are caught early, and the reasoning chain is fully transparent. Chain-of-Thought (3a) improved reasoning quality by forcing the model to justify each recommendation before committing to a course suggestion.