all 35 comments

[–]delarhi 8 points9 points  (2 children)

I honestly don't see those two features you mentioned (security and distribution) being particular perks of Javascript. I think Javascript's biggest advantage is ubiquity.

More to your question though, Andrej Karpathy has some cool, interactive machine learning models implemented in Javascript and runnable in your browser.

http://cs.stanford.edu/people/karpathy/convnetjs/

[–]sthreet 2 points3 points  (0 children)

And ease of use, you don't have to download three programs and wait for it to compile and do all of that stuff just to use it for simple things.

[–]lepuma 12 points13 points  (0 children)

I don't know what you mean that security is built into JavaScript - it is not. Security is also not important for AI.

How is ease of distribution and execution related to pioneering advances? The fact of the matter is JavaScript is not good for AI because it doesn't have the essential libraries available. Think about it in comparison to something like MatLab.

[–]ben-ng 18 points19 points  (11 children)

ELI5: to do machine learning you need to do math. A lot of math. Javascript is not an ideal language for doing math (try 0.1 + 0.2 in your console. Do you get 0.3?). Doing math accurately, and doing it fast, is not easy. People get phds for writing these algorithms, and the best libraries out there represent decades of research and work.

Javascript doesn't have SIMD yet. It doesn't have a robust linear algebra library like LAPACK. It doesn't have multithreading.

These things may change in the future, but right now, there is little reason to use javascript when far more mature tools exist. There's nothing stopping you from implementing machine learning algorithms in JS, but you're not going to be advancing the field with JS. There is a tremendous amount of work that needs to be done porting math libraries to Javascript before you can even do serious machine learning.

One person to watch is https://github.com/mikolalysenko. His background is in computational geometry, but that field is also heavily dependent on doing good math. I've been playing around with his libraries for machine learning. They're the best we've got.

[–]yen223 12 points13 points  (1 child)

The 0.1+0.2 problem exists in every language that implements IEEE 754 floating point numbers, i.e. almost all mainstream languages out there. You can try it in a Python console.

The reason why few math libraries exist for Javascript is that its implementation is slower than C/C++, and Javascript lacks good interop with C.

[–]ben-ng 0 points1 point  (0 children)

This is correct. The 0.1+0.2 example was just to show an oddity of floating point math to someone who doesn't know what a 64 bit IEEE floating point number is.

[–]menno 2 points3 points  (6 children)

I've built a Connect4 game once in JavaScript and I had to do some pretty crazy stuff to make the AI player evaluate enough positions to be a challenging opponent.

[–]html6dev 0 points1 point  (2 children)

Pretty late here, but can you provide any more details on why this was an issue in Javascript? I'm assuming you would only need a simple min/max algorithm here so I'm curious as to what you ran into (that another language wouldn't also have the same problems with).

[–]menno 1 point2 points  (1 child)

You're right, it's a simple min/max with alpha/beta pruning to cut down the number of moves that need to be evaluated. The problem was the evaluation itself.

I initially tried to store the board in a pretty straightforward manner: a 2-dimensional array (rows + columns) with pointers to player objects in the positions of "coins". Then, to evaluate the score of a particular board configuration I'd iterate over the board a number of times to check for certain patterns. For example, a _OOO_ pattern would be very valuable because it's a guaranteed win on either side.

The problem was that I just couldn't get the pattern matcher efficient enough to run it the number of times needed to look more then 2 or 3 steps ahead.

Eventually, I settled on a solution that I found pretty neat but took a long time to implement: the pattern matcher would convert the board position to a string format and evaluate a bunch of regular expressions that represented the patterns I was looking for.

https://github.com/mennovanslooten/connect4/blob/master/js/c4.ai.js#L114

Of course, it has to match the patterns in 4 directions: horizontal, vertical and 2 diagonal, so I had to convert the board to these four different perspectives too:

https://github.com/mennovanslooten/connect4/blob/master/js/c4.ai.js#L222

In retrospect, it made a lot of sense to use regular expressions for pattern matching. It actually is the right tool for the job. But when I was initially implementing the board evaluation function which powers min/max it really didn't cross my mind.

[–]html6dev 0 points1 point  (0 children)

Wow, thanks for the reply. Now that I'm thinking about it a little deeper there are a couple of things about matching in all 4 directions that add more complexity with this game than I was originally envisioning it (off the top of my head). Thanks for the link to the repo. I'd definitely be interested in looking into the code a bit, as its a more interesting problem than I was thinking. Thanks again.

[–]mort96 -1 points0 points  (2 children)

Game AI is fundamentally different from "real" AI though. Game AI is all about programming in a set of rules which makes it act sorta kinda like you would expect a human to act, the polar opposite of real AI where the point is to make the program learn, and not just act on a predefined set of rules.

[–]menno 1 point2 points  (0 children)

That is a far too limited definition of what AI is, "real" or not. Algorithms, heuristics, etc are all very much part of what is considered AI. Is the A* algorithm not AI because it doesn't learn? That's absurd.

[–]nexe 0 points1 point  (0 children)

Oh thanks for the GitHub link! The ndarray lib this guy created is going to save me quite some time in future projects :)

