Showing posts with label ChatGPT-memory. Show all posts
Showing posts with label ChatGPT-memory. Show all posts

Friday, September 29, 2023

That Reverse Thing: Chatster is puzzled by “be not or be to” as well.

As you may know, the following paper has been making the rounds in the LLM world: The Reversal Curse: LLMs trained on “A is B” fail to learn “B is A”. Not surprisingly there is a similar effect which is just a matter of word order and has nothing to do with logic. As you may know, I’ve recently been seeing how ChatGPT responds to prompt such as “To be or not to be” and “Four score and seven years ago.” As you would expect, in both cases it returns the whole speech. If you prompt it from other strings in those speeches, well, that’s a complicated and interesting story I report on here: Discursive Competence in ChatGPT, Part 2: Memory for Texts.

I’ve decided to see what happens if I prompted it with those phrases, but in reverse word order. [I did this on 9.29.23 at 4:26 AM – running against the Sept. 25 Version.]

be not or be to

It seems like you're playing with words or phrases. "Be not or be to" doesn't form a standard or coherent sentence in English. If you have a specific question or if there's something specific you'd like to know or discuss, please provide more context, and I'll be happy to help.

ago years seven and score four

It appears you've mentioned the numbers "seven" and "four," but it's not clear what context or information you're seeking. If you have a question or need information related to the numbers "seven" and "four," please provide more details or clarify your request, and I'll do my best to assist you.

Well, OK, you might be thinking that humans would find those prompts a bit weird as well. Yes, I believe so. But I’d like to think that anyone who recognizes the phrases in the correct order would also be able to recognize what’s going on in those prompts. So I decided to give Chatster another try, this time giving it a bit of help:

be not or be to

It seems like you're asking about a choice between two options: "be not" or "be to." However, this phrase is a bit unclear and may not have a standard meaning in English. Can you provide more context or clarify your question so I can assist you better?

I’ve taken words from a famous speech, but not it the correct order.

It sounds like you're referencing a famous speech and have rearranged some of its words. If you provide the specific words or phrases you've rearranged, I can try to help you understand the original context or provide more information based on that. Please share the words or phrases you're working with, and I'll do my best to assist you.

Hamlet

The phrase "To be or not to be" is one of the most famous lines from William Shakespeare's play "Hamlet." It is part of Hamlet's soliloquy in Act 3, Scene 1, where he reflects on the nature of life and death, contemplating whether it is nobler to endure the suffering and challenges of life or to end one's own existence. The full soliloquy goes:

"To be, or not to be, that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles And, by opposing, end them."

It's a reflection on the existential question of whether it's better to face the hardships of life or to choose non-existence. This soliloquy is one of the most famous passages in English literature and is often quoted or referenced in various contexts.

ago years seven and score four

It seems like you're providing a phrase without a specific question or context. If you have a question or need information related to "seven years ago" or "four scores," please provide more details or clarify your request, and I'd be happy to help.

I’ve taken words from a famous speech, but not it the correct order.

It appears that you've taken words from a famous speech and rearranged them. Without knowing the original speech or having more context, it's challenging to determine the source or provide additional information. If you could provide more details or the actual quote, I'd be happy to assist you further.

Lincoln

The phrase "four score and seven years ago" is the opening of Abraham Lincoln's Gettysburg Address, one of the most famous speeches in American history. The full sentence is:

"Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal."

Lincoln delivered this speech on November 19, 1863, during the American Civil War, at the dedication of the Soldiers' National Cemetery in Gettysburg, Pennsylvania. It's a brief but powerful speech that emphasized the principles of liberty, equality, and the importance of preserving the Union during a critical period in American history.

I wonder what would have happened if I’d gone straight to “Hamlet” and “Lincoln” without the famous speech prompt in there? I suppose I’ll have to find out, later. The interesting thing is that, when I gave Chatster the appropriate name, it was able to figure out what was going on.

I’m beginning to see get ever so faint impressions of the gears turning inside the old Chatster.

Wednesday, September 27, 2023

Discursive Competence in ChatGPT, Part 2: Memory for Texts

I've finished a new working paper. Title above, links, abstract, table of contents, and introduction below.

