Jump to content
DynamicRookie

Artificial Intelligence Neural Networks

Recommended Posts

DynamicRookie
Posted (edited)

Hey there!

 

I've been developing a artificial intelligence.

My first hard task was letting the A.I know when a sentence is found in memory with different words

What i tried to do here is simply, get all the words in user sentence that could be used
as a identifier
        
        example: Steve Jobs
        
        then identify the sentence purpose with the words we found in the past "for" loop
        
        example: Do/Know/You/Who/Steve/Jobs
        
        Compare the example in the following matching sentences in memory.
        
        1-Steve jobs was a known person
        2-Do you know who barack obama is?
        3-Do you know Steve jobs?
        4-Do you know who steve jobs is?
        5-How much money steve jobs had
        
        Then find the sentence that has way more matches than the other ones, remember that if the identifier words were not found
        (Steve jobs) then the sentence is invalid.
        
        Every sentence has a different answer and is important that the right one is chosen.
        

If there's no more than the half of words in matches, then assign a variable the result of function, such as a return but for a global var.

I couldn't figure out how to do that with StringRegExp.
 

I honestly need help with detecting identifiers on memory sentences.

I would also like to let the AI know typos, meaning that moeny and money means the same thing.

Any help is hugely appreciated.

 

Edited by DynamicRookie
Updated

Share this post


Link to post
Share on other sites
KickStarter15
9 hours ago, DynamicRookie said:

My first hard task was letting the A.I know when a sentence is found in memory with different words

Is this an excel file where your memory database found for validation?

 

9 hours ago, DynamicRookie said:

       Compare the example in the following matching sentences in memory.
        
        1-Steve jobs was a known person
        2-Do you know who barack obama is?
        3-Do you know Steve jobs?
        4-Do you know who steve jobs is?
        5-How much money steve jobs had

Secondly, if this were database validation then that would be easy for excel UDF by Water. But off course, you need to GUICtrlRead() for the input made by the user for the word validation.


Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Share this post


Link to post
Share on other sites
IAMK
Posted (edited)

For the typos, you have a few ways, depending on how lenient you want to make it.

1- The simplest would probably be to count the letters in each word (maybe store it in a data structure), so "apple" would be 1a, 2p, 1l, 1e. Then, you do a search and find a match in the word "papel". Problem: Anagrams. You could also make it accept a difference of 1 (leniency).

2- Check that two words match, but also check the +1/-1 char of the word for the letter in case they swtich it like I did for the word "switch". E.g. [w][t][c][h] and [w][t][c][h]:
0=0, 1=1, 2!=2, check 2+1=2 (2 and 3 are now found, so you can skip 3), 4=4, 5=5.

Pretend there is no strikeout above ^. The forum put it there.

Edited by IAMK

Share this post


Link to post
Share on other sites
FMS

maybe of topic on your question but I am also building AI (code here)
Maybe we can compare some code ?
I'm curious on your take on the math :)


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
DynamicRookie
13 hours ago, FMS said:

maybe of topic on your question but I am also building AI (code here)
Maybe we can compare some code ?
I'm curious on your take on the math :)

I'm not skilled or something honestly, i'm just trying to let my code be simple so debugging is easier, however, so far i could do self-learning, memory checking, non-supervised learning, GUI, Inputs, memory arrays, weight, neurons, temporal lobes (This will let the AI know that "My name is Rookie" will be reffered if the user says "What's my name?", i have made it up to 1000 messages and the sentences are kind of encrypted for privacy and saved in a file), and check if the AI is original.

 

The AI is interesting to talk to, but my objective is to make it entertaining, not only for use but for coding it, like a hobbie.

I checked ur AI thread and it looks really interesting, but hard to debug.

I'd appreciate if you explained me how it works, cause i'm really curious!

Share this post


Link to post
Share on other sites
Andreik

AI is a complex concept and usually is a mixture of many algorithms combined. For what you need a good start would be to play with levenshtein distance. This is an algorithm to check the similarities of strings.

  • Like 1

When the words fail... music speaks

Share this post


Link to post
Share on other sites
DynamicRookie
13 hours ago, Andreik said:

AI is a complex concept and usually is a mixture of many algorithms combined. For what you need a good start would be to play with levenshtein distance. This is an algorithm to check the similarities of strings.

Yeah, i have thought of that, but i made a extremely easy system that only took me about 10 minutes.

