CS I · Thu Nov 5 · 14.4 · Do Now

Code a Model Wrote

Open the discussion form on the right and answer Section 1 from your first reading.

Announcements

Generated Code, Gaps and Assumptions

This section explains how a model writes a program from a short description, and why that program can differ from the one the person had in mind.

How a Model Writes Code

A person can ask a language model for a program in the same way that a person asks it for a paragraph. Generated code is code that a model writes from a description. The model produces it the same way it produces any other text, by predicting a likely next token, adding it, and repeating. In a 2021 paper, researchers at OpenAI described Codex, a language model trained on public code, which wrote programs from short written descriptions of what each program should do. The researchers produced each program by taking tokens from the model one at a time until it reached a stopping point. As the Oct 20 lesson explained, a model that generates an answer does not retrieve a stored copy of it, so each program is new text built from the model's parameters. Code a person typed is not generated code, even when it looks exactly the same as code that a model wrote.

A Request With Gaps

In October 2026, the class's model, Mistral Small, received a request through the class endpoint. A short system prompt told the model to reply with only Java code, in one class named Main. The request below, called request 1, is shown exactly as it was sent.

Write a short Java program that prints a birthday message for my friend. Use only System.out.println.

The model replied with the program below, word for word. It was then compiled and run with the course's copy of Java, and the output under the program is what it printed.

1class Main {
2    public static void main(String[] args) {
3        System.out.println("Happy Birthday, Friend!");
4        System.out.println("Wishing you a day filled with joy and laughter!");
5        System.out.println("May all your dreams come true this year!");
6    }
7}
Happy Birthday, Friend!
Wishing you a day filled with joy and laughter!
May all your dreams come true this year!

The program compiles and runs with no error, but it is still not the program the person pictured, because the request left things out. A gap is a part of a program that the description says nothing about. Request 1 never gave the friend's name, the friend's age or the words of the message. Figure 1 lines up what request 1 says with what the model wrote, row by row, and marks each row as a match or a gap. A detail the request states exactly is not a gap. The words "Use only System.out.println" left nothing to guess about how to print, and every line the model wrote prints with System.out.println.

How a Model Fills a Gap

When a description says nothing about part of a program, the model fills the gap with its own guess. An assumption is that guess, written into the code as if someone had asked for it. In request 1, the model used the placeholder Friend, with a capital F, in the place where a name belonged. It also generated three lines, and every word in them came from the model, including a wish for a day filled with joy and laughter. The program prints no age, and its last line says "this year" instead. An assumption is not a mistake by itself, since a reader might be happy with all three lines, but it becomes a problem when it is not what the person wanted. For example, a friend named Jada would expect to see her own name, so the person would want to change the assumption that she can be called Friend.

Closing the Gaps

The second request, called request 2, filled the gaps in request 1. It gave the friend's name, her age and the exact two lines to print.

Write a short Java program that prints a birthday message for my friend Jada, who is turning 15. Print exactly two lines: "Happy birthday, Jada." and "Fifteen looks good on you." Use only System.out.println.

The model's reply and its real output are below, in the same form as the program for request 1.

1class Main {
2    public static void main(String[] args) {
3        System.out.println("Happy birthday, Jada.");
4        System.out.println("Fifteen looks good on you.");
5    }
6}
Happy birthday, Jada.
Fifteen looks good on you.

This time the model wrote exactly the two lines that the request asked for, and the output matches the request word for word. Where a description is exact, a model usually follows it, although the Codex researchers reported that their model still had trouble with descriptions that listed long chains of steps. Because a model can follow most of a description and still guess at the rest, generated code is read in three steps. First, a person reads the code, and next, the person compiles and runs it. Then the person compares the code and its output with the description, line by line, and marks each line as a match or a gap. The Codex researchers judged their programs in a similar way, by running each one against tests instead of only reading it. A guess that happens to be right is still a guess, so every line the description did not ask for gets checked.

Summary

Generated code is code that a model writes from a description by predicting one token at a time. A gap is a part of a program that the description says nothing about, and the model fills each gap with an assumption, which is its own guess written into the code. Reading the code, running it and comparing it with the description line by line shows which lines match and which ones are assumptions.

Sources: Google, Introduction to Large Language Models (2026); Chen et al., Evaluating Large Language Models Trained on Code (2021); class endpoint, Code Coach classroom data, generated-request1 (2026); class endpoint, Code Coach classroom data, generated-request2 (2026).

I Do questions
  1. notebook cue: generated code

    The program in Figure 1 compiles and runs. Does that mean it is the program the person wanted? Why or why not?

    Check

    No. It compiles and runs, but request 1 left out the friend's name, age and message, so the model guessed at all three, and a guess may not be what the person wanted. See A Request With Gaps, the paragraph after the output.

  2. notebook cue: gap

    Request 1 never said the friend's name. Find what the model put there instead.

    Check

    The model put the placeholder Friend, with a capital F, in the first line it prints. The name was a gap, so the model filled it with its own guess. See How a Model Fills a Gap, and the second row of Figure 1.

  3. notebook cue: assumption

    Name one assumption the model made that the request did not ask for, and write the sentence you would add to the request so that the model does not have to assume it.

    Check

    One assumption is that the program should print three lines in the model's own words. Adding "Print exactly two lines: Happy birthday, Jada. and Fifteen looks good on you." removes that guess, which is what request 2 did. See How a Model Fills a Gap and Closing the Gaps.

Figure 1. Request 1 set against the code the model wrote for it, with one row that matches the request and three gaps the model filled with its own assumptions.
I Do questions
  1. notebook cue: generated code

    The program in Figure 1 compiles and runs. Does that mean it is the program the person wanted? Why or why not?

    Check

    No. It compiles and runs, but request 1 left out the friend's name, age and message, so the model guessed at all three, and a guess may not be what the person wanted. See A Request With Gaps, the paragraph after the output.

  2. notebook cue: gap

    Request 1 never said the friend's name. Find what the model put there instead.

    Check

    The model put the placeholder Friend, with a capital F, in the first line it prints. The name was a gap, so the model filled it with its own guess. See How a Model Fills a Gap, and the second row of Figure 1.

  3. notebook cue: assumption

    Name one assumption the model made that the request did not ask for, and write the sentence you would add to the request so that the model does not have to assume it.

    Check

    One assumption is that the program should print three lines in the model's own words. Adding "Print exactly two lines: Happy birthday, Jada. and Fifteen looks good on you." removes that guess, which is what request 2 did. See How a Model Fills a Gap and Closing the Gaps.

Generated Code, Gaps and Assumptions

This section explains how a model writes a program from a short description, and why that program can differ from the one the person had in mind.

How a Model Writes Code

A person can ask a language model for a program in the same way that a person asks it for a paragraph. Generated code is code that a model writes from a description. The model produces it the same way it produces any other text, by predicting a likely next token, adding it, and repeating. In a 2021 paper, researchers at OpenAI described Codex, a language model trained on public code, which wrote programs from short written descriptions of what each program should do. The researchers produced each program by taking tokens from the model one at a time until it reached a stopping point. As the Oct 20 lesson explained, a model that generates an answer does not retrieve a stored copy of it, so each program is new text built from the model's parameters. Code a person typed is not generated code, even when it looks exactly the same as code that a model wrote.

A Request With Gaps

In October 2026, the class's model, Mistral Small, received a request through the class endpoint. A short system prompt told the model to reply with only Java code, in one class named Main. The request below, called request 1, is shown exactly as it was sent.

Write a short Java program that prints a birthday message for my friend. Use only System.out.println.

The model replied with the program below, word for word. It was then compiled and run with the course's copy of Java, and the output under the program is what it printed.

1class Main {
2    public static void main(String[] args) {
3        System.out.println("Happy Birthday, Friend!");
4        System.out.println("Wishing you a day filled with joy and laughter!");
5        System.out.println("May all your dreams come true this year!");
6    }
7}
Happy Birthday, Friend!
Wishing you a day filled with joy and laughter!
May all your dreams come true this year!

The program compiles and runs with no error, but it is still not the program the person pictured, because the request left things out. A gap is a part of a program that the description says nothing about. Request 1 never gave the friend's name, the friend's age or the words of the message. Figure 1 lines up what request 1 says with what the model wrote, row by row, and marks each row as a match or a gap. A detail the request states exactly is not a gap. The words "Use only System.out.println" left nothing to guess about how to print, and every line the model wrote prints with System.out.println.

How a Model Fills a Gap

When a description says nothing about part of a program, the model fills the gap with its own guess. An assumption is that guess, written into the code as if someone had asked for it. In request 1, the model used the placeholder Friend, with a capital F, in the place where a name belonged. It also generated three lines, and every word in them came from the model, including a wish for a day filled with joy and laughter. The program prints no age, and its last line says "this year" instead. An assumption is not a mistake by itself, since a reader might be happy with all three lines, but it becomes a problem when it is not what the person wanted. For example, a friend named Jada would expect to see her own name, so the person would want to change the assumption that she can be called Friend.

Closing the Gaps

The second request, called request 2, filled the gaps in request 1. It gave the friend's name, her age and the exact two lines to print.

Write a short Java program that prints a birthday message for my friend Jada, who is turning 15. Print exactly two lines: "Happy birthday, Jada." and "Fifteen looks good on you." Use only System.out.println.

The model's reply and its real output are below, in the same form as the program for request 1.

1class Main {
2    public static void main(String[] args) {
3        System.out.println("Happy birthday, Jada.");
4        System.out.println("Fifteen looks good on you.");
5    }
6}
Happy birthday, Jada.
Fifteen looks good on you.

This time the model wrote exactly the two lines that the request asked for, and the output matches the request word for word. Where a description is exact, a model usually follows it, although the Codex researchers reported that their model still had trouble with descriptions that listed long chains of steps. Because a model can follow most of a description and still guess at the rest, generated code is read in three steps. First, a person reads the code, and next, the person compiles and runs it. Then the person compares the code and its output with the description, line by line, and marks each line as a match or a gap. The Codex researchers judged their programs in a similar way, by running each one against tests instead of only reading it. A guess that happens to be right is still a guess, so every line the description did not ask for gets checked.

Summary

Generated code is code that a model writes from a description by predicting one token at a time. A gap is a part of a program that the description says nothing about, and the model fills each gap with an assumption, which is its own guess written into the code. Reading the code, running it and comparing it with the description line by line shows which lines match and which ones are assumptions.

Sources: Google, Introduction to Large Language Models (2026); Chen et al., Evaluating Large Language Models Trained on Code (2021); class endpoint, Code Coach classroom data, generated-request1 (2026); class endpoint, Code Coach classroom data, generated-request2 (2026).

Table Talk
You ask a model, "Write a Java program that prints a birthday message for my friend." What will the model have to guess? Name two things, and say which guess you would most want to fix.

Each table lists everything the model will have to guess, then agrees on one sentence to add to the request so that the biggest guess is no longer needed.

Chromebooks stay closed while your table talks. Sections 1 and 2 of the discussion form are already done. After you talk, finish Section 3 right here under My View. Submit before the exit ticket.

This form has three sections. Section 1: answer today's Board Question. Section 2: after the reading. Section 3 opens later in class. Today's Board Question: You ask a model, "Write a Java program that prints a birthday message for my friend." What will the model have to guess? Name two things, and say which guess you would most want to fix.

CR 1. Board Question: You ask a model, "Write a Java program that prints a birthday message for my friend." What will the model have to guess? Name two things, and say which guess you would most want to fix. Give your answer and one reason.

Write your answer in your lab notebook, labeled CR 1.

MC 1. Think about your answer to the board question. You ask a model, "Write a Java program that prints a birthday message for my friend." What will the model have to guess? Name two things, and say which guess you would most want to fix. Which position is closest to yours now?

  • Nothing. The model will ask for the name before it writes any code.
  • The friend's name and the words of the message, because the request does not say them.
  • Nothing important, because every birthday message says about the same thing.

MC 2. (Reading claim 1) When a description leaves something out, the model leaves that part out of the code.

  • Agree
  • Disagree

MC 3. (Reading claim 2) Code that compiles and runs can still be different from what the person wanted.

  • Agree
  • Disagree

MC 4. (Reading claim 3) The best way to fix a gap is to add the missing detail to the description.

  • Agree
  • Disagree

MC 5. (Reading claim 4) In Figure 1, every line that request 1's program prints uses System.out.println.

  • Agree
  • Disagree

MC 6. (Reading claim 5) The program for request 1 prints the friend's age.

  • Agree
  • Disagree

MC 7. (Reading claim 6) A detail that a request states exactly is a gap.

  • Agree
  • Disagree

MC 8. (Reading claim 7) For request 2, the model wrote exactly the two lines that the request asked for.

  • Agree
  • Disagree

MC 9. (Reading claim 8) In Reading 2, the line System.out.println(count); prints the word count.

  • Agree
  • Disagree

CR 2. (A different view) Write the view at your table that was most different from yours. If everyone agreed, write the strongest argument against your table's answer.

Write your answer in your lab notebook, labeled CR 2.

CR 3. Think about the Board Question again: You ask a model, "Write a Java program that prints a birthday message for my friend." What will the model have to guess? Name two things, and say which guess you would most want to fix. Do you have the same opinion as when you first answered the board question? If it is the same, what from the reading or table talk reaffirmed your opinion? If it is different, what from the reading or table talk changed your opinion?

Write your answer in your lab notebook, labeled CR 3.