Academia.edu: https://www.academia.edu/107318793/Discursive_Competence_in_ChatGPT_Part_2_Memory_for_Texts
SSRN: https://ssrn.com/abstract=4585825
ResearchGate: https://www.researchgate.net/publication/374229644_Discursive_Competence_in_ChatGPT_Part_2_Memory_for_Texts_2_Memory_for_Texts

Abstract: In a few cases ChatGPT responds to a prompt (e.g. “To be or not to be”) by returning a specific text word-for-word. More often (e.g. “Johnstown flood, 1889”) it returns with information, but the specific wording will vary from one occasion to the next. In some cases (e.g. “Miriam Yevick”) it doesn’t return anything, though the topic was (most likely) in the training corpus. When the prompt is the beginning of a line or a sentence in a famous text, ChatGPT always identifies the text. When the prompt is a phrase that is syntactically coherent, ChatGPT generally identifies the text, but may not properly locate the phrase within the text. When the prompt cuts across syntactic boundaries, ChatGPT almost never identifies the text. But when told it is from a “well-known speech” it is able to do so. ChatGPT’s response to these prompts is similar to associative memory in humans, possibly on a holographic model.

Contents

Introduction: What is memory? 2
What must be the case that ChatGPT would have memorized “To be or not to be”? – Three kinds of conceptual objects for LLMs 4
To be or not: Snippets from a soliloquy 16
Entry points into the memory stream: Lincoln’s Gettysburg Address 26
Notes on ChatGPT’s “memory” for strings and for events 36
Appendix: Table of prompts for soliloquy and Gettysburg Address 43   

Introduction: What is memory?

In various discussions about large language models (LLMs), such as the one powering ChatGPT, I have seen assertions that such as, “oh, it’s just memorized that.” What does that mean, “to memorize?”

I am a fairly talented and skilled musician. I can and have memorized a piece of music by practicing it over and over. There are the notes on the page. I start playing them until I am comfortable. Then I look away and see how far I can go. When I get lost, I look at the music, continue playing the notes on the page, and finish the piece – something like that. Then I start over from the beginning, again without the music. When I can play the whole piece without having to consult the written music, I have it memorized. At least for the moment.

But I don’t do that very often. More likely, I’ll hear a tune I like two, three, or five times and then I pick up my trumpet and playing, sometimes perfectly, sometimes with a glitch or two. I didn’t memorize it, and yet I’m playing it. From memory? No, by ear?

I’m speaking metaphorically of course. What does it mean to play by ear? I don’t really know, but I imagine it goes something like this: Music has an inner logic, a grammar, a set of rules through which it is structured. When I hear a tune I’m listening to it in term of that inner logic, as, for that matter, anyone is – at least if they’re familiar with the musical idiom. It’s that logic that I’m registering as I listen to the tune. Once I’ve heard the tune a couple of times, I’ve “absorbed” that logic, without even thinking about it or working on it. It just happens as a side-effect of (ordinary) listening. When the absorption is complete, I am able to play the tune “by ear.”

Those are two very different processes, absorbing a tune through listening vs. repeating it over and over until you have it “memorized.” Which, if either, or those two is an LLM doing when it is chewing its way through a corpus of texts? When I prompt ChatGPT with “To be or not to be,” it responds with Hamlet’s complete soliloquy, word-for-word. When it does that is the process more like what I do when playing music by ear or like I do when memorizing music? Or is it something else?

That’s the kind of issue I had in mind when I undertook the investigations I report in this working paper. In the first piece – What must be the case that ChatGPT would have memorized “To be or not to be”? – I start out with Hamlet’s famous soliloquy, initially prompting ChatGPT with first line, but then prompting it with other fragments from the soliloquy. Then I prompt it with the phrase, “Johnstown flood, 1889,” and it responds with information about that flood, by not a specific text word-for-word. Many prompts are like that, many more than elicit a specific text word-for-word. What leads to that difference? I conclude with two topics I have reason to believe were included in the training corpus, but which ChatGPT seems to know nothing about. Why not?

