mlc-ai / web-llm

High-performance In-browser LLM Inference Engine
https://webllm.mlc.ai
Apache License 2.0
12.24k stars 774 forks source link

[Announcement] Breaking changes regarding conversation template #344

Closed CharlieFRuan closed 1 month ago

CharlieFRuan commented 5 months ago

Hi community, we recently updated our models' mlc-chat-config.json on hugging face to use the latest conversation template. The goal is to make templates more lightweight, hence not requiring an npm bump whenever we support a new model (credit to @rickzx).

If you are not using npm ^0.2.29, you might encounter an issue complaining about an unrecognized conversation template, which can be solved by updating the web-llm npm.

We apologize for the breaking changes. It is possible that we would introduce other breaking changes this week in preparation for a new release of WebLLM.

After the new release (in ~1 week), things should stabilize and we will try our best to mitigate such breaking changes (i.e. not requiring updates of npm). We will also introduce wasm versioning so that npm version can pair with wasm version.

Thank you for your understanding!

flatsiedatsie commented 5 months ago

A quick fix is to make a small modification to the worker:

function getConversation(conv_template, conv_config) {
    console.error("web_llm_worker: in getConversation. conv_template: ", conv_template);
    if(typeof conv_template == 'object' && typeof conv_template.name == 'string'){
        console.log("web_llm_worker: setting conv_template to conv_template.name");
        conv_template = conv_template.name;
    }
    if (conv_template == "llama-2") return new Conversation(Object.assign({