Build a Local LLM Study Buddy

Computer Science

Build a Local LLM Study Buddy

Build a Local LLM Study Buddy

Turn your early Node and React experience into a practical AI project: a terminal study buddy that sends well-structured questions to a locally running LLM, explains concepts, gives examples, and creates a small practice challenge. You will learn what an LLM is by making each part of the app visible—from prompt construction and token limits to model settings, conversation history, and dependable error handling.

4 modules11 lessonsComputer Science

What you learn by building this

Build it yourself, get guided when you are stuck, and leave with proof you can actually show.

Learning Journey

1

Make the LLM Pipeline Visible

3 lessons

Start with the ideas an LLM app actually needs, then create a small Node-based prompt playground that makes the input and output flow concrete before any model connection is involved.

2

Connect the Study Buddy to a Local Model

3 lessons

Bridge from the prompt playground to one real local model request, using Ollama so the learner can run a model without signing up for a paid API.

3

Shape Answers Students Can Use

2 lessons

Make generation more consistent by strengthening the prompt and checking the response before presenting it as study guidance.

4

Turn It into a Dependable Study Tool

3 lessons

Finish the project as a command a learner can repeatedly use, including short-term conversation context, safe local setup guidance, and a runnable demonstration mode.

Public lesson

Trace What Happens When an LLM Answers

Think of the same language model in two familiar places:

  • Autocomplete: you type Happy birth...; it predicts what text may come next.
  • Chat: you ask a question; it predicts a useful reply one piece at a time.

The core mechanism is similar. Chat just gives the model more instructions and conversation text before it starts predicting.

1. Name the parts

Use this tiny chat request:

“Explain photosynthesis in two sentences for a 12-year-old.”

Match each part:

PartMeaningIn this example
ModelThe trained text-prediction systemThe AI service your app calls
PromptText/instructions you send to the model“Explain photosynthesis…”
TokensSmall chunks of text the model reads and writesParts of words, words, punctuation
ContextAll the information available for this one answerInstructions + user question + any included history
Generated outputNew tokens the model produces as its answerThe two-sentence explanation

A prompt is part of the context. Context is the larger package the model can see.

Quick check

If your Study Buddy sends:

You are a patient study assistant.
Student topic: fractions
Student question: Why do we need a common denominator?

Which lines are the prompt?

Answer: all three lines. Together, they are text sent to guide the model.

What is context here?
Answer: those lines, plus any other messages or materials your app includes for that request.

2. Watch the sequence

When a student presses Ask Study Buddy, this is the basic path:

student types a question
your app builds context
your app sends that context to a model
the model generates output tokens
your app displays the reply

The model does not automatically know who the student is, what they studied yesterday, or what your app is called. Your app must send the useful parts each time.

For example, if you want Study Buddy to answer at the right level, your app might include:

Student level: beginner
Current subject: biology
Question: What is mitosis?

Without that context, the model may still answer—but it has less guidance about the learner and task.

Predict

What will happen?

3. Tokens are not exactly words

Before moving on, predict: is this one token?

unbelievable

Usually, no. Models split text into chunks called tokens. A long word may become several tokens; punctuation can be a token too.

You do not need to count tokens by hand. The practical rule is:

More text sent in context and more text generated in the response both use tokens.

This matters for Study Buddy because sending an entire chat history, a whole textbook chapter, and a long answer request can make each request larger and more expensive. It can also bury the student’s actual question.

Tasks

4. Build your Study Buddy input-to-output map

Choose one realistic student action, such as:

  • asking for help with a homework question
  • requesting a quiz
  • asking the buddy to explain a concept
  • submitting an answer for feedback

Copy this map into your notes and fill it in for one action. Keep each field short.

STUDENT ACTION:
[What does the student type or click?]

MODEL:
[Which AI model/service will the app call?]

PROMPT INSTRUCTIONS:
[What should Study Buddy ask the model to do?]

USEFUL CONTEXT:
[What information would improve this answer?]

DO NOT SEND:
[What is unnecessary, private, or likely to distract the model?]

DESIRED OUTPUT:
[What should the student receive?]

For USEFUL CONTEXT, consider only information that changes the quality of the response:

  • current subject or topic
  • learner level
  • the student’s question
  • the last one or two relevant messages
  • a specific assignment instruction, if the student provided it

For DO NOT SEND, consider:

  • unrelated old chat messages
  • private information not needed for learning
  • duplicate instructions
  • a whole document when one relevant excerpt is enough

Tasks

Visible check

Read your map from top to bottom. Someone unfamiliar with your app should be able to answer these two questions:

  1. What text or information is sent to the model?
  2. What will the student see afterward?

If either answer is unclear, tighten that field before continuing.

Tasks

5. Make one context decision

Here is a common situation:

Earlier conversation:
- Student: I have a math test Friday.
- Study Buddy: What topic?
- Student: Fractions.

New question:
"Can you explain equivalent fractions?"

Decide what to include in the next request:

  • A. Only the new question
  • B. The new question + “topic: fractions”
  • C. Every Study Buddy conversation the student has ever had

Write your choice beside your map.

Best default: B. The topic is relevant context; the entire history usually is not. As your app grows, choosing the smallest useful context will keep its answers more focused.

Explain it back

Put it in your own words

6. One sentence to keep

Complete this in your own words:

Study Buddy does not send a question directly to “AI”; it sends a ______ to a ______, which uses the available ______ to generate an ______.

Check your sentence includes these ideas:

prompt → model → context → output

20 more characters

Keep your completed input-to-output map. It becomes the decision guide for the first AI request your Study Buddy will make.

Course Outline

4 modules · 11 lessons

Make the LLM Pipeline Visible

Connect the Study Buddy to a Local Model

Shape Answers Students Can Use

Turn It into a Dependable Study Tool

Learn by building your own version.

Remix this public project to open the workspace, follow the guided build, and let the AI mentor teach you through the work instead of doing it for you.