Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@soteen/bela

patamatdeveloper74MIT0.0.4-devTypeScript support: included

This is machine learning using BELA.

machine, learning, bela

readme

Banner

BELA is an AI architecture that represents text using binary, leverages entropy for learning, and two-way prediction to create response.

BELA itself stands for Binary Entropy Learning Architecture.

Tutorials

If you want to learn how to install and use BELA, you can follow the tutorial we provide.

Installation

You can install BELA using npm with this command.

npm install @soteen/bela

Next steps after installation

Here's a quick setup to start training your own AI model with BELA.

  1. Creating a configuration:

    You need a configuration to configure the model you want to create.

     {
       "parameter": {
         "epochs": 5, // Number of training iterations
         "learningRate": 0.05, // Learning rate for optimization
         "nGramOrder": 3, // Context window size for text processing
         "layers": [64, 32, 16] // Neural network layer sizes
       },
       "path": {
         "root": "./", // Base directory
         "model": "./models/", // Model storage path
         "backup": "./backup/" // Backup directory
       },
       "autoIncrement": true, // Automatic upgrade
       "autoDelete": true, // Delete old versions automatically
       "autoDeleteMax": 2 // Number of versions stored, oldest will be deleted
     }
  2. Creating a dataset:

    Before proceeding to the next step, you need to create a dataset as follows.

     [
       { "input": "Hey, how are you?", "output": "I'm fine, thank you?"},
       { "input": "Tell me about the story", "output": "Sure! I'll tell you about the story" }
     ]
  3. Use the code examples:
    After installing, creating configurations, and creating datasets. You can run the following codes.

    3.1. Import @soteen/bela to the project:

     import { BELA } from "@soteen/bela";

    3.2. Initialize BELA with the configuration:

     const model = new BELA(config);

    3.3. Train the model with the dataset:

     model.train(dataset);

    3.4. Save the trained model:

     /** No auto-increment */
     model.save("model.belamodel", {
       password: password
     });
    
     /** With auto-increment */
     model.save("model", {
       password: password
     });

    3.5. Load the trained model:

     /** No auto-increment */
     model.load("model.belamodel", {
       password: password
     });
    
     /** With auto-increment */
     model.load("model", {
       password: password
     });

    3.6. Move model to new/other file:

     /** No auto-increment */
     model.move("old-model.belamodel", {
       password: oldPassword
     },
     "new-model.belamodel", {
       password: newPassword
     });
    
     /** With auto-increment */
     model.move("old-model", {
       password: oldPassword
     },
     "new-model", {
       password: newPassword
     });

    3.7. Read the contents of the .belamodel file:

     /** No auto-increment */
     console.log(model.read("model.belamodel", {
       password: password
     }));
    
     /** With auto-increment */
     console.log(model.read("model", {
       password: password
     }));

    3.8. Make a prediction:

     const predict = model.predict("Say this is example code.", {
       maxLength: 12,
       maxTest: 5,
       logTest: true
     });
    
     console.log(predict);

    [!CAUTION] We recommend that you store your configuration in a JSON file and your model password in a .env file.

Installation Performance

From version to version, BELA has installation differences that we can see in the following table. | Version | Size | Performance | Optimizations performed | |------------|---------|-------------|-------------------------| | v0.0.4-dev | 64.62kB | 5s | Build and minify using esbuild | | v0.0.3-dev | 69.25kB | 4-8s | Deleting .js.map files | | v0.0.2-dev | 83.09kB | 4-8s | Nothing | | v0.0.1-dev | 83.16kB | 4-8s | Nothing |

This data is obtained by extracting the .tgz file from each version, after which its size is obtained through the process of checking the size of its folder. This data does not include the dependencies.

Contribute

If you haven't contributed yet, you should read how to contribute to this project.

Roadmap

This project has several roadmaps that we have achieved and have not achieved.

  • <input checked="" disabled="" type="checkbox"> Compatible with CommonJS and ES Modules.
  • <input checked="" disabled="" type="checkbox"> Introducing the move() feature.
  • <input checked="" disabled="" type="checkbox"> Introducing the read() feature.
  • <input checked="" disabled="" type="checkbox"> Introducing the fineTune() feature.
  • <input checked="" disabled="" type="checkbox"> Introducing the security of the .belamodel feature.
    And others...