Is, checking strings letters, every letter has a value, then we replace all the letters by their values and sum them all, that means that, in example, msas and mass are both worth 16.

Very easy system, i'll also add a system so it can check for duplicated letters, missing letters, and extra letters.

About the learning system, it is designed to change topic as soon as the sentence the user provided was not found in memory, then tell another person (or to the same user in a different session) the sentence the other user said, and store the answer.

Share this post


Link to post
Share on other sites
FMS
Posted (edited)
Quote

I'd appreciate if you explained me how it works, cause i'm really curious!

The AI.au3 you see is (in this case) checks "handwritten digits" and calculates the best possible digit it think it is :)
The file's beneath the ai.au3 are the mnist database (handwritten digits and it's "target")
The targets are there for the "backwards propagation".
The handwritten digits are in a grid of 28 by 28 whit a black/white of 0 to 255.

In the beggining you have 1 "array" (or vector) of 784 (28*28) whit value's of 0-255 and propagrate forward (whit matrix math E4A)  to a array[10] (1 for each digit).
you see what i mean iff you klik the label "normelized input"

pseudo code:
(input[0]*wheigt[0])+(input[1]*wheight[1])+(...))+bias = output hiddenlayer1-node1

Where you are talking about doesn't sounds like a proper AI (code who thinks for it self instead of working out a code) or am i wrong?
If not could I see your feed function?

Edited by FMS
text added

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
DynamicRookie
Posted (edited)
11 hours ago, FMS said:

code who thinks for it self instead of working out a code

What do you define by thinking by itself?

About feedback system, it checks a list with an array containing words that can be used to identify the meaning of the sentence that user typed, then, after getting class of the sentence, it calculates an answer by the user responses to questions with that type of class and the word matches of those responses with the actual user input by calculating every word value and choosing the word with the highest amount of matchs, then the class, sentence, and answer get encrypted, and saved in a file.

But, the main point of my AI is not chatting, what i want to do with it is a really original concept, and i don't feel like sharing it yet.

Still, i would like to let you know i learned AU3 Programming not long ago, i work on it as a hobbie, so if you could teach me anything it would be really appreciated, that's in fact why i chose the name Rookie :P

Edited by DynamicRookie

Share this post


Link to post
Share on other sites
FMS
Posted (edited)
Quote

Still, i would like to let you know i learned AU3 Programming not long ago, i work on it as a hobbie, so if you could teach me anything it would be really appreciated, that's in fact why i chose the name Rookie

I'm also not a big AU3 programmer but also I couldn't help you if I don't know what you are doing wrong :D
For this I need to see the code on whish you are having problems whit ;)

Edit:
 

Quote

What do you define by thinking by itself?

In mine case I've a "set of handwritten digits" to test whit and for changing the weights.
Afther all te test are done and the weights found there local minimum you can put "new" handwritten digits so the AI predicts the correct output.
I mean : it's not pre-defined and still get the correct output :)

Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
mortog

I was working on something similar and tackled it as follows:

Trained sentences:

- scrap the input from capital letters, dots, etc. Call the remainder as a function with the remainder as its name, the function will have a bunch of variables attached to it (reply, grammar analysis (see below), etc.)

New sentences:

  • Split input into 3 parts: the original, grammatical analysis, word roots
  • For the grammatical parts, I used treetagger and had it create a file containing the input, grammatical analysis, and root of the words:
