TNS
VOXPOP
Where are you using WebAssembly?
Wasm promises to let developers build once and run anywhere. Are you using it yet?
At work, for production apps
0%
At work, but not for production apps
0%
I don’t use WebAssembly but expect to when the technology matures
0%
I have no plans to use WebAssembly
0%
No plans and I get mad whenever I see the buzzword
0%
Data / Frontend Development / Software Development

JavaScript Library Lets Devs Add AI Capabilities to Web

Frontend developers can use AI functions such as translation and image generation on webpages with a new JavaScript library.
Mar 20th, 2023 10:32am by
Featued image for: JavaScript Library Lets Devs Add AI Capabilities to Web
Feature image via Shutterstock

AI company Hugging Face has released a new open source JavaScript library that allows frontend and web developers to add machine learning capabilities to webpages and apps.

Traditionally, Python notebooks are the toolkit for data scientists, but for most web and frontend developers, it’s JavaScript. That’s why Hugging Face created its new HuggingFace.js library that will allow developers to leverage the startup’s capabilities on websites and apps.

Until now, adding those functions meant a Python app on the backend that did the work, said Jeff Boudier, head of product and growth at the startup. Using JavaScript, the browser can request machine learning models to serve predictions and obtain answers for a visitor.

“We provide some low code/no code tools, but if you want to dig in a little bit, you still have to whip out some Python notebooks, etc. And that’s the traditional toolkit of data scientists,” Boudier told The New Stack. “But for most developers out there, JavaScript is how you build applications.”

Frontend Development Use Cases Enabled

Hugging Face has more than 150,000 open source machine learning models available on its site, but some of the use cases Hugging Face.js enables include:

  • Language translations
  • Sentiment analysis
  • Summarization
  • Text classification
  • Object detection in images
  • Text-to-image creation

“All of the use cases that today’s companies build within their applications using our models are going to be available on a webpage,” Boudier said. “All these use cases can be implemented directly on a webpage.”

Jeremy Ellis, a developer and a STEM high school teacher, spent time working with the models to demo for his students, which is available online.

“What I was able to do in a week would typically take me about four months,” Ellis shared with The New Stack via Mastodon. “They even changed their model presentation when I showed them what I was having trouble with. They changed an arrayBuffer to a blob, which made showing their text to image model much easier.”

Ellis shared an image he created using the Hugging Face tool (the hug16 entry on his demo page), which converted the text, “A high-resolution image of a puppy named lowrain playing on a beach,” to an image.

A puppy on a beach

AI image courtesy Jeremy Ellis

Obviously, for larger websites, leveraging these models will require more infrastructure support, Boudier explained. Inference Endpoints can be used to deploy in those situations. It allows developers to deploy machine learning models on a fully managed infrastructure.

Hugging Face.js is free to use and there’s no cost for the hub API that connects it, allowing frontend developers to play with the function for free, by leveraging an Inference Endpoint’s API. The company also welcomes community contributions to the .js library, Boudier added.

“It’s just like you would use our website directly, but you’re using it through the Hugging Face.js library when you use the Inference API,” Boudier said. “Again, there is no cost. It’s the same thing that you would do on our websites, but you’re doing it through the Hugging Face.js API.”

Open Source versus Closed Source Machine Learning Models

In addition to its products, Hugging Face supports the open source community, acting as a free repository for all types of AI models. It also offers a sandbox to explore what the models do, along with information about potential bias.

In February, the company announced a partnership with AWS to make it easier to use and train machine learning and artificial intelligence models. As part of that partnership, AWS began offering JumpStart templates that will allow web, frontend and other software developers to deploy models quickly while accessing them through an API.

One thing that makes Hugging Face’s open source options different than, say, ChatGPT or other less open AI APIs, is that developers have more information about potential biases and other details about the models, Boudier emphasized.

“That’s very important, because that means that you can understand what’s going on under the hood, you can inspect it, build upon it, etc.,” he said. “And of course, we have 150,000 Different models to do exactly what you would want to do.”

Group Created with Sketch.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.