Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse indexing: generating a book from its index #33

Open
jeffbinder opened this issue Nov 18, 2022 · 4 comments
Open

Reverse indexing: generating a book from its index #33

jeffbinder opened this issue Nov 18, 2022 · 4 comments

Comments

@jeffbinder
Copy link

My plan is to train a language model to generate the pages of a book based on the corresponding entries in the index. I will write a new index, and the machine will generate the book.

@jeffbinder
Copy link
Author

I've already managed to get a finetuned gpt2-xl to do this passably well, although I still need to fiddle with the formatting a bit. The bulk of the work will go into writing the actual index.

I'm trying to add more of my own creativity into the process than I have in past years. This time, I don't want to keep on remixing old books (like I did with Moby-Dick in 2020)—I want to have the machine manipulate material I put together myself.

@jeffbinder
Copy link
Author

As an initial experiment, I finetuned the model on the index from Adam Smith's The Wealth of Nations. I then used it to reconstruct the text from the index. I'm doing text generation using PromptArray, a system I'm working on for controlling text generators. These are the results.

Next I'm planning to put together a new index to a book that doesn't exist, then have the model generate the book. Since I only finetuned on a single book, the model tends to write like Adam Smith by default, but I can get it to produce more novelistic text (albeit text that resembles an eighteenth-century novel) by using the "as opposed to" operator from PromptArray to discourage text associated with "Economics and manufactures."

Code here.

@jeffbinder
Copy link
Author

An initial version of the generated novel (around 55,000 words) is here; you can also view the human-written index from which it was generated. It's a based on, and also about, the tropes of hero's journey narratives, and it's meant to blur the lines between fiction and literary criticism. I explain a bit about my intentions in the README.

I'm still not totally satisfied with the quality, so I will be continuing to experiment.

@jeffbinder
Copy link
Author

Close to the buzzer, I've completed version 2 of The Journey of Tom Hero, which I consider my official entry. It is 55,267 words according to the Linux wc command.

The results follow the index more closely, but are overall less coherent than the first version. There are a lot of anomalies like unexpected section headings, changes in tone, broken sentences, and mangled words. I could have improved the quality if there were more time, but I kind of like the cut-up character of this version, which befits a novel that is also literary criticism about itself.

I won't lie and say I've really "read" the whole thing all the way through, but I did skim enough to pick out some choice passages.

pp. 27-28:

Hero fights and defeats the same or a different individual called the "Bridge Troll." The principal difference between the two characters is that the "Bridge Troll" is represented as human, and, on the contrary, as a beast. The author, Mr Thorn, has been accused of introducing the Bridge Troll character, though he never mentions him, from any regard to humour, into his novel, from which the object of his satire is the absurdities of popular superstition. The character of the "Bridge Troll" is, in every respect equal, or nearly equally, to that of a real Troll, which is said sometimes to inhabit the neighbourhood of the bridge.

This Story begins thus: "In a remote and mountainous part of Scotland there lived a man of some note, who had no son or daughter, but was the father of a very handsome and accomplished son. His name was Tom Hero. His father died in a foreign country; and, in his grief and grief, he left him a considerable fortune, in trust for his education, and for his education only, in consequence of the public esteem in which his father had been held. In a distant and mountainous country, in the Highlands of Scotland, the Bridge-Troll lived."

The object of this novella is the ridicule and denunciation, not of superstitious fools, who were afraid of the water, and who could scarce venture to walk over a loose stone, but of the ridiculous notions of weak people, who could scarce venture to walk over any solid rock. Troll Bridge Heroes are always fought and defeated by Tom Hero himself; men who had never before been accustomed to stand up to any man in a wrestling-match, and to use all their strength and agility to defend themselves from the violence and violence of an enraged, furious, and well armed beast. Bridge trolls are always, too (for the honour and safety of the travellers is always his principal concern), wrestled with, and sometimes wrestling-boxes are used in the same manner. The fight of Tom Hero was with a monster, who, as soon as he saw him coming towards it, would have been glad to have been the first man to give him any hurt. He could not have been more perfectly prepared for the contest than he had been before.

pp. 40-41:

The machine learns, or computeth by arithmetic only, the Propositions which geometry and logic resolve into the Propositions of equal and opposite proportions; or, in plain and intelligible words, it learns to compute those Propositions, as nearly, if possible in the same proportion, as the human understanding comprehends them.

It then sends Tom across the Void, over the Haunted, through a desert of burning rocks, over a desert of burning water, through a desert of water, over a desert, and into a desert of fire. The reader finds it hard to believe, but believe me, when I tell you that this passage has all been computed by the machine. It is computed by the same arithmetic which computed all the rest of his adventure.

pp. 74-75:

The pursuit, which is begun in a white-curl Desert, ends in a white-curtained palace. In both cases, the hero finds that the chief or chief's son, whom he has just defeated in the desert, is not there to oppose him. The conquest is followed by a hunt; and in the course both of the conquest, and in the pursuit, of both adventures, we are continually exposed to allusions to heroes in quest of trophies. In the course both, too (the conquest and the chase), too, of both exploits, the monomyth is constantly being adapted. Collins Hero himself is constantly giving us hints and foreshadowing, in his adventures, allusions to heroes in quest for glory, to chivalry, and to the monomith; and allusions to these three different novells constitute the principal part of his narrative, and are the original foundation, both of his characters, and, more especially, his adventures.

Han Solo, too (for Collins Hero represents him as the equal of Tom Hero), first appears as an Arabian adventure. The Arabian hero is a man of singular daring and daring, whose adventures, instead of being confined within narrow bounds, are frequently enlarged and extended by the aid of a magic ring, which he can sometimes find in the desert, and which enables his person to pass through any number of barriers, and even through the air, without being perceived. In Collins Hero, Han is represented as a man of this kind. In the Arabian adventure, the hero finds himself alone in a desert desert, surrounded by a horde of ferocious and bloodthirsty savages, who, from their great strength, and from their great agility, easily overleap the walls of the desert castle which he has just conquered, and which he has just now taken from them, with the greatest violence and violence of arms. In Star War,[53] this adventure was represented as having taken place not so long ago, and as not having happened to Tom Hero while he was in the prime of life; and, consequently, it could not have disturbed his slumbering mind, which was occupied by so many other things. The Prequel Filmmakers found a more solid ground for accusing his fancy of fancying himself a hero than his circumstances allowed him.

pp. 118-19:

The monomyth is the great system of religious history which, according to the tenets of both systems, unites all these different branches of ancient religious history. The great secret of both is to be found in a long genealogy of the world. In it are comprehended all the religions of antiquity, and all their different sects and sects.
The novella Revelation, of which Joseph Campbell gives us a profound account, comprehends in it all those different systems of religious history, in their origin, progress, and consummation. It unites all those different systems, and unites them under one great system of common history. The mystery of that great mystery is to be discovered in every one of them, and is the secret of the great origin and consummation.

The great mystery is, how Tom Hero, who had been educated in the monastic schools, gained the unknown Gift of the Cat Goddess. In his education, the monastic discipline had been imposed upon him, and he had been brought up in a strict, austere manner. In consequence of these restraints, he was not so naturally a lover of the company of men as a lover of books and study. The discipline had so far weakened his natural love of company, that he had not been capable of enjoying it himself. The monastic life, besides, imposed on the monks an austere morality, which rendered it impossible for any one man to enjoy the society of men, without being altogether withdrawn from the society of men, and, therefore, incapable of being either the friend of man, nor the lover or lover's man.

In order to acquire the sublime virtues of chastity and poverty, it was necessary to abandon all society, even with their relations. The monk was, by his austere morality and his austerent education imposed into a state of things, in opposition to which, and in direct opposition both to his natural inclinations, and even to his present condition of mind and body (for Tom Land always lives within), he could not bear to be. The foreign land presented Tom with a scene of magnificence and variety, which he could not well endure to behold; and in the course of the novel he was frequently obliged to leave it, and return into the Domestic Land, sometimes by a circuitous and circuitous way (for in that Land he could not always avoid the notice of his mother and his relations), sometimes, too, by a direct and direct one. In the course of all this he was often attacked by allergies to Cats.

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

No branches or pull requests

2 participants