ShellExecuteWait("C:\TreeTagger\bin\tag-english.bat", $InputFile & " > " & $OutputFile, @SW_HIDE)
  • build a 2d array of the info in $OutputFile (_DelimFile_To_Array2D)
  • build a loop that uses _ArrayFindAll to check if a specific value of the input matches the trained sentences and build up an array of the results (ideally you should do this for the original input, grammar and root, so you can compare the data).
  • get the highest matching results. For this I used a function I found on these forums, which I edited to suit my needs:
    ;===============================================================================
    ;
    ; FunctionName:     _ArrayMode()
    ; Description:      Returns the most frequently occuring elements in the array
    ; Syntax:           _ArrayMode( $aArray [, $iStart] )
    ; Parameter(s):     $aArray - The ByRef array to find the mode of
    ;                   $iStart - (optional) The first index to check for data, default is 0
    ; Return Value(s):  On success returns a 1D array:
    ;                       [0] = Mode (number of instances of most common data element)
    ;                       [1] = First mode element
    ;                       [2] = Second mode element (with same mode count as first)
    ;                       [n] = Last mode element (with same mode count as first)
    ;                   On failure returns 0 and sets @error
    ; Author(s):        jon8763; modified by PsaltyDS; further modified by Mortog
    ;===============================================================================
    Func _ArrayMode(ByRef $aArray, $iStart = 0)
        ; Get list of unique elements
        Local $aData = _ArrayElements($aArray, $iStart)
        If @error Then Return SetError(@error, 0, 0)
        If $aData[0] = 0 Then Return $aData
    
        ; Setup to use SOH as delimiter
        Local $SOH = Chr(01), $sData = $SOH
    
        ; Setup for number of dimensions
        Local $iBound1 = UBound($aArray) - 1, $Dim2 = False, $iBound2 = 0
        If UBound($aArray, 0) = 2 Then
            $Dim2 = True
            $iBound2 = UBound($aArray, 2) - 1
        EndIf
    
        ; Assemble data string for searching
        For $m = $iStart To $iBound1
            If $Dim2 Then
                ; 2D
                For $n = 0 To $iBound2
                    $sData &= $aArray[$m][$n] & $SOH
                Next
            Else
                ; 1D
                $sData &= $aArray[$m] & $SOH
            EndIf
        Next
    
        ; Check count of each unique element listed in $aData, highest count kept in $aCounts[0]
        Local $aCounts[$aData[0] + 1] = [0], $aRegExp[1]
        For $n = 1 To $aData[0]
            $aRegExp = StringRegExp($sData, $SOH & $aData[$n] & $SOH, 3)
            $aCounts[$n] = UBound($aRegExp)
            If $aCounts[$n] > $aCounts[0] Then $aCounts[0] = $aCounts[$n]
       Next
    
       ;create 2d array with unique numbers and their occurances
       _ArrayDelete($aCounts, 0)
       $o = _ArrayMaxIndex($aCounts)
       _ArrayDelete($aCounts, $o)
       _ArrayInsert($aCounts, 0)
       _ArrayInsert($aCounts, $o +1)
       $k = UBound($aCounts)
       Local $aCounts_2d[$k][2]
       For $i = 1 to $k step +1
       _ArrayInsert($aCounts_2d, $i-1, $aCounts[$i -1] & "|" & $aData[$i -1])
       Next
       _ArrayDelete($aCounts_2d, 0)
       Local $aRET = _ArrayMaxIndex($aCounts_2d,0,0,UBound($aData), 0)
    
        Return $aRET
    EndFunc   ;==>_ArrayMode

     

  • Attach scores to all the values based on their grammatical analysis and start comparing the input to your trained material.

Some additional thoughts you should consider:

Let's assume you have the following trained: how are you doing? and you have the input: how are you doing today? You may consider the input having a total score of 6, being 6 strings. The trained material would have a score of 5, and can figure out whether you'd like your script to remove adjectives, conjunctions and adverbs one by one to see if it gets a match to your trained data.

Even better would be to have different values for different types of words, for examples verbs could have a score of 1, adverbials of time a score of 0.7. This would probably make finding matches more accurate, and easier.