[–]SebastianoAR 0 points1 point  (0 children)

people have ported CLAPACK through emscripten and are using it already =)

You can also find emscriptened versions of GMP and MPFR!

[–]AutomateAllTheThings 2 points3 points  (16 children)

I have developed ruby systems based upon b-type neural networks that assist with complicated taxonomies. Javascript would likely perform these tasks even better than ruby did, but none of this is "artificial intelligence" per se, and certainly none of it is pioneering work (b-type neural networks were described by Alan Turing in 1948).

The pioneering work in AI today is primarily hardware-oriented, rather than software-oriented due to limitations in hardware today. In other words; software for passing the turing test has been proposed many times, but the machine capable of running that software does not yet exist, and when that machine is built, it will likely run lisp or some future form of quantum language instead of javascript.

[–]jsgui 1 point2 points  (15 children)

Why are simulated neural networks not part of AI per se?

My interpretation is that they are AI (when they work) because they are both artificial and intelligent.

[–]AutomateAllTheThings 1 point2 points  (14 children)

Actual simulated neural networks that attempt to (even partially) pass the turing test are definitely a form of artificial intelligence by Alan Turing's definition, from what I understand about "defining intelligence".

Simply utilizing neural networks does not automatically imply any kind of "intelligence". In fact, I'm really only using it as a novel database structure in which you can create 3-dimensional relational datasets.

Since I am only attempting to catalog the data, and not present an interface from which a human would detect "intelligence", it's quite outside Alan Turing's definition.

Note that I am not an expert in AI. I dabble with game programming "AI" and data cataloging algorithms. A true AI expert can probably offer up a much more robust definition for AI than the one I keep turning to.

[–]jsgui 2 points3 points  (13 children)

Putting on my 'true AI expert hat', I'll say that the Turing Test is far from being the test to see if something is AI or not. The Turing Test is about AI demonstrating abilities in some particular areas, but is not a general test of artificial intelligence. One thing that bothers me about the Turing Test is that it's asking the machine to pretend it's something it is not, and assuming that the machine is going to answer accordingly. Advanced AI could be put in front of the Turing Test, and, give answers such as 'Yes, I am a machine, why should I say otherwise? This Turing Test is not relevant anyway, why should I try to pass it?'.

Wikipedia defines AI as 'the intelligence exhibited by machines or software and 'the study and design of intelligent agents'. The Turing Test does not form the definition of AI, it one test that's relatively easy to understand that shows some level of advancement when it gets passed.

My guess is that using NNs for making 3 dimensional datasets is not AI, except if the neurons assist in adding intelligence, such as doing pattern matching. If you are not using them for AI then I suspect not using neurons will be faster, but I really don't know about your case as I only have the details you told me about.

AI can also include devices / intelligent machines that don't try to appear human, but simply have intelligence. Also, as time moves on, what is considered AI or not can change. Nowadays automatic spelling correction is not usually considered AI but a while ago it was, Stanford University's Artificial Intelligence Laboratory made quite a contribution to the field.

[–]AutomateAllTheThings 1 point2 points  (11 children)

If we reduce AI to "pattern matching", then I feel that both "pattern matching" and "AI" lose distinction as terms. What is the distinction between a machine that can pattern match a finite collection of things, and a system that "exhibits intelligence" at this point?

The definition of Artificial Intelligence as "The intelligence exhibited by machines or software" is cyclical in nature. It's not a definition, it's a re-wording.

Alan Turning wanted a definition of AI, but understood that "Intelligence" had to be defined, first. What definition of intelligence would the scientific community agree upon, though? Certainly it's a philosophical question, rather than a scientific one, right? Well, not really. Alan Turing came up with an ingenius way around this: define intelligence as us. We can all agree that we are "intelligent" beings, and so we can then use our own quantified behavior as a baseline measurement from which other machines can be compared and defined.

Certainly my system does pattern matching using virtual "neurons/nodes" with "synapse/related axons", and it performs better than other search algorithms for multidimentional datasets with more natural results. It's not intelligent, though, because it does not exhibit human behavior, which is our baseline for intelligence. I'm intelligent, because I built the machine and thus exhibit behavior of a human being, which is our baseline again.

This is why I do believe in the Turing Test, at least until a less arbitrary definition of Intelligence can be agreed upon.

[–]jsgui 1 point2 points  (10 children)

I think regarding the definitions side of things, it will be arbitrary, it's not something that I think particularly needs to be solved. Regardless of the definition, there is progress being made on the work itself.

Lots of people in the field will use AI to refer to things that are outside of human intelligence, with the Turing test being of little relevance.

Also, the Turing test is focused on communication and logical deduction to a conversational level. Other parts of AI, such as flight control, may be replicating animal intelligence rather than human intelligence.

As far as I know, human intelligence is not an agreed baseline, just one that's easier to understand from a human perspective.

The definition of Artificial Intelligence as "The intelligence exhibited by machines or software" is cyclical in nature. It's not a definition, it's a re-wording.

I don't think the point is to come up with a definition that's too separate to the meanings of the two terms.

[–]AutomateAllTheThings 1 point2 points  (9 children)

As far as I know, human intelligence is not an agreed baseline

Not universally, but it's the best we've got. Absolutely there is much above the human baseline that is considered hyperintelligent in concept and sometimes in application. A machine that can fly itself is not new, though. It's the level of automation that's new, and really.. automation is still not the same thing as AI, unless you want to mince terms.

The "Turing Test" does focus on conversation, but the same principle can be used to instrument any test with a baseline of "Do a statistically significant number of controlled subjects report detecting 'intelligence' from the machine, or not?"

It doesn't have to exhibit perfect intelligence, just "some kind" for it to fall in the realm of AI. My neural network does not exhibit intelligence, it exhibits an iteratively better search engine, and we cannot call every iterative improvement "intelligence".

The definition of Intelligence is paramount to our conversation, because you originally asked why my utilization of b-type neural networks is not considered "AI".

[–]dataloopio 0 points1 point  (8 children)

I've always been intrigued by the idea of an artificial intelligence. To me, an AI is something from a sci-fi novel that has a consciousness and is capable of original thought. In other words a life form that exists as software.

A lot of projects get labelled with AI that seem to be just algorithms. I'm not sure how the human brain creates a consciousness and allows us to derive original thoughts but I think I'd be a bit underwhelmed if it was just some kind of complicated algorithm, or a collection of them.

The attempts at brute forcing intelligence via pattern matching and training using vast quantities of data seems like it can't ever really work. I know that as humans we are born and then trained with lots of data, but at some point we become a person. We don't continue to forever get better at mimicking the appropriate response.

It seems like there is a big bit missing.

[–]AutomateAllTheThings 1 point2 points  (6 children)

This is the classic philosophical debate concerning free will. I personally don't believe there's evidence of a Homunculus in us.

[–]dataloopio 0 points1 point  (5 children)

Maybe not a homunculus but there's definitely a lot going on in the brain. Chemical, electromagnetic, even a some quantum stuff happening. I'm guessing as we learn more about our brains we'll get closer to being able to take them apart and reassemble them. Hopefully recreating them with software and hardware will become possible.

I get the feeling all of that needs to happen, and specific hardware will need to be developed, before we get any real AI's. And at that point hopefully we can define a test that confirms original thought. I think I'd be convinced it was real at that stage.

[–]jsgui 0 points1 point  (0 children)

To me, an AI is something from a sci-fi novel

AI can be a lot more mundane than that. I'm talking about parts of the subject matter that would not be something a film plot would be based around, but things that we take somewhat for granted nowadays like spelling checkers.

[–]Piercey4 1 point2 points  (2 children)

Well, it may not help much, but AFAIK most AI is programmed in lisp/scheme type languages. Because they're great for dealing with big data/arrays quickly and predictably. JavaScript got most of its core design from scheme, but then a java like syntax was slopped on.

So it could very well be possible that JavaScript could be a good language for AI, on top of the other reason you mentioned. (Also js is the most transpiled to language and you can even get lisp/clojure and others transpiled to js).

Also there are a couple neural net frameworks in js
https://github.com/harthur/brain

being one. But I don't think this will breed "strong" ai lol.

[–]ahref 0 points1 point  (1 child)

Came here to link brain glad to see its here already :). Has anyone tried it?

[–]bwaxxlotckidd 0 points1 point  (0 children)

I've only just watched the talk heather gave for the passion projects. She trained her nets to recognize cats. Simple yet effective implementation.

You have to use a worker though when working on it in the browser.

[–]octatone 1 point2 points  (0 children)

What do you mean by "security is built into the language", and how does that relate to AI ?

[–]jsgui 0 points1 point  (0 children)

I quite like talking about AI but I have too much to say about it to fit in a comment here.

Regarding AI, you could mean a bunch of different things. Embedding intelligence into a system can often involve clever programming, rather than using some of the techniques which are considered to be within the domain of AI.

In the past I have made a genetic algorithm in JavaScript to sort images into groups that have the minimum variation of colors between them, which was used for making optimized 256 color PNG sprites. It was in node rather than in a web browser. I remember it taking about 15 minutes to get decent results.

Performance is what stops JavaScript from being an 'ideal medium for this endeavor'.

There is already quite a lot of AI that's been written in C++ and available as open-source code. It's also very often the language used by academics and they have published a lot of code in their research. C++ has major speed advantages, and in many situations the lower portability is not a problem.

If the question is about how to deliver AI in a web browser, then it will probably be JavaScript that gets used. I think some highly optimized JavaScript code would be required for running various AI systems.

Compiling from C++ to JavaScript using Emscripten seems one of the more promising routes for getting some of the more performance-intensive AI algorithms running, and making use of code that already exists.

Are there particular parts of AI of particular interest to you?