Empower your Node.js and browser applications with real-time text generation, n-gram probability distributions, self-attention heatmaps, and RAG fact injection.
Train a model live in your browser and experiment with softmax temperature and nucleus (top-p) sampling.
Train models directly in your browser by uploading text files, export checkpoints to JSON, or restore previously saved models.
Select or drop .txt, .md, .json, or .csv files to train the in-browser LM:
// 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 });
});
Visualize query-key focus weights across token sequences in real time.
Retrieve relevant key-value facts and augment language model prompts automatically.
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.
Press F12 or Ctrl+Shift+I on any webpage and select the Console tab.
Click the Copy Snippet button below to copy the one-liner injection script to your clipboard.
Paste (Ctrl+V) into the Console and press Enter to activate the engine.
Start typing into form fields. Press Tab or → to accept completions!
Fast N-gram model up to 5-grams with robust JSON state save/load serialization.
Greedy, Softmax Temperature, Top-K, Top-P Nucleus sampling, and Beam Search decoding.
Self-learning DOM form autocomplete engine with continuous localStorage persistence.
MLE, Laplace (Add-k) smoothing, and Stupid Backoff estimators.
Perplexity, BLEU (with brevity penalty), ROUGE-L, Precision/Recall/F1, and Accuracy.
In-memory key-value fact store for context augmentation.
Co-occurrence vector space similarity and 2D self-attention heatmaps.
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);