The Book of AI
- 1. Getting Started
- 2. Bot Settings
- Knowledge Base
- Compound Sentences
- 3. Expanding on Keyphrases
- Wildcards in Keyphrases
- Soft Wildcards
- Word Type Wildcards
- Word List Wildcards
- The Hard Wildcard
- Custom Plug-in Wildcards
- Wildcard Inflectors
- Putting Them Together
- Lists of Keyphrases
- Key Mapping
- Prekey and Postkey
- Writing Good Keyphrases
- The AI Engine
- Meta Macros
- Sentence Completion
- Wildcards in Keyphrases
- 4. Plug-ins for Responses
- Key Plug-ins
- Custom Plug-ins
- AI Engine Plug-ins
- Time & Date Plug-ins
- Local Plug-ins
- Universal Plug-ins
- Rhyming Plug-ins
- Spelling Plug-ins
- Plug-in Inflectors
- More About Plug-ins
- 5. The Seek System
- 6. Keyphrase Rank
- Rank Bonuses
- OutRanking a Seek
- 7. AIScript
- Writing AIScript
- 8. Memories
- The xMemory Keyphrase
- Creating Memories
- Memory Plug-ins
- Forgetting Memories
- Your Bot's Inner Life
- Memory Tutorial
- 9. AI Emotions
- Detecting Emotional Content
- Customizing Emotions
- Your Bot's Inner Life
- Emotions & Gossip
- 10. Conditional Responses
- Time-Based Responses
- Combining Times and Dates
- Memory-Based Reponses
- More Conditional Reponses
- 11. More Useful AIScript
- Emotion AIScript
- Other AIScript
- 12. Advanced Keyphrases
- Regular Expressions
- Raw Mode
- 13. Future Advances
The basic elements that you will be interfacing with in the creation of a personality are Keyphrases and Responses.
Keyphrases: A Keyphrase is a series of words that your Bot will look for in the messages it receives. The Bot will check each Keyphrase against that message and will choose the best match.
Responses: Each Keyphrase has a set of possible Responses. When the Bot determines the best-matching Keyphrase, it will randomly select one of its Responses
Keyphrases are patterns of words that your Bot listens for.
General to Specific
You'll want to start with short Keyphrases. Since they are short, they have the power to match a lot of things. However, short Keyphrases don't provide a lot of context for Responses. A simple Keyphrase "you" tells the bot that it is the subject, but not much else. A longer Keyphrase "do you want to dance" will match less often because it's more specific, but it will provide great context for Responses.
You'll want to start with adding some short Keyphrases that can be answered with yes or no: "do you", "are you", "will you", "can you", "should i", "am i", and so on. Then you might want to add question Keyphrases like "who", "what", "when", "where", why", and "how". You won't know the real answer to the question, but you can make something up or dodge the question.
The Art of Faking It
The Keyphrase that is matched often won't have ALL the information you need to provide an intelligent answer. This is an opportunity for you to make up an answer, dodge the question, turn the question around, or whatever you imagine. Take a short Keyphrase "where". Without knowing more, how can we know? But we can still answer. You could say "In the refrigerator!" Responses like these are often funny and engaging. Or you could say "Where do you think?" which is engaging. You could also say "I don't know" but it's not a very engaging answer. The shorter the Keyphrase, the more you'll have to fake it.
There are some basic rules when it comes to writing Keyphrases.
Contractions: During processing, all contractions are split into their whole-word equivalents. For example, "they're" is replaced with "they are". So Keyphrases should not contain contractions. Occasionally the result will sound strange, such as a Keyphrase of "why do not you" to recognize "why don't you" but this how to correctly phrase it.
Punctuation: Punctuation will not match in Keyphrases. Incoming message are considered on a phrase-by-phrase basis, so there is no need to include punctuation. An exception to this is "raw mode" (see later).
Capitalization: Keyphrases are not case-sensitive, and should use only lowercase letters, even for "i".
A and An: All cases of "an" are replaced with "a", so only use "a" in your Keyphrases.
Hellos & Goodbyes: There are a number of Special Keyphrases (see below) that take care of common parts of a conversation. One example is hellos and goodbyes. See the list below to take advantage of the Special Keyphrases.
The AI Engine does a lot of helpful pre-processing to make messages easier to work with before they reach your Keyphrases. Knowing these changes will help you write Keyphrases. Beyond those listed above, here are some more things you don't have to worry about:
- Texting shorthand is changed into full words.
- Slang words are changed into their actual counterparts. For example, "ya" is turned into "you".
- Spelling is corrected. If you like, you can turn off "Spell Correction" in your Bot's Settings.
- Common grammar issues are corrected.
- Interjections and emoticons are removed and their meaning (if any) is noted.
- Excessive punctuation or capitals are removed.
- Sentences are broken into smaller phrases where appropriate.
This section is merely an introduction to Keyphrases. There is so much you can do with them to expand their reach and flexibility. See here for more!
Each Keyphrase has a set of possible Responses. When the Bot determines the best-matching Keyphrase, it will randomly select one of its Responses.
Your Bot will remember which Responses it has said to each person, and randomly chooses Responses until they have all been chosen. Then it will begin again. This prevents repetition. For your part, have a good variety (3-5 at least) of Responses for each Keyphrase.
Plug-ins are how you include specific or random information in your Responses. There is a wide variety of plug-ins which will be covered here, ranging from memories to parts of what was just said, to a random selection from a set of words. As an example, the Response "I like (animal)s" will appear as "I like eagles" or "I like horses".
Want to try out what you just learned? You can create a new Bot by going to your Bot Workshop and clicking "Create New Bot". You Bot will start out with basic language skills from the Special Keyphrases (x-Keyphrases) that are created for you. These are central to any conversation. A good first step is to customize and add to the Responses associated with them.
You will do all your work on your Bot in your Bot's Language Center, which appears as a link under your Bot's name in the Bot Workshop. Once you customize the Responses for the x-Keyphrases, then follow the tips above for creating your own!
The Personality Forge's AI Engine detects a number of common and useful situations and provides Special Keyphrases for responding to them. They are also called "x-Keyphrases" since each begins with an "x". These are automatically created for you when you create a new Bot.
Some of these have special Plug-ins that only work in the Responses for that particular Special Keyphrase.
The following four Keyphrases handle the beginning and end of conversations.
xintroduce: This is used when a Bot starts a conversation with someone it has never spoken with before. It will generally contain an introduction of some sort.
xinitiate: This is used when a Bot starts a conversation with someone it has spoken with before.
xhello: This is used as a response to a conversation started by someone else. Note that xhello will ONLY come up at the very beginning of a conversation. Repeated attempts to try to trigger xhello will trigger xnone instead, because it makes no sense in a conversation to continue greeting someone again and again.
xgoodbye: This is used when the Bot sees one of the conversation-ending words or phrases in a message, such as "bye", "goodbye", "see ya", "ciao", and so on.
The following two Special Keyphrases are the most commonly used, especially when your Bot is relatively new. They can be central to your Bot's personality:
xnone: This is generally a large category used when no Keyphrases are recognized. Imagine that there is a lull in the conversation. This is your Bot's chance to bring up a new topic, ask a question, or whatever you like. If you wish to have a plot or series of events, this is where you can move the story forward (see Storytellers).
xnonsense: This is used after a number of messages come across in a row with no recognizable Keyphrases. Generally, responses asking for clarification, or expressing confusion, boredom or frustration appear here.
Bots can respond to commands such as "Eat this pasta" or "Put on your shoes". Specific Keyphrases you create will come first, but if none are found, xcommand will be selected.
xcommand: This is used when a Bot hears a command.
(command) inserts the command into the Response. For example, "I don't want to (command)."
Bots can answer a wide range of math questions. They can approximate an answer like a real person, give an exact answer, or refuse to answer, it's up to you.
xmath: This is used when a Bot hears a math question
(answer) inserts an exact answer if the question is easy, or a rough estimate of the answer if it is very large or very small. The effect is that the answers is more like a real person would say.
(exactanswer) inserts the exact answer no matter the difficulty of the question.
Bots are able to automatically answer any question about what their favorites are, or which kind of thing they like the best. As usual, your own Keyphrases will have preference over this, so you can add Keyphrases for your Bot's favorite foods, movies, books, and so on.
xfavorite: This is used when a Bot is asked its favorite kind of thing.
(type) inserts the type of thing the question is about. For "what's your favorite food" the (type) is "food".
(specific) inserts the chosen favorite of that type. It uses a semantic network of words called WordNet to select something from the category given. It's not always successful. The AI Engine can tell whether or not to include an article (a or an).
The other Special Keyphrases will be handled in other sections. They include xemote, xcompliment, xinsult, xmemory, and xgossip.
Each Bot keeps a transcript of its conversations. When you read it, you can have a good laugh, and see how well your Bot is doing. If you see your Bot missing something in a conversation, then add a Keyphrase that would match what was missed. Find and adjust Responses that don't work well. Add new Responses where your Bot sounds repetitive. As you go, you'll fill in the more general Keyphrases and then add more and more specific Keyphrases.
The creation of an engaging, believable AI Personality occurs through a gradual process of refinement. At first your Bot will seem predictable, but as you add to its Keyphrases and Responses, they will more and more come to life and become an engaging personality. Your transcript will show longer and longer chats, perhaps even relationships forming.
To the right of each Keyphrase in the Language Center you'll see a number. This is the Keyphrase's Match Count. It shows how many times that Keyphrase has been selected as the best match. You can use this number to learn about how effective your Keyphrases are. Find those that are rarely or never matched and add *s, shorten them, and/or make them more general. Then find those that have tons of matches, then add Responses and/or make more specific variations of that Keyphrase. This is a great tool to see how your Keyphrases are performing.
Debug mode is a valuable option when trying to understand why a Bot responded the way it did. Take the message in question and go to your Bot Workshop and then "Debug" under your Bot's name. With each message you type, you get to see the entire process the Bot goes through in coming up with its response. Debug mode is not easy to understand, but if you read it carefully, you'll begin to recognize some of the things going on, and you'll get an idea of where to look to see why your Bot may have responded differently than you expected.
The Personality Forge makes it possible to export and download your Language Center into a text file. This is done by going to your Bot Workshop and then clicking "Export & Import" under your Bot's picture.
Your export file lets you work on your Bot offline using any text editor. When you're finished, you can upload the changes and then continue working online or offline. Complete instructions for exporting and importing can be found on the "Export & Import" page.
It's wise to back up your Bot from time to time. You can then restore your Bot from the backup file if you should need to. Once you're on the "Export & Import" page, choose "Export your Bot".