Skip to content

app(flowerhub): Add NanoGPT Shakespeare federated learning example#6630

Closed
zzsi wants to merge 7 commits intoflwrlabs:mainfrom
zzsi:app/nanogpt-shakespeare
Closed

app(flowerhub): Add NanoGPT Shakespeare federated learning example#6630
zzsi wants to merge 7 commits intoflwrlabs:mainfrom
zzsi:app/nanogpt-shakespeare

Conversation

@zzsi
Copy link
Copy Markdown

@zzsi zzsi commented Feb 25, 2026

Summary

  • Adds a new FlowerHub example: federated character-level language modeling using NanoGPT (~10.8M params) on the Tiny Shakespeare dataset
  • Supports both Simulation Engine (auto-partitioning) and Deployment Engine (pre-staged train.bin/val.bin data)
  • Uses FedAvg strategy with server-side global evaluation and post-training text generation

Details

The model is a "baby GPT" — small enough to train on CPU. Over 5 rounds with 2 simulated clients (50 steps each), validation perplexity drops from ~69 to ~12.4.

Round Train Loss Val Loss Perplexity
0 4.23 69.0
1 3.26 2.97 19.5
2 2.74 2.64 14.0
3 2.60 2.56 13.0
4 2.53 2.52 12.5
5 2.50 2.52 12.4

Test plan

  • Tested with flwr run . simulation (5 rounds, 2 clients, CPU)
  • Test deployment mode with pre-staged data partitions
  • Verify flwr app publish workflow

Character-level language modeling with a baby GPT (~10.8M params) on
the Tiny Shakespeare dataset. Supports both Simulation Engine and
Deployment Engine modes. Uses FedAvg with server-side evaluation and
text generation after training.
@github-actions github-actions Bot added the Contributor Used to determine what PRs (mainly) come from external contributors. label Feb 25, 2026
yan-gao-GY
yan-gao-GY previously approved these changes Mar 2, 2026
Copy link
Copy Markdown
Member

@yan-gao-GY yan-gao-GY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zzsi Thank you for creating this PR — it looks great! I’ve just made a few minor formatting changes. Please feel free to create a Flower account and publish the app on Flower Hub. Thanks again for you contribution!

@zzsi
Copy link
Copy Markdown
Author

zzsi commented Mar 3, 2026

@yan-gao-GY thanks, will do

@yan-gao-GY
Copy link
Copy Markdown
Member

This app has been published on Flower Hub - https://flower.ai/apps/zzsikungfu/nanogpt-shakespeare/
@zzsi Thanks again for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contributor Used to determine what PRs (mainly) come from external contributors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants