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.
If you want to learn how to install and use BELA, you can follow the tutorial we provide.
You can install BELA using npm with this command.
npm install @soteen/belaHere's a quick setup to start training your own AI model with BELA.
-
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 }
-
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" } ]
-
Use the code examples:
After installing, creating configurations, and creating datasets. You can run the following codes.3.1. Import
@soteen/belato 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:
- Asynchronous
async function main() { /** No auto-increment */ await model.save("model.belamodel", { password: password }); /** With auto-increment */ await model.save("model", { password: password }); } await main();
- Synchronous
/** No auto-increment */ model.saveSync("model.belamodel", { password: password }); /** With auto-increment */ model.saveSync("model", { password: password });
3.5. Load the trained model:
- Asynchronous
async function main() { /** No auto-increment */ await model.load("model.belamodel", { password: password }); /** With auto-increment */ await model.load("model", { password: password }); } await main();
- Synchronous
/** No auto-increment */ model.loadSync("model.belamodel", { password: password }); /** With auto-increment */ model.loadSync("model", { password: password });
3.6. Move model to new/other file:
- Asynchronous
async function main() { /** No auto-increment */ await model.move("old-model.belamodel", { password: oldPassword }, "new-model.belamodel", { password: newPassword }); /** With auto-increment */ await model.move("old-model", { password: oldPassword }, "new-model", { password: newPassword }); } await main();
- Synchronous
/** No auto-increment */ model.moveSync("old-model.belamodel", { password: oldPassword }, "new-model.belamodel", { password: newPassword }); /** With auto-increment */ model.moveSync("old-model", { password: oldPassword }, "new-model", { password: newPassword });
3.7. Read the contents of the
.belamodelfile:- Asynchronous
async function main() { /** No auto-increment */ console.log(await model.read("model.belamodel", { password: password })); /** With auto-increment */ console.log(await model.read("model", { password: password })); } await main();
- Synchronous
/** No auto-increment */ console.log(model.readSync("model.belamodel", { password: password })); /** With auto-increment */ console.log(model.readSync("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);
- Asynchronous
Caution
We recommend that you store your configuration in a JSON file and your model password in a .env file.
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.
If you haven't contributed yet, you should read how to contribute to this project.
This project has several roadmaps that we have achieved and have not achieved.
- Compatible with CommonJS and ES Modules.
- Introducing the
move()feature. - Introducing the
read()feature. - Introducing the
fineTune()feature. - Introducing the security of the
.belamodelfeature.
And others...