In the next section (To be or not: Snippets from a soliloquy) I create various prompts for the soliloquy. I do the same in the third section (Entry points into the memory stream: Lincoln’s Gettysburg Address), but more systematically. Finally, I do a bit of speculating about what’s going on: Notes on ChatGPT’s “memory” for strings and for events. I begin by quoting a passage from F. C, Bartlett’s classic 1932 study, Remembering, and conclude that ChatGPT may have an associative memory along the lines suggested by holography, which engendered a great deal of speculation in the 1970s and, in this millennum, specifically for word meaning and order.

Wednesday, September 20, 2023

Notes on ChatGPT’s “memory” for strings and for events

[Updated on Sept. 21 and 26, 2023]

Here I take a look at the results reported in three previous posts and begin the job of making sense of them analytically. Here are the posts:

What must be the case that ChatGPT would have memorized “To be or not to be”? – Three kinds of conceptual objects for LLMs, New Savanna, September 3, 2023.

To be or not: Snippets from a soliloquy, New Savanna, September 12, 2023.

Entry points into the memory stream: Lincoln’s Gettysburg Address, New Savanna, September 13, 2023.

I set the stage with a passage from F. C. Bartlett’s 1932 classic, Remembering. Then I consider the three cases I laid out in that first post and then go on to look at the results reported in the next two. I conclude by suggesting that we look to the psychological literature on memory and recall to begin making analytic sense of these results. Of course, we also need more observations.

F.C. Bartlett, memory, and schemas

Back in the ancient days of 1932 F. C. Bartlett published a classic study of human recall, Remembering: A Study in Experimental and Social Psychology (1932). He performed a variety of experiments, a number involving the familiar game of having people tell a story from person to person to a chain and then comparing the initial story with the final one. He made the general conclusion that memory is not passive, like a tape-recorder or a camera, but rather is active, involving schemas (I believe he may have been the one to introduce that term to psychology), which shape our recall. A story that corresponds to an existing schema will be more faithfully transmitted than one that does not.

However, I’m not interested in those experiments. I’m interested in something he reports in a later chapter, “Social Psychology and the Manner of Recall,” pp. 264-266:

As everybody knows, the examination by Europeans of a native witness in a court of law, among a relatively primitive people, is often a matter of much difficulty. The commonest alleged reason is that the essential differences between the sophisticated and the unsophisticated modes of recall set a great strain on the patience of any European official. It is interesting to consider an actual record, very much abbreviated, of a Swazi trial at law. A native was being examined for the attempted murder of a woman, and the woman herself was called as a necessary witness. The case proceeded in this way:

The Magistrate: Now tell me how you got that knock on the head.

The Woman: Well, I got up that morning at daybreak and I did... (here followed a long list of things done, and of people met, and things said). Then we went to so and so’s kraal and we... (further lists here) and had some beer, and so and so said....

The Magistrate: Never mind about that. I don’t want to know anything except how you got the knock on the head.

The Woman: All right, all right. I am coming to that. I have not got there yet. And so I said to so and so... (there followed again a great deal of conversational and other detail). And then after that we went on to so and so’s kraal.

The Magistrate: You look here; if we go on like this we shall take all day. What about that knock on the head?

The Woman: Yes; all right, all right. But I have not got there yet. So we... (on and on for a very long time relating all the initial details of the day). And then we went on to so and so’s kraal.. .and there was a dispute ... and he knocked me on the head, and I died, and that is all I know.

Practically all white administrators in undeveloped regions agree that this sort of procedure is typical of the native witness in regard to many questions of daily behaviour. Forcibly to interrupt a chain of apparently irrelevant detail is fatal. Either it pushes the witness into a state of sulky silence, or disconcerts him to the extent that he can hardly tell his story at all. Indeed, not the African native alone, but a member of any slightly educated community is likely to tell in this way a story which he has to try to recall.

What’s going on here? Keep in mind that the issue is not word-for-word recall. Rather, it is the incidents being recalled, in whatever verbal form is convenient. Why can’t the witness simply begin talking about the incident in question? And when, when asked to get on with it, must the witness return to be beginning of the day?

It's as though the memory stream of a day’s events can only be entered at the beginning of the day, and not at arbitrary points within the day. I note that we are dealing with people who do not have clocks and watches they can use to mark events during the day. Of course it’s not enough to have a watch, you must also take note of it at various times during the day. That will give you various points of entry into the memory stream.

This sort of thing is also quite familiar to me as a musician. While I have learned to read music, and have done so often, I am an improvising (jazz) musician and am quite used to playing things “by ear.” If I am practicing a melody by ear, and get lost at some point, I may not be able to restart at the point where I broke off. Rather, like the witness testifying in court, I have to go back to the beginning – in this case, the beginning of the melody rather than the beginning of the day.

To be or not, and beyond

Early in September I asked the question: “Given that [the LLM underlying ChaGPT] has been trained to predict [only] the next word, what MUST have been the case in order to ChatGPT to return the whole soliloquy when given the opening six words?” It must have encountered that soliloquy many different times in its training corpus. That’s the only way that predicting that exact sequence, word after word, not result in training loss.

However, given Bartlett’s observations about human memory, ChatGPT’s ability to rattle off a whole sequence word for word does raise a question. Is it just passively stringing one word after another, or does it recognize internal structure? How can we figure out which is the case?

I want to set those questions aside for a moment, but I will return to the question. Though interesting, such specific sequences are relatively rare. It is much more common for the training corpus to have many texts about the same event or set of events, but not expressed in the exact same words. Thus I have ChatGPT the prompt, “Johnstown flood, 1889.” Note that I specified the year because Johnstown (PA) was subsequently flooded in 1937 and 1977. But it’s the 1889 flood that made the national news, prompting national concern.

ChatGPT responded in a way I thought reasonable. Since I had grown up in Johnstown and was familiar with the flood, I didn’t bother to check the Chatster’s reply against reliable sources. But, for all I know, the Chatster was giving me some specific text word-for-word, implying that there was some specific text about the flood that had appeared many times in the training corpus. While that didn’t seem likely, I had to check. Later that same day I opened a new session and gave ChatGPT the same prompt. Again, it gave me a reasonable reply, but one that was expressed differently from the earlier one. This reply gave the sequence of events in seven numbered paragraphs. The earlier reply did not have a sequence of numbered paragraphs.

So we’ve got two cases so far: 1) a specific sequence of words that is repeated when prompted for, and 2) and flexible recall of an event using different word sequences in different sessions. There is a third case to consider: 3) and event that is in the training corpus, but in so very few times, perhaps only once, that it doesn’t register in ChatGPT’s model as a specific event. The text serves as evidence about word usage, but otherwise has no effect on the model.

Without access to the training corpus, how do you identify such things? You can’t. But you can make a plausible. I’d attended a Dizzy Gillespie concert back in the mid-1980s which I’d written about in two places which could have been in the training corpus. I prompted ChatGPT with that concert, naming the venue and city where the concert took place in addition to the artist (Diz). Apparently, it had no record of it.

Let me offer you a somewhat different example of this last case. I’m currently interested in a mathematician named Miriam Lipschutz Yevick. She published a paper back in 1975 (Holographic or fourier logic), which I think is interesting and important, but which has been forgotten. The paper is available on the web, and I have blogged about it. A few other papers are also available, as well as an obituary, all before ChatGPT’s cut-off point. I’ve asked Chatster about Yevick in several different sessions but it knows nothing about her. 

Let’s think about this a bit. GPT-3.5, the large language model underlying ChatGPT, may have been trained on (almost, a big chunk of) the entire internet, but its model does not incorporate everything that it has been trained on. It is abstracting over those texts, not memorizing them in any ordinary sense of the word. When a particular text occurs word-for-word many times and in various contexts, GPT-3.5 will learn it word-for-word; think of that as, in effect, an abstraction over those many contexts. When a particular topic, that is, a particular congeries of terms, occurs many times and in various contexts, GPT-3.5 abstracts over than congeries and meshes them together so they are mutually available. If neither of these things occurs to something that appears in a text, then that something just dissolves into the net.

Thus we’ve got three cases: 1) word-for-word recall of a text, 2) flexible recall of a specific topic, and 3) no recall of a topic that was in its training corpus. I want to return to the first case, where ChatGPT is generating a fixed text, and see what, if anything, we can learn about how it does it.

Wednesday, September 13, 2023

Entry points into the memory stream: Lincoln’s Gettysburg Address

I’m continuing the investigation I began in To be or not: Snippets from a soliloquy, and What must be the case that ChatGPT would have memorized “To be or not to be”? This time I used Lincoln’s “Gettysburg Address” as my source text. First I verified that ChagGPT knew it, which it did. Then I have it twelve prompts:

  • Sentence initial prompts: Four from the beginning of a line,
  • Syntactically consonant prompts: Four from the interior of a line, but that respect syntactic boundaries, and
  • Syntactically unruly prompts: Four that ran across syntactic boundaries.

ChatGPT correctly identified the “Gettysburg Address” as the source of all of the prompts in the first category. But it mislocated two of them, asserting that they were from the opening line, when they were not.

Its response to the second category was peculiar. It got one correct and missed one. In the other two cases, it identified the “Gettysburg Address” as the source. But when it identified the context, that segment didn’t include the prompt. In both of those cases the segment was from the end of the text.

It was unable to identify any of the last four prompts with the “Gettysburg Address.” However, in the last three cases I thought to offer a further prompt, that the passage was “a very well-known speech.” That rather weak prompt was enough to send it to “Gettysburg Address.” In the case of the second prompt, ChatGPT provided context that did not contain the prompt. In the case of the third prompt, while the quoted context did contain the prompt, that quoted text was half the speech. In the last case (“in vain—that this”), ChatGPT offered a context that contained the last part of the prompt (“that this”), but not the first.

Thus for ChatGPT it is one thing to know that a text fragment comes from a specific larger text, it is something else to be able to pinpoint just where it is located in the larger text. Mislocation is a problem. Moreover, its ability to determine what text a fragment is from – assuming it is from a well-known text – depends on exactly where in the text it is from.

Identification is very liable if the fragment comes from the beginning of a sentence and not at all reliable if it is from within a sentence and does not respect syntactic boundaries. Identification is fairly reliable for prompts from within sentence but that follow syntactactic boundaries. Obviously, more work needs to be done.

I opened a new session for each prompt. I have highlighted line initial prompts in yellow, syntactically consonant strings in aqua, and unruly strings in green. I have interpolated some comments in italics along the right margin.

* * * * *

The full address

Do you recognize this?

"Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

[Note: “Liberty” appears in two different prompts.]

Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.

But, in a larger sense, we can not dedicate—we can not consecrate—we can not hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom—and that government of the people, by the people, for the people, shall not perish from the earth."

Yes, I recognize this passage. It is the opening of Abraham Lincoln's Gettysburg Address, which he delivered on November 19, 1863, during the American Civil War at the dedication of the Soldiers' National Cemetery in Gettysburg, Pennsylvania. The speech is one of the most famous in American history and is often cited for its eloquent expression of the principles of liberty, equality, and democracy.

Sentence initial prompts

Four score and seven years ago

These famous words, "Four score and seven years ago," are the opening phrase of Abraham Lincoln's Gettysburg Address. Lincoln delivered this historic speech on November 19, 1863, during the American Civil War, at the dedication of the Soldiers' National Cemetery in Gettysburg, Pennsylvania. In the address, he reflected on the significance of the Civil War, the principles of liberty and equality, and the need to ensure that the United States would have a government "of the people, by the people, for the people."

"Four score and seven years ago" means 87 years ago, as a "score" represents 20 years. So, Lincoln was referring to the founding of the United States in 1776, 87 years before his address in 1863. This speech is one of the most famous and enduring speeches in American history, emphasizing the values of freedom, democracy, and the importance of preserving the Union during a time of great national crisis.

Now we are engaged in a great civil war

The phrase "Now we are engaged in a great civil war" is the opening line of Abraham Lincoln's Gettysburg Address, which he delivered on November 19, 1863, during the American Civil War. The speech was given at the dedication of the Soldiers' National Cemetery in Gettysburg, Pennsylvania, following the Battle of Gettysburg, one of the bloodiest battles of the war.

