Join thousands of AI enthusiasts and experts at the Learn AI Community.

Publication

Latest

I used AI to Generate Nietzschean Aphorisms

Last Updated on November 25, 2022 by Editorial Team

Author(s): Yoo Byoung Woo

Originally published on Towards AI the World’s Leading AI and Technology News and Media Company. If you are building an AI-related product or service, we invite you to consider becoming an AI sponsor. At Towards AI, we help scale AI and technology startups. Let us help you unleash your technology to the masses.

Can large language models help mankind overcome the crisis of nihilism in the modern world?

Ever since OpenAI released GPT-3, a large language model (LLM) trained on a massive amount of text data, the natural language processing community has been excited about the potential of using this technology for computational creativity (e.g., generating blog posts, fiction, or poetry). I personally think that LLMs are not only convenient tools for synthesizing media content or writing works of literature but also have the potential to solve a more serious problem: the crisis of meaning due to the advent of nihilism in the modern world.

God is Dead — Nietzsche, the Herald of Nihilism

According to the 19th-century German philosopher Friedrich Nietzsche, best known for heralding the death of God, modern civilization is plagued by nihilism; the loss of all value structure and meaning in life. When Nietzsche proclaimed “God is dead”, he wasn’t merely observing the decline of religion but was also pointing out that the universal values which have been the cornerstone of Western civilization for centuries no longer hold any meaning, thus each individual is left to fend for themselves, trying to make sense of a world that seems increasingly chaotic and full of suffering.

In the wake of the death of God, modern civilization is plagued by nihilism (created by author & stable diffusion)

Although the age of Enlightenment and the scientific revolution played a significant part in ushering the loss of faith, Nietzsche mainly blames the predominant worldview of the time, i.e., Platonic idealism, Christianity, and Utopianism, for the spiritual weakening of modern man. For Nietzsche, these philosophies are a form of escapism, as they are based on the belief in a perfect, idealistic world (e.g., Platonic Forms, Paradise, communist utopia, etc.) which is separate from and superior to the material world, in which we often feel our lives are cruel, harsh and painfully short. Their function is to provide grand narratives of the “true world” and give hope that there is something more to life than our earthly existence, but such a view is ultimately decadent, as it provides false hope and encourages people to withdraw from life and the real world. When these idealistic visions of reality are shown to be false (as they inevitably are), then the entire value structure that they support collapses, leading to a spiritual crisis and a loss of meaning in life. This is what Nietzsche called nihilism, and he saw it as the greatest threat to Western civilization.

Ideologies aim to bring an end to history by creating a utopia (created by author & stable diffusion)

Nietzsche’s warnings about the dangers of nihilism have proven to be prophetic, as the 20th century was marked by two world wars and the horrific genocide of millions of people, which were primarily fueled by fascism, totalitarianism, and communism; ideologies that aim to bring an end to history by creating a utopia, be it racial, national or class-based. According to philosopher Julian Young, although most of them rejected metaphysical ideas, they are nevertheless “true world” philosophies in disguise, in which the old distinction between physical and metaphysical is reinterpreted as a distinction between present and future. The modern man, after the death of God and consequent disasters, is left with a feeling of absurdity and pointlessness, and the need for a new grand narrative, or better yet, overcoming the dependence on such narratives altogether, arises.

Revaluation of All Values — Generating Aphorisms with a LLM

How can man accomplish the task of overcoming nihilism? Nietzsche proposes that we must first carefully examine the ethical norms we take for granted, a process he calls the revaluation of all values. This process exposes how these “true world” grand narratives promote decadence, so that man can create values of his own without relying on such life-denying philosophies. For Nietzsche, the method of revaluation was to write aphorisms — brief, pithy, highly condensed statements that identify the genealogy and psychological motivations behind systems of values and their futile attempts to cover up the existential uncertainties of the human condition.

Summon Nietzsche from the abyss of madness via AI technology (created by author & stable diffusion)

Recently, I’ve been reading a lot of Nietzsche — I was fascinated by his style of writing in aphorisms and how he used this literary form to uncover truths that modernity would rather keep hidden. I thought it was a shame that, ever since Nietzsche suffered a severe mental breakdown at the age of forty-four, he couldn’t produce remarkable works again. This had me thinking: what if we could summon Nietzsche from the abyss of madness and resurrect him via AI technology? Specifically, what if we could use LLMs to generate previously unheard-of Nietzschean aphorisms?

NLP enthusiasts have shown that it is possible to get OpenAI’s GPT-3 to generate works of poetry in the style of a specific poet by providing only a handful of examples. This approach is known as few-shot learning, where a LLM is able to learn to perform a certain task from a small amount of data (a.k.a. few-shot samples) during inference time. These few-shot samples are included in the input text (a.k.a. prompt), usually in the form of a numbered list. The LLM, a model which is primarily trained for natural language completion tasks, will then generate text that conforms to the format and style of the provided samples. I thought there would be no reason why the same approach couldn’t be used to generate Nietzschean aphorisms.

The prompt for Nietzschean aphorism generation (created by author)

The main idea for Nietzschean aphorism generation is as follows: I take a bunch of Nietzsche’s aphorisms, format them in a specific way, and then feed them into a LLM. The model will then “learn” the style and content of Nietzsche’s aphorisms and generate new, never-before-seen aphorisms that are indistinguishable from Nietzsche’s (at least in principle). Hopefully, these aphorisms will be able to provide stark insights into the human condition.

Human, all too Human — Tutorial for Few-shot Learning of Nietzschean Aphorisms

Nietzschean aphorism generation workflow overview (created by author)

I used Nietzsche’s <Human, all too Human> as a source for few-shot samples since it takes the form of a collection of aphorisms. The full English-translated text is available at Project Gutenberg, which is a great resource consisting of numerous classical works of literature. Since the text file isn’t formatted in a way that is suitable for NLP operations, a preprocessing step was necessary. After parsing the text file, I yielded two lists; one for the aphorisms themselves and the other for the corresponding section titles. The section titles will be used as aphorism topics later on. The following is the code for converting the entire text file into lists of aphorisms and their topics.

def preprocessing(file_dir):

# read text file into book_text variable
book_text = open(file_dir, 'r', encoding='utf-8').read()

topic_data = [] # list for storing section titles (used as topics)
aphorism_data = [] # list for storing aphorism texts

# aphorism sections are seperated by '\n\n\n' strings
for chunk in book_text.split('\n\n\n'):

chunk = chunk.split('\n\n')[-1] # remove section number
chunk.replace('\n', ' ') # remove newline characters
chunk.replace('_', '') # remove underscores

# topic (section title) and aphorisms are seperated by '.--' strings
topic, aphorism = chunk.split('.--')

topic_data.append(topic.upper()) # capitalize topics
aphorism_data.append('.--'.join([topic.upper(), text.aphorism()]))

return topic_data, aphorism_data

The generation process is two-fold. First, the LLM generates a new aphorism topic given a list of randomly selected topic examples. Second, the LLM generates a new aphorism given a prompt consisting of randomly selected topic-aphorism pairs and the topic generated in the previous step. Therefore, two prompts are required: the topic prompt and the aphorism prompt. The following is the code for prompt engineering.

# I used 30 topic samples
def topic_prompt(topic_samples):

prompt = 'Nietzsche\'s Aphorism Topics:\n' # task description

# numbered list of few-shot samples
for n, topic in enumerate(topic_samples):
prompt += f'\n{n+1}. {topic}'

prompt += f'\n{len(topic_samples)+1}.'
return prompt


# I used only 3 aphorism samples due to LLM context length
def aphorism_prompt(aphorism_samples, generated_topic):

prompt = 'Nietzsche\'s Aphorism:\n' # task description

# numbered list of few-shot samples
for n, aphorism in enumerate(aphorism_samples):
prompt += f'\n{n+1}. {aphorism}'

# append the generated topic to the prompt
prompt += f'\n{len(aphorism_samples)+1}. {generated_topic}.--'
return prompt

In this project, I used the open-source 176B parameter LLM BLOOM, which is freely accessible via the Huggingface Inference API. Note that any sufficiently powerful LLM (e.g., GPT-3, PaLM, etc.) is able to perform few-shot learning. As mentioned above, the generation process is two-fold — first, we yield the topic, then the aphorism. The following is the code for generating Nietzschean aphorisms with BLOOM.

import requests

def generate(prompt, max_new_tokens):

API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
headers = {"Authorization": "Bearer YOUR_HF_TOKEN_HERE"}

payload = {
"inputs": prompt, # prompt should be less than 1000 tokens

# the following decoding setting yields coherent results
"parameters": {"max_new_tokens": max_new_tokens,
"do_sample":True,
"top_p":0.9,
"repetition_penalty":2.0,
"temperature":0.85,
"return_full_text":False,
"use_gpu":True,
"wait_for_model":True}
}
response = requests.post(API_URL, headers=headers, json=payload)
output = response.json()

return output[0]['generated_text']


# step 1. generate topic
prompt = topic_prompt(topic_samples)
generated_topic = generate(prompt, 16).split(f'{len(topic_samples)+1} ')[-1].split('\n')[0].strip()

# step 2. generate aphorism
prompt = aphorism_prompt(aphorism_samples, generated_topic)
generated_aphorism = generate(prompt, 250).split(f'{len(aphorism_samples)+1} ')[-1].split('\n')[0].strip()

Results

The model yielded impressive results. It was able to successfully generate aphorisms that conform to the style and topics of Nietzsche’s writing in a few minutes. Although the generated aphorisms were by no means perfect, I believe that they succeeded in portraying “Nietzschean” characteristics. Here is an example of a prompt and its completion (text in bold):

Nietzsche’s Aphorisms:

