Using AI to Create the Perfect Keyboard

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
most of the English-speaking world will be familiar with this keyboard layout named after the first six letters on the top row the QWERTY keyboard was invented for typewriters nearly 150 years ago by Christopher Latham scholes and has remained unchanged ever since technological innovation in the past 150 years has soared but the keyboard layout has remained a constant it just hasn't made sense to change a design that so many people are already familiar with despite how unintuitive the layout may be but I wanted to know how much better can the keyboard actually be foreign in the context of this video a good keyboard is one that is efficient by minimizing the total distance the fingers have to move when typing assuming you use all 10 fingers to type your fingers should start in this basic position each finger is responsible for typing specific keys on the keyboard for the purposes of this video we will only focus on the letter and punctuation keys by following these rules we can calculate how far each finger has to travel for any given letter pairing if we assume that the distance from one key to the key left or right of it is one then the distance from a key in the middle row to a key in the top row is approximately 1.032 notice that the bottom row is slightly more offset than the top row which means that the distance to the bottom row will be slightly further at approximately 1.118 this is common among many keyboards but not all keyboards so your keyboard might look slightly different the distance from the top row to the bottom row is about 2.138 this covers most key pairings but there are special cases for fingers 4 and 7 since they are responsible for more keys using all of these distances we can calculate the total distance the fingers will travel in order to type any given word for example in order to type the word have finger 7 moves from J to H finger one doesn't need to move anywhere to type a finger 4 moves from F to V and finger three moves from D to e this gives a total distance traveled of approximately 3.15 it's worth noting that for words where a letter appears twice in a row your finger doesn't need to move back to that letter so to type a word like pool would be a distance of 3.096 foreign in order to create the most optimized keyboard for efficiency I'll be using a genetic algorithm if you're not familiar with genetic algorithms then I'll explain it in the context of this project as I already mentioned for giving keyboard layout we can calculate the total distance it will take to type something for example using the QWERTY layout to type the quick brown box jumps over the lazy dog will have a total distance of about 34.611 then we could take another keyboard layout like the Dvorak layout for example and calculate the total distance for the same sentence which would be just 22.823 since we decided that the most efficient keyword is one that minimizes distance then we would conclude that the Dvorak layout is a better and more efficient keyboard layout than the QWERTY layout however this would be a really bad test since it would just be testing the distance over one sentence instead we should calculate the distance over a very large data set of text for this video I use the archive.org abstract data set archive.org Is An Open Access archive for research papers and other scholarly articles and on the site each of these articles has a short abstract that describes the paper I use the archive.org dataset to create a large collection of these abstracts what I was left with was a textual data set of about 37 000 English words and 240 000 total characters that I could use to better test the efficiency of a keyboard layout for example when I simulated typing this data set using the QWERTY layout the total distance was about 174 000. compare that again to the Dvorak layout which had a total distance of only 96 000. now we can work confidently conclude that the Dvorak layout is in fact more efficient than the QWERTY layout now instead of using two predefined layouts let's use a bunch of randomly generated keyboard layouts and calculate the total distance for each in genetic algorithm terms each key on the keyboard would be a gene each keyboard itself would be referred to as a chromosome and all of the keyboards that get there would be referred to as our population and our population size would be 10. the total distance for each keyboard would be referred to as its Fitness score after we've calculated the distances for each keyboard we can take the most efficient keyboards and use them to create new layouts we can create a new keyboard layout by combining any two of these keyboards together we choose a point at which we will split the keyboards and then add the keys from the left of the split point from keyboard 1. we could add the keys from the right of the split point from keyboard 2 however this will usually create an issue where there are duplicate keys so instead of adding all the keys from keyboard 2 we only add the remaining keys that are needed in the order that they appear after the split point the hope is that by doing this we can potentially create a better keyboard by taking good traits from both of the keyboards and combining it into one we will then repeat this 10 times choosing random keyboards and split Points each time to create 10 new keyboards this will be the population for the next generation and the entire process will be repeated Again by only using the most efficient keyboards from each generation to create a Next Generation the keyboard should become increasingly efficient over time this process mimics natural selection only the best keyboards survive and they are used to create the next generation of keyboards I implemented the genetic algorithm in Python and ran the algorithm for 1 000 generations with a population size of 150. the first graph shows the distance for the most efficient keyboard in the entire generation the second graph shows the average distance across the entire population for each generation the keyboard they have shown is the most efficient layout that the genetic algorithm has found so far you can see that the genetic algorithm makes very quick progress at the start finding a keyboard with a total distance under 80 000 within the first 30 Generations after this the progress becomes much slower it isn't until generation 109 when the distance drops below 75 000. after another 100 Generations the total distance for the best keyboard found is just about seventy four thousand for context remember that the total distance of the QWERTY keyboard was 174 000. it is an Intel generation 279 that the next and final Improvement is made to the layout the algorithm runs for the total 1000 Generations but doesn't make any additional improvements this is the best keyboard that was generated by the genetic algorithm I also ran the algorithm two more times this time with a population size of 200 and got similar but slightly different results the total distances for all the keyboards was in the low 74 thousands this is about a 57 decrease from using the standard QWERTY layout we can see some similarities among all of the keyboards for one the semicolon and question mark keys are in the middle of the keyboard this makes sense because the position of these keys are further from the starting Keys than any other keys since the question mark and semicolon are less frequently used than any other Keys it makes sense to have them in the furthest away positions another similarity is that all the vowels except U are on the middle row as well as the consonants rstln this makes sense because these are the most frequently used letters so it makes sense to have them be the starting keys if you've ever watched Wheel of Fortune then you'll know that in the bonus realm the show gives contestants the letters r-s-t-l-n-e because they are commonly used letters as a tribute to that show I'll be referring to this style of keyboard layout as the rst lne layout since all of these letters feature on the home row of these keyboards if I were to suggest a keyboard design that implements the rst lne layout it would look something like this it minimizes the changes that need to be made to the QWERTY layout making it easier to learn while also keeping the key features of the rst lne layout this design has a total distance of about 80 000 on the data set making it slightly less inefficient than the keyboards that were generated by the genetic algorithm but still much more efficient than the QWERTY layout I thought it would also be interesting to find the best keyboards for various different situations as well for example what if you don't use all 10 fingers to type and instead only use two fingers what would the best keyboard be then this situation would be very common when typing on a mobile device or for people who haven't learned how to type with all 10 fingers yet for this situation we can run the genetic algorithm in the same way we just need to measure the distances differently in this case I assume that the starting positions for the two fingers would be over the D and K Keys the total distance detected data set using two fingers would be 343 000 on a qwerty keyboard these are the layouts that were generated by the genetic algorithm the main thing to notice here is that it groups the vowels together on one side and the commonly used consonants together on the other side of the keyboard this is pretty intuitive since the commonly used keys are placed closer to the starting positions of the two fingers and the less commonly used keys are placed further away if I were to propose a keyboard design implementing this it would probably look something like this the next situation I wanted to test for was using one finger to type I adjusted the distances and ran the algorithm three times again these were the keyboards that were generated these results were actually slightly surprising to me I would have expected that the most commonly used Keys would be grouped in the center of the keyboard but in all of the layouts they were actually grouped slightly more to the left around the fourth key in the second row this doesn't seem super intuitive to me and I'm not sure why the AI found this to be more optimal than having the common these keys in the center nevertheless if I were to propose a keyboard layout implementing this finding then it might look something like this the last thing I wanted to test was how the keyboard would change if the content of the text was different for example if you were typing code in Java you would need to use the semicolon key far more often than in standard English since it appears at the end of every instruction to test this I switched the text data set to 6000 lines of java code extracted from the GitHub Java Corpus I then ran the genetic algorithm again for the normal 10-finger keyboard and this was the result as expected the semicolon key is now in a position closer to the home Keys one interesting observation is that c is now in the middle row instead of L this could be because C appears more often due to Java keywords like package interface static switch case and catch which are all used frequently and contain the letter c the rst lne keyboard layout might be the best for typing Standard English using 10 fingers but depending on how many fingers you use to type and the type of content you are typing the most optimized keyword layout can change significantly if you're curious to try out the keywords created by the AI I created a simple website at atomcodes.github.io Link in the description where you can do typing tests using the different keyboards in this video I put this together in about one day so it might be kind of buggy or look weird on certain devices but the general functionality should work foreign istically I don't expect anyone to actually change the way they type just based on this video learning to type can take a while to learn and be comfortable with it's just not worth the effort for most people who are already familiar with the QWERTY layout to relearn where the keys are in a different layout even if it is significantly more efficient the QWERTY keyboard has already stood the test of time for nearly 150 years and it seems like it'll stay that way for at least 150 more I do think it was a really interesting experiment though to see how the keyboard could be improved and if anyone actually tries it let me know how it goes in the comments if you made it this far and enjoyed the video then consider leaving a like and subscribing thanks for watching
Info
Channel: adumb
Views: 1,408,089
Rating: undefined out of 5
Keywords: artificial intelligence, artificialintelligence, ai, machine learning, machinelearning, genetic algorithm, geneticalgorithm, keyboard, keyboard layout, qwerty, ai learns, codebullet
Id: EOaPb9wrgDY
Channel Id: undefined
Length: 12min 5sec (725 seconds)
Published: Fri Sep 23 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.