Star on GitHub
RELEASE v1.2.4 • 16 MODULAR CLASSES • NEAR-ZERO DEPENDENCIES

High-Performance JS Language Model & NLP Suite

Empower your Node.js and browser applications with real-time text generation, n-gram probability distributions, self-attention heatmaps, and RAG fact injection.

Try Live Playground View Quickstart
Live Demo

Interactive LM Training & Text Generation

Train a model live in your browser and experiment with softmax temperature and nucleus (top-p) sampling.

Temperature: 0.8
Top-P (Nucleus Sampling): 0.9
Generated Continuation
Click 'Train Model & Generate Continuation' to execute live...
⚡ Powered by GrokJS v1.2.4 Engine
Browser Studio

Document Trainer & Model Checkpoints

Train models directly in your browser by uploading text files, export checkpoints to JSON, or restore previously saved models.

📂 1. Upload & Train Documents

Select or drop .txt, .md, .json, or .csv files to train the in-browser LM:

📄
Drag & drop text documents here
or click to browse from device
💾 2. Save & Reload Checkpoints
Current Model State:
0
Vocabulary Tokens
0
Documents Processed
🤖 3. Live Checkpoint Inference & Autocomplete Widget
Active: Pre-trained Tech Model
Start typing to generate predictions...
// 1. Load GrokJS UMD bundle
const { LanguageModel, FormAutocompleteEngine } = GrokJS;
const lm = new LanguageModel();

// 2. Fetch and import exported JSON checkpoint
fetch('grokjs_model_checkpoint.json')
  .then(res => res.json())
  .then(checkpoint => {
    lm.importState(checkpoint);
    
    // 3. Attach self-learning autocomplete to DOM forms
    FormAutocompleteEngine.inject({ model: lm });
  });
Visualization

Self-Attention Heatmap Matrix

Visualize query-key focus weights across token sequences in real time.

RAG Suite

Fact Server & Prompt Context Injection

Retrieve relevant key-value facts and augment language model prompts automatically.

Augmented Prompt Output
Click button to run RAG prompt augmentation...
Advanced Feature

Self-Learning Webpage Autocomplete Injection

Inject an AI autocomplete engine into ANY webpage (Gmail, GitHub, Notion, Reddit, Twitter, Google Docs). It automatically trains as you type into inputs and saves learned vocabulary to localStorage.

01

Open DevTools

Press F12 or Ctrl+Shift+I on any webpage and select the Console tab.

02

Copy Snippet

Click the Copy Snippet button below to copy the one-liner injection script to your clipboard.

03

Paste & Run

Paste (Ctrl+V) into the Console and press Enter to activate the engine.

04

Auto-Train

Start typing into form fields. Press Tab or to accept completions!

browser-console-injection.js
(function(){if(window.__grokjs_autocomplete)return console.log("GrokJS Autocomplete active.");function init(){if(window.GrokJS){window.__grokjs_autocomplete=window.GrokJS.FormAutocompleteEngine.inject({showSetup:true});console.log("%cGrokJS Self-Learning Autocomplete Injected! Press Tab or Right Arrow to accept completions.","color:#38bdf8;font-size:14px;font-weight:bold;");}else{console.error("GrokJS failed to load.");}}if(window.GrokJS){init();}else{const script=document.createElement('script');script.src='https://cdn.jsdelivr.net/npm/@putervision/grokjs@1.2.4/dist/grokjs.bundle.js';script.onload=init;document.head.appendChild(script);}})();
✍️ Test Autocomplete Live Below:
Architecture

16 Production-Grade Modules

LM

LanguageModel & Ngram

Fast N-gram model up to 5-grams with robust JSON state save/load serialization.

IE

InferenceEngine

Greedy, Softmax Temperature, Top-K, Top-P Nucleus sampling, and Beam Search decoding.

AC

FormAutocompleteEngine

Self-learning DOM form autocomplete engine with continuous localStorage persistence.

PD

ProbabilityDistribution

MLE, Laplace (Add-k) smoothing, and Stupid Backoff estimators.

EM

EvaluationMetrics

Perplexity, BLEU (with brevity penalty), ROUGE-L, Precision/Recall/F1, and Accuracy.

FS

FactServer (RAG)

In-memory key-value fact store for context augmentation.

EB

Embedding & Attention

Co-occurrence vector space similarity and 2D self-attention heatmaps.

Quickstart

Node.js & TypeScript Usage

const { LanguageModel, InferenceEngine, FactServer, FormAutocompleteEngine } = require("@putervision/grokjs");

// Initialize and train model
const lm = new LanguageModel();
lm.train("GrokJS v1.2.4 provides 16 modular NLP classes.");

// Text generation with nucleus sampling
const output = InferenceEngine.generate(lm, "GrokJS", 10, {
  temperature: 0.8,
  topP: 0.9,
  repetitionPenalty: 1.2
});

console.log(output);