The challenging part though, will be that the word today does imply something: you could be expacted to have had a bad experience yesterday for example. The system described here is also easy for single sentences, but you'll need to build on it considerably if you want it to be able to process multiple sentences (and for example recognize a sentence with multiple questions).

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Pricehacker
      By Pricehacker
      Hello!
      Im wondering if it is possible to 'empty' the variable value to save memory, for example i often use variable as a onetime use thing and would prefer to 'forget' it after is is used
      Maybe it is just as easy as to setting $vVar = Null, but i wanted to make sure that this is the case
    • CarlD
      By CarlD
      Is there a reliable way to ensure that data assigned to variables in a script is overwritten or deleted when the script exits? I have scripts that encrypt/decrypt data and would like to ensure, if possible, that the encryption keys and decrypted data do not stay in memory after the script exits. Thanks.
    • Tersion
      By Tersion
      Here test example of a dummy program with random added controls to the main form:
      If #include <GuiListView.au3> is commented out, then this simple program uses around 3,5 MB of RAM. When #include <GuiListView.au3> NOT commented out - RAM usage is around 13-14 MB.
      How can I reduce memory usage? Even if I'm not using GuiListView.au3 - 3,5 MB quite a bit for a such dummy program!
      I found out that using this DLLCall in main loop:
      DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1) Significantly reduces RAM usage (even with GuiListView.au3 included, from 13-14 MB to 600 KB !!! ) but I'm not sure if it's doesn't have any impact to common workflow of a program...
      So, give me any advice about that, please.
    • OneSolution
      By OneSolution
      Hi guys! I have these checkbox that I'm trying to click on. They have the same inner-text string but a different ID. Sometime there can be as many as 4 checkbox
      with the same string but the ID is always different. I tried a few methods down below but I'm unable to make any real results. Any suggestions or solutions I would
      appreciate it very much.
      <ul><li class="cx-list-item-wrapper" data-day="Aug 2 2018 07:27:37 GMT-0700 (Pacific Daylight Time)"><div class=""><div class="cx-list-item-container"><div class="cx-list-item cx-item-icon-2 pointer-cursor"><div class="cx-item-contents cx-item-time col-md-2"><!-- react-text: 675 -->Morning<!-- /react-text --><!-- react-text: 676 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-1"><!-- react-text: 678 -->OTHER<!-- /react-text --><!-- react-text: 679 -- >&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 681 -->8:30 AM<!-- /react-text --><!-- react-text: 682 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 684 -->10:30 AM<!-- /react-text --><!-- react-text: 685 -->&nbsp;<!-- /react-text -- ></div><div class="cx-item-contents col-md-1"><!-- react-text: 687 -->SRV<!-- /react-text --><!-- react-text: 688 -->&nbsp;<!-- /react-text --></div></div></div><div class="pull-right cx-listitem-chk"><div><input id="cx_checkbox1" class="cx-fa-chk cx-selfschedule-chk" value="on" type="checkbox"><label for="cx_checkbox1"></label></div></div></div></li><li class="cx-list-item-wrapper" data-day="Aug 2 2018 07:27:37 GMT-0700 (Pacific Daylight Time)"><div class=""><div class="cx-list-item-container"><div class="cx-list-item cx-item-icon-2 pointer-cursor"><div class="cx-item-contents cx-item-time col-md-1"><!-- react-text: 698 -- >Morning<!-- /react-text --><!-- react-text: 699 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-1"><!-- react-text: 701 -->OTHER<!-- /react- text --><!-- react-text: 702 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 704 -->8:30 AM<!-- /react-text --><!-- react-text: 705 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 707 -->2:30 PM<!-- /react-text --><!-- react-text: 708 -- >&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-1"><!-- react-text: 710 -->SRV<!-- /react-text --><!-- react-text: 711 -->&nbsp;<!-- /react-text --></div></div></div><div class="pull-right cx-listitem-chk"><div><input id="cx_checkbox2" class="cx-fa-chk cx-selfschedule-chk" value="on" type="checkbox"><label for="cx_checkbox2"></label></div></div></div></li></ul> I tried the _IETagNameGetCollection() but it only check the box but doesn't fire the event! And I'm unable to submit that without a click action.
      Func _Box1() $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.id == "cx_checkbox1" Then $oInput.checked = true Next Sleep(10) ToolTip('box1') EndFunc ;==>_Box1 I also tried click by text.The boxes do get check by a click but the problem with that is it will select every box that has the same string. I'm allowed only to check 1 box selection at a time per day for the submit button to work.  Any preference to select only the second box and bypass the other?
      Func _Morning() For $a In _IETagNameGetCollection($oIE, "div") If StringInStr(_IEPropertyGet($a, "innerText"), "Morning") Then _IEAction($a, "click") EndIf Next Sleep(10) ToolTip('Morning selected') EndFunc ;==>Morning The last method I tried was _IEGetObjById(). It doesn't click or respond to the checkbox.
      Func _Click1() $oChk = _IEGetObjById($oIE, "cx_checkbox1") _IEAction($oChk, 'click') Sleep(20) ToolTip('box1') EndFunc ;==>_Click1  
    • DynamicRookie
      By DynamicRookie
      Hey there!
       
      I was studying about algorithms of machine learning and artificial intelligence inner systems, in specific, i would like to create a similar system like AIML and A.L.I.C.E., but in AU3.

      I can re-create pretty much all the functions in AIML by myself, except for "any (*)", which is really useful for pattern detection.
       
      Example:
       
      How i could re-create it in Au3?

      Any help is really appreciated!
×