Skip to content

AI Engines Configurations

This section outlines the setup requirements for various AI engines, including Tesseract.js, TensorFlow.js, and NLP.js. Each configuration specifies the necessary parameters to enable the models managed by the respective AI engines.

Tesseract.js

Tesseract.js is a JavaScript library that brings the capabilities of the Tesseract OCR engine to the web by compiling it from C to JavaScript using WebAssembly. This enables optical character recognition (OCR) to be performed directly in the browser, facilitating faster text recognition and minimizing the need for server-side processing.

Tesseract.js supports over 100 languages, automatic text orientation, and script detection, making it a versatile tool for extracting text from images and videos in various languages and formats.

Primary Parameters:

ParameterTypeDefault ValueRequiredDescriptionMetal Version
engineStringYesSet to tesseractjs for Tesseract.js^0.1
modelStringengNoLanguage to use for OCR (see Lang Code: Tesseract OCR Data Files)^0.1

Example Configuration:

yaml
ai-engines:
  my-ocr:
    engine: tesseractjs
    model: eng

Output Object:

KeyTypeDescription
blocksArray<Block>An array of text blocks detected in the image.
confidenceNumberThe overall confidence level of the recognized text.
htmlStringThe recognized text formatted as HTML.
linesArray<Line>An array of lines detected in the image.
oemStringOCR engine mode used during OCR processing.
paragraphsArray<Paragraph>An array of paragraphs detected in the image.
psmStringPage segmentation mode used during OCR processing.
symbolsArray<Symbol>An array of individual symbols detected in the image.
textStringThe recognized text from the image.
versionStringThe version of the OCR engine.
wordsArray<Word>An array of individual words detected in the image.

TensorFlow.js

TensorFlow.js is an open-source JavaScript library that allows you to develop machine learning and deep learning models directly in the browser. It is part of the TensorFlow ecosystem and enables running machine learning models, including neural networks, in JavaScript.

Primary Parameters:

ParameterTypeRequiredDescriptionMetal Version
engineStringYesSet to tensorflowjs for TensorFlow.js^0.1
modelStringYesModel to use (see: Models table)^0.1

Models:

Model ValueDescriptionMetal Version
image-classifyTo classify image^0.1

image-classify

Image classification involves identifying and categorizing images into predefined classes.

Example Configuration:

yaml
ai-engines:
  my-image-classifier:
    engine: tensorflowjs
    model: image-classify

Output Object:

json
{
  "class": [
    {
      "className": "screw",
      "probability": 0.6480134725570679
    },
    {
      "className": "acoustic guitar",
      "probability": 0.31899121403694153
    },
    {
      "className": "electric guitar",
      "probability": 0.014988371171057224
    }
  ]
}
KeyTypeDescription
classArrayAn array of classification results
class[].classNameStringThe name of the classified object
class[].probabilityFloatThe probability of the classified object

NLP.js

NLP.js is an open-source JavaScript library for natural language processing (NLP) and natural language understanding (NLU). It provides tools for various NLP tasks such as tokenization, part-of-speech tagging, named entity recognition, and sentiment analysis.

Primary Parameters:

ParameterTypeRequiredDescriptionMetal Version
engineStringYesSet to nlpjs for NLP.js^0.1
modelStringYesModel to use (see: Models table)^0.1

Models:

Model ValueDescriptionMetal Version
sentimentFor sentiment analysis^0.1
lang-guessFor guessing the language^0.1

sentiment

Sentiment analysis determines the sentiment expressed in a given text, typically categorizing sentiments as positive, negative, or neutral. This process is essential for understanding customer feedback, monitoring social media, and analyzing opinions and emotions in various applications.

Optional Parameters:

ParameterTypeDefault ValueRequiredDescriptionMetal Version
langStringenNoDefines the language of the text to be analyzed. For supported languages, see NLP.js Sentiment Analysis Languages.^0.1

Example Configuration:

yaml
ai-engines:
  my-sentiment-analyzer:
    engine: nlpjs
    model: sentiment
    options:
      lang: en

Output Object:

json
{
  "score": 1.125,
  "numWords": 4,
  "numHits": 3,
  "comparative": 0.28125,
  "type": "senticon",
  "language": "en"
}
KeyTypeDescription
scoreFloatThe overall sentiment score
numWordsIntegerThe total number of words analyzed
numHitsIntegerThe number of words that were found in the sentiment lexicon
comparativeFloatThe comparative score, calculated as score/numWords
typeStringThe type of sentiment analysis method used
languageStringThe language of the analyzed text

lang-guess

Language guessing can identify the language of a given text. This feature is useful for applications requiring language detection before processing text, such as multilingual chatbots, content categorization, and automatic language selection. It ensures that the appropriate language models and processing techniques are applied, enhancing the accuracy and relevance of the application's responses.

Optional Parameters:

ParameterTypeDefault ValueRequiredDescriptionMetal Version
acceptStringenNoDefines a list of languages to guess, separated by commas. For supported languages, see NLP.js Language Support.^0.1

Example Configuration:

yaml
ai-engines:
  my-language-guesser:
    engine: nlpjs
    model: guess-lang
    options:
      accept: en,fr

Output Object:

The returned object is an array of guessed languages with their respective scores:

json
[
  {
    "alpha3": "eng",
    "alpha2": "en",
    "language": "English",
    "score": 1
  }
]
KeyTypeDescription
alpha3StringThe three-letter ISO 639-2 code for the language
alpha2StringThe two-letter ISO 639-1 code for the language
languageStringThe name of the language
scoreFloatThe confidence score for the language guess

Released under the GNU v3 License.