JavaScript library to run machine learning models in the browser

Machine Learning


Julian Wikison-Duran has created what he calls the Poor Man’s Machine Learning model for browsers.

“What I really want to do is bring that machine learning to the front end. I don’t think a model needs a billion parameters to allow it to do really cool things, especially on the front end,” he said. “What I tried to do was create a new model that didn’t require a huge amount of parameters or a lot of memory to run. [is] You can do very practical things within your web browser. ”

The result is AsterMind-ELM, an open source machine learning library written in JavaScript rather than a Python library with a JavaScript wrapper. He introduced the open source project at the devmio International JavaScript Conference in Brooklyn last week.

Wikison-Duran, a full-stack software engineer at Ippon Technologies, built AsterMind-ELM, a modular Extreme Learning Machine (ELM) library for JavaScript and TypeScript. He rewrote the Extreme Learning Machine (ELM) network in JavaScript for use by front-end developers.

Understand ELM

ELM is a type of neural network algorithm developed in 2006 by Guang Bin Huang, whose research at Nanyang Technological University in Singapore focuses on neural networks. ELM is used in machine learning and AI. Perform training tasks such as classification, regression, and clustering quickly and efficiently.

But in 2006, researchers were trying to solve the problem of balancing the optimal learning rate for a dataset.

“A lot of people everywhere are asking this question because they don’t want to spend billions of dollars on data centers,” he said.

Huang’s solution was to create a completely random, never-touched hidden layer and ask what would happen if he didn’t train all of it. Does it still work?

“To many engineers, especially those at the time, this sounded like shipping production code without running unit tests. It just seems crazy,” Wikison-Duran says. “What he did was a simple math trick that we all learned in high school. He said, ‘What if we used hidden layers as maps?'”

All magic happens inside hidden layers, he added. It’s like looking around a city and trying to give directions. Buildings are so high that individual streets cannot be seen. But what would happen if we put a grid on top of a city, Wilkison-Duran said?

“suddenly, [it’s] Something like a battleship: So you can say, “Oh, the bank is on the 3rd or 5th corner. Or the park is on the 4th or 3rd corner,” he explained.

“What I came up with was a neural network, and that’s just matrix calculations.”
– Julian Wikison-Duran, creator of AstroMind ELM

This provides developers with a reference that is not and will not be accurate, but it is a map of enough data to know where things are, he said.

Now that you have a map, how do you find a way to get from point A to point B? The answer is the Moore-Penrose inverse function (also known as the pseudoinverse function).

“This is a simple matrix operation that most of us learn in high school, but we didn’t really understand why we were learning it. And I didn’t really understand why we were learning matrix math in high school until about a year ago,” Wilkison-Duran said. “What I came up with was a neural network, and that’s just matrix calculations.”

Think of hidden layers like this: When data is placed in a hidden layer, Wilkison-Duran explained, it acts like ground paper. Astro-Mind ELM uses the output layer as a GPS for hidden layer maps.

“If you pick up a piece of paper and literally mash it up, it’s really hard to tell what’s on the paper right now or even what’s written on it, but when you unfold that paper, all of a sudden it starts to make sense again,” he said.

ELM is used in situations where real-time training speed and computational efficiency are more important than achieving the absolute highest accuracy. Applications include industrial applications where training speed is critical, such as financial forecasting, social media sentiment analysis, real-time control systems, and complex pattern recognition.

AstroMind ELM brings ML to the browser

Unlike regular neural networks, Astro-Mind ELM does not resolve all hidden layers. He said that since it solves only the last layer, memory consumption and all settings are significantly reduced.

“Instead of training billions of parameters, you just train the last layer,” he said.

AstroMind-ELM brings the power of ELM to the browser and makes it available to JavaScript developers.

“I put it in my browser and said, now that it’s in my browser, what can I do?” Wilkison-Duran said. “I took the technology, mathematics, and all the other elements that make up ELM and rewrote it in JavaScript so that the model could be trained instantly and run in the browser without requiring a lot of memory.”

He reiterated that AsterMind-ELM was not written in Python and then wrapped in JavaScript; it was completely rewritten in JavaScript.

AstroMind-ELM is not designed to handle large language models that generate large amounts of text, he added. Instead, he said, it’s a very specialized model that can be created and trained on the fly and chained together like Lego blocks.

“AsterMind brings instant, small, on-device ML to the web,” Wikison-Duran explained in the GitHub repository. “This allows us to ship models that train in milliseconds, predict with microsecond latency, and run entirely in the browser, with no GPUs, servers, or tracking.”

In addition to ELM, the library now includes a kernel ELM.

“Kernel ELM does not use the grid in this case,” he said. “Instead, you use things like landmarks. If you think about your neighborhood and you’re walking there, there’s a tree over there and it’s big and I can recognize it. There’s a mailbox over there. What kernel ELM does is it uses those landmarks to try to figure out where the data is.”

AsterMind ELM Demonstration

He demonstrated training a model live in just 20 sentences. The model then categorized the data into World, Sports, Business, and Science and Technology. I predicted that a certain sentence belonged to science and technology, and I was right. But interestingly, while the sentence was correct when it had a 48% chance of being science and technology, the other choices only ranked 18% and 17%.

“The result is that all the data is categorized into world sports, business, science and technology, and on the column side, all of this becomes a vector,” he said. “Vectors don’t mean anything until you name them. But in this case, they represent sentences. The other thing I want to point out on this slide is that vectors are not large, so the model itself is actually just a JSON file.”

“AsterMind brings instant, small, on-device ML to the web.”
– AstroMind GitHub repository

We also trained a model to recognize your own voice, distinguish between left and right, and demonstrated how to play a game that uses voice commands to control actions.

“This is going to be a game changer, because everyone is saying, ‘Oh, the front end is DEA (Dead on Arrival).’ You can just use LLM to generate it.” [and] You can generate rich, dynamic UIs that can actually do amazing things,” he said. “What we actually want to do as JavaScript developers is [is] Create amazing widgets and create absolutely stunning visuals. ”

He demonstrated training ELM on a 4/4 drum beat, a typical rock drum beat. It generated beats instantly, without waiting for spin-up or backend intervention.

The AstroMind ELM library also allows developers to chain models and run multiple models simultaneously within the browser. He demoed several different models from the library.

“The important thing is that you can build amazing things with this model. You can train it with very little data. You can even use synthetic data for the initial training,” he said.

ELM also requires no data retention. Once training is complete, you can discard the data to free up memory.

As for the context window, he said it can be an issue with LLM, but its limitations are within the memory limits of hidden layers and JavaScript itself.

“We did extensive experimentation with this and were able to get up to 1,000 parameters using web workers and online learning,” he said. “So you can have 1,000 parameters, but it’s in the web worker and you’re streaming the training data so it doesn’t consume all the memory at once.”

What can you build with it?

This repository explains how AstroMind ELM library components such as Kernel ELMS, Online ELM, DeepELM, and Web Worker Offload can be used by developers to create:

  • For example, private on-device classifiers for language, intent, toxicity, spam, etc. that are retrained on user feedback.
  • Real-time retrieval and re-ranking with compact embeddings for search and RAG.
  • Interactive creative tools such as an instantly responsive drum generator and autocomplete.
  • Edge analytics: Regressors/classifiers from data that never leaves the page. and
  • Deep ELM chains that enable powerful pipelines are still small and transparent.

Wilkinson-Duran wants to build a community around open source projects. He said that anyone who wants to participate at this time can make a pull request and they will consider it. One of his desired outcomes is to create an ecosystem of shared weight among developers.

“What I really want is for people to be able to improve on these models, so I’ve made it open source so that anyone can dig in and find ways to make the models even more powerful than what they already have,” he said. “What I’m saying is, it doesn’t take that long. You can feed in whatever data you want and train instantly. No one cares if it doesn’t work right away, because you’re not spending billions of dollars like you would with an LLM. You use what you have and train with what you got.”


group Created with sketch.





Source link