Simple Transformer example

Small examples in C that demonstrate C language principles and how to use the standard libraries.
Post Reply
yossik32
Posts: 70
Joined: Fri Jan 30, 2026 1:40 pm
Contact:

Simple Transformer example

Post by yossik32 »

Tiny Transformer-Style Attention Example

What this example teaches :

This tiny demo shows the core transformer idea:

1. Each earlier word has a key

This helps decide whether the word is important.

2. Each earlier word also has a value

This carries useful meaning.

3. The current position creates a query

This asks:

“Which earlier word matters most right now?”

4. Attention weights are computed

The model gives more weight to the useful token.

5. The weighted information is combined

That combined result helps make a prediction.
Attachments
simple_transformer.zip
(760 Bytes) Downloaded 1 time
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest