Skip to content

Commit fb6d0e8

Browse files
authored
Support RedPajama-Chat-3B-V1 (#99)
1 parent cfd78db commit fb6d0e8

File tree

10 files changed

+201
-120
lines changed

10 files changed

+201
-120
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[submodule "3rdparty/sentencepiece-js"]
2-
path = 3rdparty/sentencepiece-js
3-
url = https://github.com/tqchen/sentencepiece-js
41
[submodule "mlc-llm"]
52
path = mlc-llm
63
url = https://github.com/mlc-ai/mlc-llm
4+
[submodule "3rdparty/tokenizers-cpp"]
5+
path = 3rdparty/tokenizers-cpp
6+
url = https://github.com/mlc-ai/tokenizers-cpp

3rdparty/sentencepiece-js

Lines changed: 0 additions & 1 deletion
This file was deleted.

3rdparty/tokenizers-cpp

Submodule tokenizers-cpp added at a3fd734

mlc-llm

Submodule mlc-llm updated 51 files

scripts/build_site.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cp web/llm_chat.css site/dist/
2323

2424
cp dist/tvmjs_runtime.wasi.js site/dist
2525
cp dist/tvmjs.bundle.js site/dist
26-
cp -r dist/sentencepiece site/dist
26+
cp -r dist/tokenizers-cpp site/dist
2727

2828
if [ -d "$MLC_LLM_HOME/dist/vicuna-v1-7b-q4f32_0/params" ]; then
2929
mkdir -p site/dist/vicuna-v1-7b-q4f32_0

scripts/prep_deps.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ if [[ -z ${TVM_HOME_SET} ]]; then
1515
export TVM_HOME="${TVM_HOME:-3rdparty/tvm}"
1616
fi
1717

18-
export SENTENCEPIECE_JS_HOME="3rdparty/sentencepiece-js"
18+
export TOKENIZERS_CPP_HOME="3rdparty/tokenizers-cpp/web"
1919

2020
mkdir -p dist
2121
cd ${TVM_HOME}/web && make && npm install && npm run bundle && cd -
2222
git submodule update --init --recursive
23-
cd ${SENTENCEPIECE_JS_HOME} && npm install && npm run build && cd -
23+
cd ${TOKENIZERS_CPP_HOME} && npm install && npm run build && cd -
2424
git submodule update --init --recursive
25-
rm -rf dist/sentencepiece
26-
cp -r ${SENTENCEPIECE_JS_HOME}/dist dist/sentencepiece
25+
rm -rf dist/tokenizers-cpp
26+
cp -r ${TOKENIZERS_CPP_HOME}/dist dist/tokenizers-cpp
2727

2828
echo "Exporting tvmjs runtime dist files"
2929
python -c "from tvm.contrib import tvmjs; tvmjs.export_runtime(\"dist\")"

site/_includes/llm_chat.html

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,39 @@
33
</script>
44

55
<script type="module">
6-
async function getTokenizer(url) {
7-
const mod = await import("./dist/sentencepiece/index.js");
8-
return await mod.sentencePieceProcessor(url);
6+
import { Tokenizer } from './dist/tokenizers-cpp/index.js';
7+
8+
async function tokenizerFromJSON(jsonArrayBuffer) {
9+
return await Tokenizer.fromJSON(jsonArrayBuffer);
10+
}
11+
async function tokenizerFromSentencePiece(modelBuffer) {
12+
return await Tokenizer.fromSentencePiece(modelBuffer);
913
}
10-
tvmjsGlobalEnv.sentencePieceProcessor = getTokenizer;
14+
tvmjsGlobalEnv.tokenizerFromJSON = tokenizerFromJSON;
15+
tvmjsGlobalEnv.tokenizerFromSentencePiece = tokenizerFromSentencePiece;
16+
1117
</script>
1218
<script>
1319
function handleChatUIInputEnter(event) {
1420
if (event.keyCode === 13) {
1521
tvmjsGlobalEnv.asyncOnGenerate();
1622
}
1723
}
18-
async function getTokenizer(url) {
19-
const mod = await import("./dist/sentencepiece/index.js");
20-
return await mod.sentencePieceProcessor(url);
21-
}
22-
tvmjsGlobalEnv.sentencePieceProcessor = getTokenizer;
2324
</script>
24-
25+
<!--
2526
<form>
2627
<select id="model-name">
2728
<option selected="selected">vicuna-v1-7b-q4f32_0</option>
28-
<!-- <option >dolly-v1-3b-q4f32_0</option> -->
29+
<option >RedPajama-INCITE-Chat-3B-v1-q4f32_0</option>
2930
</select>
30-
</form>
31+
</form> -->
32+
33+
<label>Pick a pre-compiled model or load your own model's mlc-chat-config.json:
34+
<input list="model-names" name="model" id="model"/></label>
35+
<datalist id="model-names">
36+
<option value="vicuna-v1-7b-q4f32_0" ></option>
37+
<option value="RedPajama-INCITE-Chat-3B-v1-q4f32_0"></option>
38+
</datalist>
3139

3240
<script src="dist/llm_chat.js"></script>
3341
<link href="dist/llm_chat.css" rel="stylesheet" type="text/css"/>

web/global_config.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"url_dict":{
3-
"vicuna-v1-7b-q4f32_0": "https://huggingface.co/hongyij/web-llm-test-model/resolve/main/model_config.json"
3+
"vicuna-v1-7b-q4f32_0": "https://huggingface.co/hongyij/mlc-llm-vicuna-7b-v1/resolve/new_config/model_config.json",
4+
"RedPajama-INCITE-Chat-3B-v1-q4f32_0": "https://huggingface.co/hongyij/mlc-llm-redpajama/resolve/main/mlc-llm-config.json"
45
},
56
"model_lib_map":{
6-
"vicuna-v1-7b-q4f32_0": "https://raw.githubusercontent.com/jinhongyii/llm-lib-debug/main/vicuna-v1-7b-q4f32_0-webgpu.wasm"
7+
"vicuna-v1-7b-q4f32_0": "https://raw.githubusercontent.com/jinhongyii/llm-lib-debug/new_config/vicuna-v1-7b-q4f32_0-webgpu.wasm",
8+
"RedPajama-INCITE-Chat-3B-v1-q4f32_0": "https://raw.githubusercontent.com/jinhongyii/llm-lib-debug/new_config/RedPajama-INCITE-Chat-3B-v1-q4f32_0-webgpu.wasm"
79
}
810
}

web/llm_chat.html

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,39 @@
33
</script>
44

55
<script type="module">
6-
async function getTokenizer(url) {
7-
const mod = await import("./dist/sentencepiece/index.js");
8-
return await mod.sentencePieceProcessor(url);
6+
import { Tokenizer } from './dist/tokenizers-cpp/index.js';
7+
8+
async function tokenizerFromJSON(jsonArrayBuffer) {
9+
return await Tokenizer.fromJSON(jsonArrayBuffer);
10+
}
11+
async function tokenizerFromSentencePiece(modelBuffer) {
12+
return await Tokenizer.fromSentencePiece(modelBuffer);
913
}
10-
tvmjsGlobalEnv.sentencePieceProcessor = getTokenizer;
14+
tvmjsGlobalEnv.tokenizerFromJSON = tokenizerFromJSON;
15+
tvmjsGlobalEnv.tokenizerFromSentencePiece = tokenizerFromSentencePiece;
16+
1117
</script>
1218
<script>
1319
function handleChatUIInputEnter(event) {
1420
if (event.keyCode === 13) {
1521
tvmjsGlobalEnv.asyncOnGenerate();
1622
}
1723
}
18-
async function getTokenizer(url) {
19-
const mod = await import("./dist/sentencepiece/index.js");
20-
return await mod.sentencePieceProcessor(url);
21-
}
22-
tvmjsGlobalEnv.sentencePieceProcessor = getTokenizer;
2324
</script>
24-
25+
<!--
2526
<form>
2627
<select id="model-name">
2728
<option selected="selected">vicuna-v1-7b-q4f32_0</option>
28-
<!-- <option >dolly-v1-3b-q4f32_0</option> -->
29+
<option >RedPajama-INCITE-Chat-3B-v1-q4f32_0</option>
2930
</select>
30-
</form>
31+
</form> -->
32+
33+
<label>Pick a pre-compiled model or load your own model's mlc-chat-config.json:
34+
<input list="model-names" name="model" id="model"/></label>
35+
<datalist id="model-names">
36+
<option value="vicuna-v1-7b-q4f32_0" ></option>
37+
<option value="RedPajama-INCITE-Chat-3B-v1-q4f32_0"></option>
38+
</datalist>
3139

3240
<script src="dist/llm_chat.js"></script>
3341
<link href="dist/llm_chat.css" rel="stylesheet" type="text/css"/>

0 commit comments

Comments
 (0)