rahuldshetty / llm.js

Run Large-Language Models (LLMs) 🚀 directly in your browser!

Home Page:https://rahuldshetty.github.io/llm.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

llm.js logo

no-languages commit-activity stars

LLM.js

Run Large-Language Models (LLMs) 🚀 directly in your browser!

Sample

Example projects🌐✨: Live Demo

Learn More: Documentation

Models Supported:

New models/formats coming soon

Installation

Download and extract the latest release of the llm.js package to your web application📦💻.

Quick Start

// Import LLM app
import {LLM} from "llm.js/llm.js";

// State variable to track model load status
var model_loaded = false;

// Initial Prompt
var initial_prompt = "def fibonacci(n):"

// Callback functions
const on_loaded = () => { 
    model_loaded = true; 
}
const write_result = (text) => { document.getElementById('result').innerText += text + "\n" }
const run_complete = () => {}

// Configure LLM app
const app = new LLM(
     // Type of Model
    'STARCODER',    

    // Model URL
    'https://huggingface.co/rahuldshetty/ggml.js/resolve/main/starcoder.bin', 

    // Model Load callback function
    on_loaded,          

    // Model Result callback function
    write_result,       

     // On Model completion callback function
    run_complete       
);

// Download & Load Model GGML bin file
app.load_worker();

// Trigger model once its loaded
const checkInterval = setInterval(timer, 5000);

function timer() {
    if(model_loaded){
            app.run({
            prompt: initial_prompt,
            top_k: 1
        });
        clearInterval(checkInterval);
    } else{
        console.log('Waiting...')
    }
}

About

Run Large-Language Models (LLMs) 🚀 directly in your browser!

https://rahuldshetty.github.io/llm.js/

License:Apache License 2.0


Languages

Language:JavaScript 91.2%Language:Shell 8.8%