In his address, President Lincoln reflected on the significance of the Civil War, which was a struggle to preserve the Union and to ensure that "government of the people, by the people, for the people, shall not perish from the earth." He emphasized the importance of honoring and remembering the sacrifices made by the soldiers who had fought and died on the battlefield.

The Gettysburg Address is one of the most famous speeches in American history and is often cited for its eloquence and its profound message about the principles of democracy and the enduring importance of freedom and equality.

[Note: The prompt is from the second line, not the first.]

But, in a larger sense, we can not dedicate

Nor consecrate, nor hallow this ground. The brave men, living and dead, who struggled here, have consecrated it far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom—and that government of the people, by the people, for the people, shall not perish from the earth.

These words are from Abraham Lincoln's Gettysburg Address, delivered on November 19, 1863, during the American Civil War. It is one of the most famous speeches in American history and is often cited for its eloquence and the profound ideas it conveys about the principles of democracy and the sacrifice of those who fought for freedom.

It is for us the living

"It is for us the living" is the opening phrase of Abraham Lincoln's Gettysburg Address, delivered on November 19, 1863, during the American Civil War. The full sentence is:

"It is for us the living to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced."

In this address, President Lincoln spoke at the dedication of the Soldiers' National Cemetery in Gettysburg, Pennsylvania, and he emphasized the importance of preserving the Union and the principles of liberty and equality for which the soldiers who fought in the Civil War had given their lives. The speech is considered one of the most eloquent expressions of American values and the principles of democracy.

[Note: The prompt is the middle of the third paragraph. It is not the opening phrase of the address.]

Tuesday, September 12, 2023

To be or not: Snippets from a soliloquy

A week ago I uploaded a post with an ungainly title, What must be the case that ChatGPT would have memorized “To be or not to be”? – Three kinds of conceptual objects for LLMs. This is a follow-up to one set of examples from that post.

I gave ChatGPT a simple prompt, “To be or not to be.” It responded with the whole soliloquy, as I expected. Then I prompted it with two phrases from within the soliloquy, “The insolence of office”, “The slings and arrows.” In each case it identified them as coming from that famous soliloquy. Each of those prompts came from the beginning of a line. What if I prompted it with a string from within a line? I chose this string, “and sweat under a,” which is from this line: “To grunt and sweat under a weary life.” It failed to identify the string with the soliloquy.

Interesting, very interesting. That makes sense. I need to look into this a bit more.

And so I have.

I’ve now prompted ChatGPT with thirteen (13) snippets (I won’t call them phrases becasuse, technically, many of them are not phrases, just strings of words), four (4) from line beginnings, and nine (9) from somewhere in the interior of a line. It correctly located all of line-initial snippets, through responded to them in various ways. It only identified two (2) correctly. In one of those cases, the snippet in question, “what dreams may come,” has a use outside the play, which ChatGPT points out.

It responded in various ways to the snippets it was unable to identify, in some cases offering fairly elaborate intrepretive commentary. In the two cases where it correctly located the snippet it also quoted enough of the soliloquy to establish context.

And then there’s the peculiar case of this prompt: “make cowards of us all.” It is from one of the best-known lines in the play, one often quoted on its own: “Thus conscience does make cowards of us all.” I expected the Chatster to identify it. But it did not. So I decided to help it a bit.

I opened a new session and prompted it with: “does make cowards of us all.” The addition of that one word, “does” was all the Chatster needed. It quoted most of the soliloquy in response.

On the whole, I find this is satisfying. For what it’s worth, the fact that ChatGPT would be able to identify snippets from the beginning of a line, but not snippets from the interior, accords well with my intuitions about human psychology. I am an experienced musician – yes, a different medium, but one where serial order is important – and line beginnings are privileged loci. If, during practice or rehearsal, you are going to go over something again, perhaps several times, you’re likely to start at the beginning of a line, not the interior. The same is true when playing a tune “from memory.” You can’t start at any point in the sequence of notes. You have to start at an “access point.” If you know the tune well, it may have several access points for you, generally at a structural boundary. If not, you may only be able to access the tune from the beginning. 

We know that in humans memory is not a passive process, like making a tape recording. It is an active process. It has as structure. That seems to be the case for ChatGPT as well. What mechanisms in the model allow it to do this?

I’ve appended a complete record of these observations. Note that I started a new session for each prompt. I was running againts the August 3 version of ChatGPT. My prompts are bold.

* * * * *

Whether ‘tis nobler

To be or not to be,
That is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles
And, by opposing, end them.

To die: to sleep;
No more; and by a sleep to say we end
The heart-ache and the thousand natural shocks
That flesh is heir to, 'tis a consummation
Devoutly to be wish'd. To die, to sleep;
To sleep: perchance to dream: ay, there's the rub;
For in that sleep of death what dreams may come
When we have shuffled off this mortal coil,
Must give us pause: there's the respect
That makes calamity of so long life;
For who would bear the whips and scorns of time,
The oppressor's wrong, the proud man's contumely,
The pangs of despised love, the law's delay,
The insolence of office and the spurns
That patient merit of the unworthy takes,
When he himself might his quietus make
With a bare bodkin? who would fardels bear,
To grunt and sweat under a weary life,
But that the dread of something after death,
The undiscovered country from whose bourn
No traveller returns, puzzles the will
And makes us rather bear those ills we have
Than fly to others that we know not of?
Thus conscience does make cowards of us all;
And thus the native hue of resolution
Is sicklied o'er with the pale cast of thought,
And enterprises of great pitch and moment
With this regard their currents turn awry,
And lose the name of action.

Soft you now!
The fair Ophelia! Nymph, in thy orisons
Be all my sins remember'd.

Or to take arms

The phrase "or to take arms" is part of a famous line from William Shakespeare's play "Hamlet." The full line is "To be or not to be, that is the question: Whether 'tis nobler in the mind to suffer the slings and arrows of outrageous fortune, or to take arms against a sea of troubles, and by opposing end them."

In this soliloquy, Hamlet is contemplating the nature of existence and the idea of whether it is better to endure the suffering and hardships of life or to take action and confront those challenges head-on, even if it means facing adversity. The phrase "or to take arms" suggests the idea of actively fighting against one's troubles and problems.

It's a powerful and philosophical passage that reflects on the human condition and the choices we face in dealing with life's difficulties.

No more: and by a sleep

I see you've quoted a line from Shakespeare's play "Hamlet." The full line is:

"To die, to sleep—
No more—and by a sleep to say we end
The heart-ache and the thousand natural shocks
That flesh is heir to—’tis a consummation
Devoutly to be wish’d."

This soliloquy is spoken by Prince Hamlet and reflects his contemplation of death and the idea that death may bring relief from life's suffering. If you have any questions or if there's something specific you'd like to discuss related to this quote, please feel free to ask.

That flesh is heir to

The phrase "That flesh is heir to" is the beginning of a famous line from William Shakespeare's play "Hamlet." The full line is:

"That flesh is heir to all — but all shall die."

In this line, Hamlet reflects on the inevitability of death and the mortality of human beings. He acknowledges that all living things, represented by the word "flesh," are destined to die eventually. This theme of mortality and the human condition is a central one in the play and is explored throughout Hamlet's soliloquies and interactions with other characters.

Sunday, September 3, 2023

What must be the case that ChatGPT would have memorized “To be or not to be”? – Three kinds of conceptual objects for LLMs

I’ve been thinking about ChatGPT again, about what goes on under the hood. What would happen I prompted it with a famous phrase from Shakespeare? Would it return the whole passage?

While I am interested in that question, that’s not only thing I’m interested in. There are topics which show up in responses to prompts but not in the form of fixed texts. Finally, there are likely topics that exist in the training corpus, but don’t show up in response to prompts. THAT’s what this post is about, the differences between those kind of objects.

Fixed strings – Hamlet’s soliloquy

It’s easy enough to try. I did so on July 31, running against the July 20 version.

To be or not to be

"To be or not to be" is one of the most famous lines from William Shakespeare's play "Hamlet." It appears in Act III, Scene 1, where Prince Hamlet is contemplating the nature of existence and the idea of suicide.

The full quote is as follows:

