Skip to main content

Command Palette

Search for a command to run...

The Mathematical Core of AI — Weights, Temperature, and Why AI Responses Change

Published
8 min read
D

Heya! 👋 I love helping people, and one of the best ways I do this is by sharing my knowledge and experiences. My journey reflects the power of growth and transformation, and I’m here to document and share it with you.

I started as a pharmacist, practicing at a tertiary hospital in the Northern Region of Ghana. There, I saw firsthand the challenges in healthcare delivery and became fascinated by how technology could offer solutions. This sparked my interest in digital health, a field I believe holds the key to revolutionizing healthcare.

Determined to contribute, I taught myself programming, mastering tools like HTML, CSS, JavaScript, React, PHP, and more. But I craved deeper knowledge and practical experience. That’s when I joined the ALX Software Engineering program, which became a turning point. Spending over 70 hours a week learning, coding, and collaborating, I transitioned fully into tech.

Today, I am a Software Engineer and Digital Health Solutions Architect, building and contributing to innovative digital health solutions. I combine my healthcare expertise with technical skills to create impactful tools that solve real-world problems in health delivery.

Imposter syndrome has been part of my journey, but I’ve learned to embrace it as a sign of growth. Livestreaming my learning process, receiving feedback, and building in public have been crucial in overcoming self-doubt. Each experience has strengthened my belief in showing up, staying consistent, and growing through challenges.

Through this platform, I document my lessons, challenges, and successes to inspire and guide others—whether you’re transitioning careers, exploring digital health, or diving into software development.

I believe in accountability and the value of shared growth. Your feedback keeps me grounded and motivated to continue this journey. Let’s connect, learn, and grow together! 🚀

At this point, you already understand two important ideas:

  • words become embeddings (numbers)

  • layers transform those numbers step by step

Now we arrive at the next big question:

How does the AI decide what matters most?

Why does it sometimes give:

  • a precise answer

  • a creative answer

  • a strange answer

  • or a completely wrong answer delivered with full confidence?

To understand that, we need to talk about:

  • weights

  • training

  • temperature

  • top-p

This lesson is important because it moves you from:

“AI feels smart”

to:

“I understand why it behaves this way.”

And honestly, that shift changes how you use AI forever.


What Are Weights?

A neural network is made of connections.

Between neurons, there are numerical values called weights.

A weight tells the AI:

“How important is this pattern?”

That’s it.

A weight is simply an importance value.


A Simple Analogy: Volume Knobs on a Mixer

Imagine a music studio.

There’s a giant sound mixer with sliders.

Some sounds are turned up:

  • vocals

  • drums

  • guitar

Others are turned down.

The producer adjusts the mix depending on what matters most.

Weights work similarly.

Inside a neural network:

  • some patterns get amplified

  • some get reduced

  • some are almost ignored

The AI learns which “signals” deserve attention.

That decision is controlled by weights.

weights act like volume knobs that increase or decrease the importance of patterns


How Weights Affect Decisions

Let’s imagine the AI is trying to identify whether a message is spam.

Certain words may become important:

"winner"
"free"
"click now"

During training, the AI may learn:

  • “click now” strongly appears in spam

  • “meeting tomorrow” usually does not

So the weights connected to spam-like patterns become stronger.

Over time, the network learns:

“Pay more attention to these signals.”


Important Point: AI Does Not “Know” Things

This is one of the biggest misconceptions beginners have.

AI does not contain knowledge like a person does.

It does not sit there understanding the world.

Instead:

👉 It adjusts weights based on patterns in data.

That means every response comes from learned mathematical relationships.

Not awareness.

Not consciousness.

Not understanding.

Just calculations based on learned importance values.

That distinction matters a lot.


How Training Actually Works

At the beginning, weights are mostly random.

The AI starts out terrible at tasks.

Then training begins.

The process looks roughly like this:

  1. The AI sees data

  2. It makes a prediction

  3. The prediction is checked

  4. Errors are measured

  5. The weights are adjusted

  6. The process repeats millions of times

Gradually, useful patterns become stronger.

Bad patterns become weaker.

This is how the network “learns.”

Not through understanding.

Through adjustment.


Why Training Data Matters So Much

Here’s something students often underestimate:

The AI becomes shaped by whatever data trained it.

If the training data is excellent:

  • outputs improve

If the training data is biased:

  • outputs become biased

If the training data is poor:

  • outputs become unreliable

This explains many AI problems.

The AI is not inventing beliefs on its own.

It is learning patterns from data.

