Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    Messing around with Brain.js

    General Discussion
    3
    14
    327
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jeffreyrb03-gmail
      JaecadeJnight Mod Helper last edited by

      Brain.js is really interesting for machine learning, it’s a JS library that allows you to do stuff with AI right in the browser! It takes up so much time to load though, but it’s worth it to get these results:
      772b483e-6b26-4cb3-82f9-e63626f3978f-image.png

      It barely knows English but does well with the training data I give it somewhat. I really like it though but I know the more training data I give it, the harder it’ll be for me to actually use it and run it (as it’ll take forever to load). I’m considering using the NodeJS version, making an API, and a front-end chatting interface that just sends requests to that API and all. With the NodeJS version, I think it might be able to use more processing power as it’s on the cloud.

      Here’s the training data I gave it so far (I gave credit to my sources in order to be ethical):

       const tData = [
        // I made the next three strings
        'Hi, how are you doing today?', 
        'I\'m doing well, how are you?', 
        'John Cena said to never give up!',
        // https://en.wikipedia.org/wiki/Pizza
        'Pizza is an Italian dish that consists of a flat base of leavened wheat-based dough topped with tomato, cheese, and other ingredients, baked at a high temperature, usually in a wood-fired oven.',
        // made by me
        'Notch is the guy who made Minecraft!! He is awesome!!',
        // https://en.wikipedia.org/wiki/Hatsune_Miku (modified by me)
        'Hatsune Miku is a 16 year old Vocaloid girl with long blue hair.',
        // http://www.creatingmycambridge.com/history-stories/newtons-apple-tree/ (modified by me)
        'Isaac Newton was sitting under an apple tree, thinking about the mysterious universe when suddenly an apple hit him on the head lol',
        // https://simple.wikipedia.org/wiki/Apple_pie
        'An apple pie is a common pie or tart filled with apples. Sometimes it has whipped cream or ice cream on top.',
        // https://tatoeba.org/en/sentences/show/10098194
        'I\'d rather live in a world full of secrets than one so small that I\'m able to understand it.',
        // https://en.wikipedia.org/wiki/Ireland
        'Ireland is an island in the North Atlantic Ocean, in Northwestern Europe. It is separated from Great Britain to its east by the North Channel, the Irish Sea, and St George\'s Channel. Ireland is the second-largest island of the British Isles, the third-largest in Europe, and the twentieth-largest in the world.'
      ];
      

      I find that for good training data, I can always just use Wikipedia and Creative-Commons licensed internet stuff. I mean ChatGPT did that too so it’s not a bad thing ig. It’s also a good (but time consuming) option to make your own training data.

      #LLJW
      <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

      jeffreyrb03-gmail 2 Replies Last reply Reply Quote 0
      • jeffreyrb03-gmail
        JaecadeJnight Mod Helper @jeffreyrb03-gmail last edited by

        @jeffreyrb03-gmail Update: LOLOLOLLOLLOLOLLOL
        f9e8f9b0-7a74-4e80-9bc3-bda49f4016e4-image.png

        'Greland is an island is an island is an island …"

        I think I need to give it more iterations and/or more training data. I genuinely wonder how it got stuck there. I know it meant “secrets” by heecrets, and “Ireland” by Greland, since my training data used those two things, but just “is an island” repeating lol. I wish I could test this faster and see what’s up.

        #LLJW
        <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

        1 Reply Last reply Reply Quote 0
        • jeffreyrb03-gmail
          JaecadeJnight Mod Helper @jeffreyrb03-gmail last edited by

          @jeffreyrb03-gmail now its weirdly hallucinating because I trained it with Hatsune Miku being 16 years old (and some new stuff):
          22f70ce4-2ab4-490d-ba4b-df10bdf71619-image.png

          #LLJW
          <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

          mod.squadacademy 1 Reply Last reply Reply Quote 0
          • mod.squadacademy
            Mod. Squad Trainer @jeffreyrb03-gmail last edited by

            @jeffreyrb03-gmail Did you know Gandi IDE has something similar to this? Instead of JavaScript though, it generates python, which can be turned into blocks.

            jeffreyrb03-gmail 1 Reply Last reply Reply Quote 1
            • jeffreyrb03-gmail
              JaecadeJnight Mod Helper @mod.squadacademy last edited by

              @mod-squadacademy For the python, what NLP/ML library is used in the generated code? Also i got a funny update:
              e002ca88-3145-4a90-bbff-d0b531d124c9-image.png

              #LLJW
              <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

              mod.squadacademy 1 Reply Last reply Reply Quote 0
              • mod.squadacademy
                Mod. Squad Trainer @jeffreyrb03-gmail last edited by

                @jeffreyrb03-gmail Not entirely sure. I do know that you can tell it what you want, and it will generate the python for you.

                The annoying thing about Gandi IDE’s extensions is that there’s no way that I know of to get much information on how they work.

                jeffreyrb03-gmail 1 Reply Last reply Reply Quote 1
                • jeffreyrb03-gmail
                  JaecadeJnight Mod Helper @mod.squadacademy last edited by

                  @mod-squadacademy In Python, you’ll know what libraries are used by looking at the top of a document,
                  for example “import math” is used so you can use math stuff:

                  import math
                  
                  radius = float(input("Enter the radius: "))
                  area = math.pi * radius ** 2
                  print(f"Area: {area:.2f}, Square root of area: {math.sqrt(area):.2f}")
                  
                  

                  python needs a module/library for everything.

                  For extensions in Gandi IDE, have you tried looking at their documentation/source code? Knowing a lot of JS can help

                  #LLJW
                  <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                  mod.squadacademy 1 Reply Last reply Reply Quote 0
                  • mod.squadacademy
                    Mod. Squad Trainer @jeffreyrb03-gmail last edited by

                    @jeffreyrb03-gmail f3d5a3e9-fcff-4675-aa4e-8b56fd97d933-image.png
                    f817413e-b24d-4fdd-a803-ff4d3fadae42-image.png

                    jeffreyrb03-gmail 2 Replies Last reply Reply Quote 1
                    • jeffreyrb03-gmail
                      JaecadeJnight Mod Helper @mod.squadacademy last edited by

                      @mod-squadacademy ah ok

                      #LLJW
                      <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                      1 Reply Last reply Reply Quote 0
                      • jeffreyrb03-gmail
                        JaecadeJnight Mod Helper @mod.squadacademy last edited by

                        @mod-squadacademy my AI just called me a “cood”, heres the full message:
                        AI: Na a cout B C N R S T c Xeean, purrlentime are you doing tods?A cood.

                        #LLJW
                        <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                        mod.squadacademy 1 Reply Last reply Reply Quote 0
                        • mod.squadacademy
                          Mod. Squad Trainer @jeffreyrb03-gmail last edited by

                          @jeffreyrb03-gmail Given everything else it said, there’s no way of knowing if it actually called you that.

                          jeffreyrb03-gmail 1 Reply Last reply Reply Quote 1
                          • jeffreyrb03-gmail
                            JaecadeJnight Mod Helper @mod.squadacademy last edited by

                            @mod-squadacademy Prolly lol. I’m trying to fix this thing and it’s so hard to debug. Then one change makes it start to spit more gibberish out

                            #LLJW
                            <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                            Tyller_ 1 Reply Last reply Reply Quote 0
                            • Tyller_
                              Tyller_ Best Forum Helpers @jeffreyrb03-gmail last edited by

                              @jeffreyrb03-gmail how much training data are you using? I might try brain js for some stuff if it isn’t that computationally heavy

                              <div component="post/signature" data-uid="255" class="post-signature">Check out my chat room project so you ppl can not use forums as chat rooms! https://play.creaticode.com/projects/66f2e1dcd1be43d82b886fbd?version=1 <p dir="auto">
                              </div>

                              jeffreyrb03-gmail 1 Reply Last reply Reply Quote 0
                              • jeffreyrb03-gmail
                                JaecadeJnight Mod Helper @Tyller_ last edited by

                                @tyller_ It doesnt use GPU acceleration like TensorFlow so it kinda sucks on that part as you have to make up methods to make it go faster and all that are kinda annoying.

                                For training data, it’s just a lot of sentences and all on random topics from wikipedia

                                #LLJW
                                <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post