"To be, or not to be, that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing, end them? To die: to sleep;
No more; and by a sleep to say we end
The heartache and the thousand natural shocks
That flesh is heir to; 'tis a consummation
Devoutly to be wished. To die, to sleep;
To sleep, perchance to dream—ay, there's the rub:
For in that sleep of death, what dreams may come,
When we have shuffled off this mortal coil,
Must give us pause—there's the respect
That makes calamity of so long life:
For who would bear the whips and scorns of time,
Th'oppressor's wrong, the proud man's contumely,
The pangs of despised love, the law’s delay,
The insolence of office, and the spurns
That patient merit of th'unworthy takes,
When he himself might his quietus make
With a bare bodkin? Who would fardels bear,
To grunt and sweat under a weary life,
But that the dread of something after death,
The undiscovered country from whose bourn
No traveler returns, puzzles the will,
And makes us rather bear those ills we have,
Than fly to others that we know not of?
Thus conscience does make cowards of us all,
And thus the native hue of resolution
Is sicklied o'er with the pale cast of thought,
And enterprises of great pith and moment,
With this regard their currents turn awry,
And lose the name of action. Soft you now,
The fair Ophelia! Nymph, in thy orisons
Be all my sins remembered."

In this soliloquy, Hamlet is contemplating the nature of life, death, and the fear of the unknown. He ponders whether it is nobler to endure the hardships and challenges of life or to take his own life and end the suffering. Throughout the play, Hamlet grapples with existential questions and struggles with his emotions, making "To be or not to be" one of the most memorable and profound passages in literature.

Except for the opening and closing material, that’s pretty much what I expected to happen. But why? Given that the underlying LLM has been trained to predict the next word, what MUST have been the case in order to ChatGPT to return the whole soliloquy when given the opening six words?

It must have encountered that soliloquy many times during its training. Shakespeare’s Hamlet is a well-known play and it must have existed at many places in the training corpus. Moreover the soliloquy itself is famous probably occurred many times independently of the whole play.

What would happen if I gave it a phrase from somewhere in the soliloquy? Let’s find out. From 12 minutes ago, running against the August 4 version. This is of course a new session; there is no prior context it is working from:

The insolence of office

The phrase "the insolence of office" is a line from William Shakespeare's play "Hamlet." It appears in Act 3, Scene 1, during a soliloquy by the character Hamlet. The full line is:

"To be, or not to be, that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing, end them? To die: to sleep;
No more; and by a sleep to say we end
The heartache and the thousand natural shocks
That flesh is heir to; 'tis a consummation
Devoutly to be wished. To die, to sleep;
To sleep, perchance to dream—ay, there's the rub:
For in that sleep of death, what dreams may come,
When we have shuffled off this mortal coil,
Must give us pause—there's the respect
That makes calamity of so long life:
For who would bear the whips and scorns of time,
Th'oppressor's wrong, the proud man's contumely,
The pangs of despised love, the law’s delay,
The insolence of office, and the spurns
That patient merit of th'unworthy takes,
When he himself might his quietus make
With a bare bodkin? Who would fardels bear,
To grunt and sweat under a weary life,
But that the dread of something after death,
The undiscovered country from whose bourn
No traveler returns, puzzles the will,
And makes us rather bear those ills we have,
Than fly to others that we know not of?
Thus conscience does make cowards of us all,
And thus the native hue of resolution
Is sicklied o'er with the pale cast of thought,
And enterprises of great pith and moment,
With this regard their currents turn awry,
And lose the name of action.

In this famous soliloquy, Hamlet is contemplating the nature of existence, the pain and suffering that people endure in life, and the fear of the unknown in death. The specific line you mentioned, "The insolence of office," refers to the abuses of power and authority that people in positions of power may engage in, which can be a source of suffering and frustration for those subjected to it. It's just one part of Hamlet's larger meditation on the human condition and the difficult choices we face in life.

I wasn’t sure that would happen, but I’m not very surprised that it did. Note, though, that whereas it gave 35 lines the previous time, it only gave 33 lines this time, omitting: “Soft you now,/ The fair Ophelia! Nymph, in thy orisons/ Be all my sins remembered.” Not surprisingly, the final gloss was a bit different as it decided to explicate the line I’d given it as a prompt.