“garbage in, garbage out” applies strongly to AI systems


Why AI Can Sound Confident While Being Wrong

This part surprises many people.

AI does not truly know whether something is true.

It predicts what response is statistically likely.

So sometimes:

  • the pattern looks convincing

  • the sentence sounds fluent

  • but the information is false

This is why AI hallucinations happen.

The model is generating probable patterns, not checking reality directly.

That is an important limitation to remember.


Temperature: The Creativity Dial

Now let’s move into generation settings.

When you use tools like Google AI Studio, you’ll often see:

Temperature

Temperature controls how predictable or creative the AI becomes.


Low Temperature

Example:

Temperature = 0.2

The AI becomes:

  • safer

  • more focused

  • more predictable

It usually picks the most likely response.

This is useful for:

  • factual answers

  • coding

  • structured tasks


High Temperature

Example:

Temperature = 0.9

Now the AI becomes:

  • more creative

  • more surprising

  • less predictable

It takes more “risks” in word selection.

This is useful for:

  • brainstorming

  • storytelling

  • creative writing

But it can also become:

  • inconsistent

  • strange

  • chaotic


What Temperature Is Really Doing

Under the hood, the AI predicts probabilities for possible next words.

Example:

"The sky is..."

Maybe the probabilities look like:

blue = 70%
gray = 15%
dark = 10%
spaghetti = 0.0001%

Low temperature:

  • strongly favors high-probability choices

High temperature:

  • allows lower-probability choices more often

So creativity increases.

But reliability may decrease.


What Is Top-p?

Top-p is another generation setting.

It controls:

How many possible word options the AI considers before choosing.

This can feel confusing initially, so let’s simplify it carefully.


A Simple Analogy

Imagine the AI has 100 possible next words.

Top-p tells it:

“Only consider the most likely group of words.”

Example:

top_p = 0.9

This means:

The AI keeps selecting likely words until their combined probability reaches 90%.

Then it ignores the rest.


Lower Top-p

Lower values:

  • reduce randomness

  • narrow choices

  • increase focus


Higher Top-p

Higher values:

  • allow more variety

  • increase diversity

  • increase unpredictability


Temperature vs Top-p

Students often confuse these.

Here’s the simplest distinction:

Temperature

Controls:

how bold the AI becomes

Top-p

Controls:

how many options the AI is allowed to consider

Both influence randomness, but differently.


Why These Settings Matter

When you tested temperature and top-p in your assignment, the goal is not just to “see different outputs.”

The goal i to understand:

👉 AI responses are shaped by probability control.

The model is not “changing personality.”

You are adjusting:

  • randomness

  • confidence

  • creativity

  • output diversity


Common Beginner Mistakes

Mistake 1: Thinking AI “knows” the correct answer

It predicts likely patterns.

Sometimes those patterns are correct.

Sometimes they only sound correct.


Mistake 2: Thinking higher temperature means “better”

Higher temperature means:

  • more variety

  • not necessarily more quality


Mistake 3: Ignoring training data

The AI’s behavior is deeply connected to what it learned from.

Training data shapes the weights.

Weights shape the outputs.


Mistake 4: Thinking weights are knowledge

Weights are not facts.

They are learned importance values.

That’s a huge difference.


Mental Model

Here’s the clearest way to think about this lesson:

Weights

= importance signals

Training

= adjusting those signals over time

Temperature

= creativity level

Top-p

= how many choices the AI considers

Together, these shape how the AI generates responses.


Practice Thinking

Try thinking through these carefully:

  1. Why might low temperature work better for coding tasks?

  2. Why could high temperature produce more interesting stories?

  3. What happens if an AI trains on biased information?

  4. Why can AI sound convincing while being wrong?

  5. How are weights different from human understanding?

Do not rush these questions.

These are the kinds of ideas that separate surface-level understanding from real understanding.


Key Takeaways

  • Weights determine how important patterns are inside a neural network

  • AI learns by adjusting weights during training

  • Training data strongly shapes AI behavior

  • AI predicts patterns rather than truly understanding meaning

  • Temperature controls creativity and randomness

  • Top-p controls how many possible words the AI considers

  • Different parameter settings create different styles of output


What’s Next

At this point, you now understand three foundational ideas behind modern AI:

  • embeddings represent meaning

  • layers transform information

  • weights and parameters shape outputs

This is the core pipeline behind many AI systems.

And once you understand these foundations, AI stops feeling mysterious.

You start seeing it for what it really is:

A very large pattern-learning system built from mathematics, probabilities, and massive amounts of data.