Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whole project with Playground and local model use #6

Open
gitknu opened this issue Dec 21, 2023 · 1 comment
Open

Whole project with Playground and local model use #6

gitknu opened this issue Dec 21, 2023 · 1 comment

Comments

@gitknu
Copy link

gitknu commented Dec 21, 2023

Hello, sorry for stupid question, but can you upload the project with Playground it seelf and the manual how to run model locally, just by picking downloaded GGUF file? I would like to run offline webserver and try running models on isolated machine.

Thank you for understanding and such a great job you`ve done!

@rahuldshetty
Copy link
Owner

Hello @gitknu,

You can find the source code for the playground and other examples over here: https://github.com/rahuldshetty/ggml.js-examples

You just need to provide the relative path to the model file in your local machine.

E.g code:

<script type="module">
        import {LLM} from "../dist/llm.js";

        let submitButton = document.getElementById('submitBtn');
        let outputElement = document.getElementById('output');

        const on_loaded = () => {
            submitButton.disabled = false;
            submitButton.innerText = "Generate";
        }

        const write_result = (line) => {
            outputElement.textContent  += line + "\n";
        }

        const run_model = () => {
            const text = document.getElementById("textInput").value;
            submitButton.innerText = "Running...";
            submitButton.disabled = true;
            outputElement.textContent = ""; // clead old content
            app.run({
                prompt: text,
                max_token_len: 64,
                top_k: 1,
            });
        }

        const run_complete = () => {
            submitButton.innerText = "Generate";
            submitButton.disabled = false;
        }
        
        const app = new LLM(
            'LLAMA',
            '../models/llama2_xs_460m_experimental_evol_instruct.q4_k_m.gguf',  
            on_loaded,
            write_result,
            run_complete
        );
        
        app.load_worker();
        submitButton.addEventListener("click", run_model);

    </script>

This works with local live-server: https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants