Code Monkey home page Code Monkey logo

hellojwilde / energetic-ai Goto Github PK

View Code? Open in Web Editor NEW
33.0 5.0 0.0 36.65 MB

EnergeticAI is TensorFlow.js, optimized for serverless environments, with fast cold-start, small module size, and pre-trained models.

Home Page: https://energeticai.org

License: Apache License 2.0

TypeScript 75.56% JavaScript 17.05% CSS 7.39%
ai artificial-intelligence embeddings embeddings-trained machine-learning sentence-embeddings tensorflow tensorflowjs

energetic-ai's Introduction

EnergeticAI

Run open-source AI in serverless functions, up to 67x faster. Compatible with Tensorflow.js.

EnergeticAI

EnergeticAI is a distribution of TensorFlow.js optimized for serverless functions:

  • small module size (~3 MB vs. 146 MB - 513 MB for stock TensorFlow.js)
  • fast cold-start inference (~50 ms vs. 2000+ ms for stock TensorFlow.js)
  • incredible ease-of-use (pre-trained models for common cases)

It's intended to be a condensed replacement for TensorFlow.js, so you can use it with much existing code and models.

Install

EnergeticAI is available on NPM.

Install the core package, along with any model libraries you want to use (e.g. embeddings):

npm install @energetic-ai/core @energetic-ai/embeddings @energetic-ai/model-embeddings-en

You can see a full list of packages below.

Usage

Here's an example of using the embeddings model:

import { initModel, distance } from "@energetic-ai/embeddings";
import { modelSource } from "@energetic-ai/model-embeddings-en";
(async () => {
  const model = await initModel(modelSource);
  const embeddings = await model.embed(["hello", "world"]);
  console.log(distance(embeddings[0], embeddings[1])));
})();

Packages

This repository contains the following packages:

Package Description
@energetic-ai/core The core EnergeticAI library, comparable to @tensorflow\tfjs-core.
@energetic-ai/classifiers Classifiers model library.
@energetic-ai/embeddings Embeddings model library.
@energetic-ai/model-embeddings-en English embeddings model weights.

See the readmes in the packages directory for more information.

Examples

See the examples directory for examples.

Development

This repository uses Lerna to manage packages, and Vitest to run tests.

License

Apache 2.0, except for dependencies.

Acknowledgements

This project is derived from TensorFlow.js, the Universal Sentence Encoder model library and Universal Sentence Encoder Lite model weights, which are also Apache 2.0 licensed.


energetic-ai's People

Contributors

hellojwilde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

energetic-ai's Issues

Add support for Deno Deploy

Background

There was a fantastic idea from a Redditor about making EnergeticAI run well in Cloudflare Workers, so you can have super fast inference at the edge, without the need to distribute your model weights:

https://www.reddit.com/r/tensorflow/comments/1493uoq/comment/jo6axc9/?utm_source=reddit&utm_medium=web2x&context=3

Goal

This task is to add support for Deno Deploy to EnergeticAI.

Approach

Given that Deno Deploy has even more restrictive bundle limits than AWS Lambda, I suspect the way to do this would be to distribute sharded model weights in Deno KV, and then fetch from that in parallel on function invocation. On paper at least KV values should be colocated with the functions enough that this should be fast.

Add support for Cloudflare Workers

Background

There was a fantastic idea from a Redditor about making EnergeticAI run well in Cloudflare Workers, so you can have super fast inference at the edge, without the need to distribute your model weights:

https://www.reddit.com/r/tensorflow/comments/1493uoq/comment/jo6axc9/?utm_source=reddit&utm_medium=web2x&context=3

Goal

This task is to add support for Cloudflare Workers to EnergeticAI.

Approach

Given that Cloudflare Workers have even more restrictive bundle limits than AWS Lambda, I suspect the way to do this would be to distribute sharded model weights in Cloudflare KV, and then fetch from that in parallel on function invocation. On paper at least KV values should be colocated with the functions enough that this should be fast.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.