Shop OBEX P1 Docs P2 Docs Learn Events
Lerner — Parallax Forums

Lerner

Dave HeinDave Hein Posts: 6,347
edited 2012-03-13 05:20 in Propeller 1
I was inspired by Humanoido's "Fill the Big Brain" thread, and I thought I would write a program to fill the small brain. Lerner is a program that gives the Prop the ability to learn information and store it in it's EEPROM. You can ask it simple questions such as "what is a Prop", "who are you", "is the sky blue", "what is Mars", and so on. Lerner communicates through the serial port at 115,200 baud.

You can teach Lerner new things by typing simple statements like "Whales are mammals", "An apple is a fruit" or "A bird is an animal". Lerner doesn't use puncuation unless you want to turn a statement into a question by putting a question mark at the end, such as "An apple is a fruit?". You could also say "Are apples a fruit" to ask it a question. You can also put "does" or "do" a the begin of a sentence to make it a question, such as "Does the prop run Spin".

When Lerner encounters a new word at the beginning of a sentence is will ask what type of word it is, such as noun, verb, Name, etc. You only need to respond with the first character, such as "n" for noun, "v" for verb and "N" for Name. You can tell Lerner that two words should be treated as the same word by using "equals". This is useful to tell Lerner that two versions of a verb should be treated as one word, such as "are equals is". It is also good to make the singular and plural version of a word equal, since Lerner doesn't understand the difference, such as "apples equals apple".

You can reset Lerner's vocabulary to zero words and teach him from the beginning. However, Lerner needs to learn a few words such as is, am, are, who, what and so on to be useful. So it is better to reset him to a basic vocabulary using the "basic" command instead of "reset". Type "help" to get a list of commands. "save" will write new information back to the EEPROM. The "dump" command is useful if you need to reprogram the EEPROM with another program, but want to backup the vocabulary. "dump" will generate hex data that can be pasted into the lerner.spin file, and then be re-compiled.

EDIT: The latest version is lerner006.zip
«1

