main function
void
main()
Implementation
void main() {
print("--- MuZero-GPT: 'Quick Brown Fox' Stability Build ---");
final Map<String, int> stoi = {
"hello": 0,
"world": 1,
"the": 2,
"quick": 3,
"brown": 4,
"fox": 5,
".": 6,
"<start>": 7,
"jumps": 8,
"over": 9,
"lazy": 10,
"dog": 11,
};
final Map<int, String> itos = stoi.map((k, v) => MapEntry(v, k));
final model = TransformerDecoder(
vocabSize: 32,
embedSize: 64,
encoderEmbedSize: 64,
blockSize: 16,
numLayers: 2,
numHeads: 4,
);
// lmHead bias zeroing to prevent index-collapse
// model.lmHead.zeroBias();
final agent = MuZeroGreedyAgent(model, 64);
final List<int> trainingData = [
stoi["<start>"]!,
stoi["the"]!,
stoi["quick"]!,
stoi["brown"]!,
stoi["fox"]!,
stoi["jumps"]!,
stoi["over"]!,
stoi["the"]!,
stoi["lazy"]!,
stoi["dog"]!,
stoi["."]!,
];
// 1000 Epochs for deep convergence
trainMuZero(agent, trainingData, 1000, stoi);
print("\n--- Running Pure Dynamics Generation ---");
generateMuZeroPure(agent, [stoi["<start>"]!], 12, itos, stoi);
}