1. TO CAUSE THE MASTER TO BE FORGOTTEN - The pianoforte player who executes the work of a master will have played best if he has made his audience forget the master, and if it seemed as if he were relating a story from his own life or just passing through some experience. Assuredly, if he is of no importance, every one will abhor the garrulity with which he talks about his own life. Therefore he must know how to influence his hearer’s imagination favourably towards himself. Hereby are explained all the weaknesses and follies of "the virtuoso."

2. REDUCING - Many things, events, or persons, cannot bear treatment on a small scale. The Laocoon group cannot be reduced to a knick-knack; great size is necessary to it. But more seldom still does anything that is naturally small bear enlargement; for which reason biographers succeed far oftener in representing a great man as small than a small one as great.

3. SENSUOUSNESS IN PRESENT-DAY ART - Artists nowadays frequently miscalculate when they count on the sensuous effect of their works, for their spectators or hearers have no longer a fully sensuous nature, and, quite contrary to the artist’s intention, his work produces in them a "holiness" of feeling which is closely related to boredom. Their sensuousness begins, perhaps, just where that of the artist ceases; they meet, therefore, only at one point at the most.

4. THE SENSUOUS ARTIST AND THE PHILOSOPHER - An artist is sensuous in the same sense in which a philosopher is spiritual. In both, the instinct which demands an immediate satisfaction is predominant, in both the "subject" is the immediate object of the instinct, in both there is an almost animal craving for the most direct effect; both are only just as little consistent as is the animal in this respect. The difference between them consists in this, that in the artist the sensuousness is always the most active principle, while in the philosopher it is only the most passive; in the artist the sensuousness is determined by a certain narrow sphere of the sensuous, while in the philosopher it is determined by a certain narrow sphere of the spiritual. Thus the sensuousness of the artist and that of the philosopher are in direct antithesis to each other.

More aphorisms are presented in the appendix. There were a few limitations in the project, the biggest one being that I had to use only three few-shot samples due to BLOOM’s context length constraints. I’m hoping to improve upon the current framework by fine-tuning a smaller language model rather than relying on BLOOM’s few-shot learning capabilities.

Appendix

THE EARTH AND THE WORLD’S POWER - Whoever desires to maintain that the earth was created by God, is not only doing violence to his own thought, but also insulting science, in so far as he affirms that there is something which is incomprehensible, that there is anything which we are not able to comprehend, and which therefore must have been produced by a superhuman force. But whoever, like us, looks at the earth from the point of view of science, regards the earth as a world-body, subject to the same laws as other world-bodies, and he will never be able to understand how an incomprehensible, spiritual, supernatural, or what not, can have produced anything out of nothing. The geological science, which has only been perfected within the last few hundred years, has taught us that the earth has always existed, and that the time since it has existed is only a few thousands of years. 

THE PASSION OF THE INDIVIDUAL - What is called the passion of the individual is a wish to be something. It is the pleasure of an individual to feel himself as a person, and to be as much as possible something. In the whole history of the world this is a most unusual and at the same time a most noble feeling, and it has the same value for an individual as a whole as the feeling of existence has for a world. It is because of this feeling that the individual is not entirely annihilated in the family and in the state. Every one who has felt this feeling must have had a great pleasure in acting alone and independently, in feeling himself as a person, and in being able to speak and to think. This feeling is so uncommon that it may be called the passion of the individual.

COMPARING ONE’S SELF TO THE AVERAGE - It is only a defective man who compares himself with others. The healthy man does not seek in others what he can have himself. The healthy man knows that the real goal is his own person, and that there are others only in order that he may know himself. Therefore the real man does not go about seeking others, but he seeks himself. Therefore he who compares himself to the average does not go about seeking himself.

HONOUR AND DUTY - We are used to consider honour as a kind of property, as something belonging to us. It is indeed a peculiarly sensitive property, and therefore in our eyes a special source of enjoyment. The feeling of honour, however, is a purely artificial one, and is not more natural than a king’s crown. As the very idea of property is derived from exchange, so the idea of honour is derived from recognition. Honour is the feeling of property in a man’s own value, in a property which has been recognised by a third party, a feeling which must be acknowledged as independent of all other possessions, and as the highest of all possessions. The idea of honour is the idea of a property, which, as soon as it is in the possession of a man, must be recognised by every one else as his property, and as such must be treated. Honour is not a virtue but a good, not a moral but a legal property. Honour and duty are two different expressions for the same idea, for the relation of a man to himself, to his own special value.

THE DECADENCE OF ART - The decadence of art is also the decadence of the understanding. The latter may be defined as the impossibility of creating a system of ideas and forms by which the manifold appearance of things could be expressed in a new way. The decadence of art is, therefore, not only the decadence of art, but that of the whole mental development.


I used AI to Generate Nietzschean Aphorisms was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Join thousands of data leaders on the AI newsletter. It’s free, we don’t spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