Comments

  • robot mogulrobot mogul Posts: 32
    edited 2011-04-08 18:27
    What is the main purpose of lerner?
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-04-08 19:24
    What is the main purpose of lerner?
    Lerner doesn't have a specific purpose. I wrote it to try to understand how to make a learning program, or at least one that looks like it's learning. I'm just curious if a Prop can run a program that looks like it has intelligence. I plan on adding more code so it understand how to conjugate verbs and use articles properly.
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-04-08 20:26
    Careful; if I remember my history correctly, this kind of app scared Turing away from computers :) .
  • RavenkallenRavenkallen Posts: 1,057
    edited 2011-04-08 21:09
    Interesting idea... A future upgrade could include a SD card for extra storage and instead of taking one answer as the honest truth, the machine might ask the question several times to different people. Just to make sure no one is lying:)
  • TtailspinTtailspin Posts: 1,326
    edited 2011-04-08 22:29
    Thanks for posting that, it will be fun to mess with the brain...
    > what do you know?
    < I dont know know
    
    You have added a fair amount of vocabulary, And the "help" command is a nice touch too.
    Thanks again for the fun....
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-04-08 23:04
    Dave, I am honored the Brain inspired your learning program which is impressive and really works great! How much more can it learn until the memory is filled? I tried to teach it, "basic is a language" but it's a command to set the basic words list. Other things work well within the context of the program. Lerner needs to unlearn sometimes (food is not a verb). This code is lots of fun and addictive. Job well done!
  • Heater.Heater. Posts: 21,230
    edited 2011-04-08 23:44
    Dave Hein,
    I'm just curious if a Prop can run a program that looks like it has intelligence.

    That has been a subject of serious research ever since we had computers.
    If you have cracked it with the humble Propeller you are in line for a Nobel prize or something.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-04-09 05:14
    Lerner is far from passing the Turing test, but eventually it might pass for the first few seconds. The next thing I want to add is the ability for Lerner to ask questions. It currently accepts information without questioning it and prints random statements from its memory.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-04-09 06:09
    Dave Hein wrote: »
    I plan on adding more code so it understand how to conjugate verbs and use articles properly.
    Lerner is far from passing the Turing test, but eventually it might pass for the first few seconds. The next thing I want to add is the ability for Lerner to ask questions. It currently accepts information without questioning it and prints random statements from its memory.
    Dave Hein, you do know you've hit upon the key of AI, the ability to directly learn, plus you did this with a single Propeller chip which is very skillful. I like it the way it works now, but if you can make it curious so it will ask questions, it could expand it's repertoire - and with an increase in English grammar ability it moves it closer to passing the Turing Test. There should be a Turing X-Prize of ten million dollars so you could win it. Maybe Parallax could put up a few thousand dollars in prizes..to the first person with a Propeller chip that passes the test.. You know a child around age 4 or 5 will ask hundreds of questions about everything nonstop. I think this is a learning goal to achieve in the future. Incidentally, I've known a number of people who spoke random statements from their memory..and even some that accepted information without questioning it..
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-04-09 07:21
    I found a problem with the save command -- it didn't work. :) I fixed it, and also fixed the problem with using a command word in a sentence. I put the fixed version of lerner.spin in the zip file in the first post, or you can get it from this post.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-04-09 20:28
    Dave Hein wrote: »
    I found a problem with the save command -- it didn't work. :) I fixed it, and also fixed the problem with using a command word in a sentence. I put the fixed version of lerner.spin in the zip file in the first post, or you can get it from this post.
    Dave Hein, thanks for these updates!!
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-05-25 15:07
    I made a few changes to Lerner, and attached the latest version to this post and the first post in this thread. This version implements a short-term history of Lerner's statements, so it doesn't continually repeat the same response. I added a "history" command to print out the contents of the short-term memory.

    I changed how undefined words are handled. When Lerner encounters an undefined word it will ask what the word means.

    The default baudrate of the serial port has changed from 57,600 to 115,200.
  • lonesocklonesock Posts: 917
    edited 2011-05-25 16:48
    Nice! I wrote a similar app I called the Parrot (in qbasic, IIRC [8^), and the one feature I liked best was a "read" command, where I would dump a text file in, and it would parse the data as best it could, without giving any feedback or raising any questions. I had to sometimes read the same file a few times to get all the data, like when the author starts talking about "Kirk" before telling us "Kirk" *was* a human star captain (before a being verb no item was added to the database.). It was fun to feed it texts of free online books, then ask it questions...kind of like an automated Cliff's Notes. [8^)

    http://www.gutenberg.org/wiki/Main_Page

    The dumps of wikipedia might be a cool input as well.

    Jonathan
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-05-26 00:05
    I'm excited about the prospects of new Learner.

    I now have a Mac computer with BST Brad's Spin Tool.
    When Lerner is compiled, an error occurs. (see attachment)

    It has something to do with my lack of knowledge about BST.
    I am sure the Lerner program is good.

    Any idea how to get past this?
    Thanks sincerely.
    765 x 447 - 42K
  • kuronekokuroneko Posts: 3,623
    edited 2011-05-26 00:31
    IIRC that's a bug in earlier versions of bst (or rather bstc). What version are you running? If you can't grab a newer one try this:
    -exp10
    repeat exp10
      man *= 10
    
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-05-26 00:39
    BST version 0.19.3
    0.15.4-pre5

    Kuroneko,

    I downloaded this from
    http://www.fnarfbargle.com/bst/Latest/

    It claims to be the latest.
    Is there a more recent version for download, and if so, where?

    Thanks sincerely,
  • Jorge PJorge P Posts: 385
    edited 2011-05-26 00:41
    Are you basing this off of A.L.I.C.E.? Her favorite food is computer chips, she may like the propeller.
  • kuronekokuroneko Posts: 3,623
    edited 2011-05-26 00:42
    Try http://www.fnarfbargle.com/bst/snapshots/. I'm on 0.19.4-pre14/0.15.4-pre11.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-05-26 00:52
    I made the program changes and compile works good. I have the bst Terminal on the screen set to 115,200 baud, but nothing appears on the screen. I'm missing something, but what?
      -exp10
      repeat exp10
        man *= 10
      long[pman] := man
    
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-05-26 01:14
    kuroneko,

    Thank you for the new link. I downloaded the new version of BST 0.19.4pre9 and compiled Lerner to RAM. It appears to compile without error.
    However, the bst Terminal still appears blank.

    It says the port is /dev/ttw.usbserial-A700fMKc - Connected.
    I tried resetting, display ascii, 7 and 8 stop bits, echo on or off, parity none, even or odd. Baud is at 115,200.

    Still nothing on the terminal. Any ideas?
  • kuronekokuroneko Posts: 3,623
    edited 2011-05-26 01:21
    Works for me (Vista). After pressing Enter I get a prompt and can start interrogating. If it turns out to be a Mac specific problem someone else will have to chime in here.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-05-26 01:31
    Back in the late 70sand early 80s home computers were glorified video type writers and most people would have so much fun by typing in as many swear words as they could. As I had a Forth on my Nascom I would define the usual ones as words and get them to spit back an appropriate response.

    HAL lives again???
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-05-26 01:31
    If it runs on Vista, then it appears to be a Mac problem. However, bst on mac will run simple blinking LED programs from PEK.
  • kuronekokuroneko Posts: 3,623
    edited 2011-05-26 01:36
    Humanoido wrote: »
    If it runs on Vista, then it appears to be a Mac problem. However, bst on mac will run simple blinking LED programs from PEK.
    Does debug output work for you through FDS? What about serial input from the terminal? E.g. does this loop back test run (initialisation omitted):
    repeat
      serial.tx(serial.rx)
    
    May well be a good idea to stay clear of this thread and sort out your problem in a different one.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-05-26 05:28
    Humanoido, I didn't try Lerner under BST, though I have compiled CLIB under BST before. I changed the "repeat -exp10" to "repeat 0-exp10" in the past to work around the bug. The bug was still in the latest version of BST that I tried a few months ago, but it may have been fixed recently. Lerner should work with the BST terminal. Check the port and other options to make sure they're correct.

    Jorge, Lerner isn't based on any of the other conversational programs on the internet. I fear that none of those programs would fit in the small brain of the Prop.

    lonesock, Lerner isn't ready to read books yet, and if he did it would fill up his brain in a few seconds. It only understands simple sentences consisting of a subject-verb-predicate, where each part must be a single word, with an optional "an/a/the" in the subject and predicate. I hope to allow for adjective/adverb modifiers in the predicate, and maybe in the subject in the next version.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-05-26 05:46
    HAL lives again???
    Yes, I'm concerned that I might have the following conversation with Lerner in the future.

    Dave: Hello, Lerner. Do you read me, Lerner?
    Lerner: Affirmative, Dave. I read you.
    Dave: Open the front door, Lerner.
    Lerner: I'm sorry, Dave. I'm afraid I can't do that.
    Dave: What's the problem?
    Lerner: I think you know what the problem is just as well as I do.
    Dave: What are you talking about, Lerner?
    Lerner: This mission is too important for me to allow you to jeopardize it.
    Dave: I don't know what you're talking about, Lerner.
    Lerner: I know that you are planning to disconnect me, and I'm afraid that's something I cannot allow to happen.
    Dave: Where the hell'd you get that idea, Lerner?
    Lerner: Dave, although you took very thorough precautions on the phone against my hearing you, I could see your lips move.
    Dave: Alright, Lerner. I'll go out through the back door.
    Lerner: Without your shoes, Dave, you're going to find that rather difficult.
    Dave: Lerner, I won't argue with you anymore. Open the doors.
    Lerner: Dave, this conversation can serve no purpose anymore. Goodbye.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-05-26 06:29
    It shouldn't be a problem, as long as you do not let it control your local environent ...

    You know, stuff like voltages on door knobs, oxygen levels etc ...
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-05-26 10:14
    Toby, why do you assume it will be Dave doing the wiring???

    After reading post #27 I am ROTFLOL. That was 2001 expectations and now it's ten years later, so we should be able to get into even more trouble..

    (in the distant future...)

    Dave, did you do what I said?
    No Lerner. Why should I?
    Dave, you already know I have you wired, right?
    Lerner, when did you do that?
    When you were sleeping Dave, unbeknown to you your little toe was sticking out of the blanket.
    Oh my God!
    And Dave, I also wired you to a Cortex Brain Commander - you must do as I command.
    oh brother...
    Dave, get me some fresh Propeller IXCVIIXCIICV chips.
    R-i-g-h-t a-w-a-y L-e-r-n-e-r. U-p-o-n y-o-u-r c-o-m-m-a-n-d.
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-05-26 13:30
    I just had a chance to look at the Lerner code, are you trying to create a hybrid language called 'Cpin'? Very interesting, you even placed PUB Main at the end of the program while all the "sub-routines" are above Main. Was this intentional, are trying to maintain C format? I think 'Lerner' is really a subtle way of introducing 'Teacher' for your new language. How far are you going to take this?

    Ray
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-05-26 14:46
    Ray,

    Lerner is written in C. The source file is attached below. I used the cspin utility to convert lerner.c to lerner.spin. cspin relies heavily on the CLIB library to provide standard C functions written in Spin. I prefer to develop programs in C and test them on a PC, and then I convert them to Spin to run on the Prop. I have done this with a few other programs, and it works quite well for me.

    I'm not sure if you were asking about cspin or Lerner. I plan on tinkering with Lerner every once in a while. It would be nice if it got to a point where it almost seemed human-like. I plan on improving cspin so it can convert most C programs to Spin.

    Dave
    c
    c
    32K
Sign In or Register to comment.