Skip to content

Commit e990bab

Browse files
authored
Change vocab size to support vicuna v1 (#33)
Vicuna v0's vocab_size is 32001, but v1's vocab size is 32000. So we need to update the manual schedule.
1 parent 0eff3fa commit e990bab

File tree

12 files changed

+125
-149
lines changed

12 files changed

+125
-149
lines changed

build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
def _parse_args():
1919
args = argparse.ArgumentParser()
20-
args.add_argument("--model", type=str, default="vicuna-7b")
20+
args.add_argument("--model", type=str, default="vicuna-7b-v1")
2121
args.add_argument("--target", type=str, default="auto")
2222
args.add_argument("--db-path", type=str, default="log_db/")
2323
args.add_argument("--artifact-path", type=str, default="dist")

chat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def _parse_args():
1616
args.add_argument("--device-name", type=str, default="auto")
1717
args.add_argument("--debug-dump", action="store_true", default=False)
1818
args.add_argument("--artifact-path", type=str, default="dist")
19-
args.add_argument("--model", type=str, default="vicuna-7b")
19+
args.add_argument("--model", type=str, default="vicuna-7b-v1")
2020
args.add_argument("--max-gen-len", type=int, default=128)
2121
args.add_argument("--run-torch-model", action="store_true", default=False)
2222
parsed = args.parse_args()
@@ -101,7 +101,7 @@ def sample_top_p(probs, p):
101101
def chat(model_wrapper, args):
102102

103103
# Chat
104-
conv = conv_templates["v1"].copy()
104+
conv = conv_templates["vicuna_v1.1"].copy()
105105
while True:
106106
try:
107107
inp = input(f"{conv.roles[0]}: ")

evaluate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _parse_args():
2222
args.add_argument("--debug-dump", action="store_true", default=False)
2323
args.add_argument("--artifact-path", type=str, default="dist")
2424
args.add_argument("--prompt", type=str, default="The capital of Canada is")
25-
args.add_argument("--model", type=str, default="vicuna-7b")
25+
args.add_argument("--model", type=str, default="vicuna-7b-v1")
2626
args.add_argument("--profile", action="store_true", default=False)
2727
parsed = args.parse_args()
2828
parsed.model_path = os.path.join(parsed.artifact_path, "models", parsed.model)

scripts/build_site.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ cp dist/tvmjs_runtime.wasi.js site/dist
1919
cp dist/tvmjs.bundle.js site/dist
2020
cp -r dist/sentencepiece site/dist
2121

22-
if [ -d "dist/vicuna-7b/params" ]; then
23-
mkdir -p site/dist/vicuna-7b
24-
cp -rf dist/models/vicuna-7b/tokenizer.model site/dist/vicuna-7b/
25-
cp -rf dist/vicuna-7b/vicuna-7b_webgpu.wasm site/dist/vicuna-7b/
22+
if [ -d "dist/vicuna-7b-v1/params" ]; then
23+
mkdir -p site/dist/vicuna-7b-v1
24+
cp -rf dist/models/vicuna-7b-v1/tokenizer.model site/dist/vicuna-7b-v1/
25+
cp -rf dist/vicuna-7b-v1/vicuna-7b-v1_webgpu.wasm site/dist/vicuna-7b-v1/
2626
fi
2727

2828
cd site && jekyll b && cd ..

scripts/local_deploy_site.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ scripts/build_site.sh web/local-config.json
55

66
echo "symlink parameter location to site.."
77

8-
if [ -d "dist/vicuna-7b/params" ]; then
9-
rm -rf site/_site/vicuna-7b-params
10-
ln -s `pwd`/dist/vicuna-7b/params site/_site/vicuna-7b-params
8+
if [ -d "dist/vicuna-7b-v1/params" ]; then
9+
rm -rf site/_site/vicuna-7b-v1-params
10+
ln -s `pwd`/dist/vicuna-7b-v1/params site/_site/vicuna-7b-v1-params
1111
fi
1212
cd site && jekyll serve --skip-initial-build --host localhost --baseurl /web-llm --port 8888

scripts/rpc_debug_deploy.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ cp web/local-config.json ${TVM_HOME}/web/dist/www/llm-chat-config.json
1919
rm -rf ${TVM_HOME}/web/dist/www/dist/sentencepiece
2020
cp -rf dist/sentencepiece ${TVM_HOME}/web/dist/www/dist/
2121

22-
if [ -d "dist/vicuna-7b/params" ]; then
23-
mkdir -p ${TVM_HOME}/web/dist/www/dist/vicuna-7b
24-
cp -rf dist/models/vicuna-7b/tokenizer.model ${TVM_HOME}/web/dist/www/dist/vicuna-7b/
25-
cp -rf dist/vicuna-7b/vicuna-7b_webgpu.wasm ${TVM_HOME}/web/dist/www/dist/vicuna-7b/
26-
rm -rf ${TVM_HOME}/web/.ndarray_cache/vicuna-7b-params
27-
ln -s `pwd`/dist/vicuna-7b/params ${TVM_HOME}/web/.ndarray_cache/vicuna-7b-params
22+
if [ -d "dist/vicuna-7b-v1/params" ]; then
23+
mkdir -p ${TVM_HOME}/web/dist/www/dist/vicuna-7b-v1
24+
cp -rf dist/models/vicuna-7b-v1/tokenizer.model ${TVM_HOME}/web/dist/www/dist/vicuna-7b-v1/
25+
cp -rf dist/vicuna-7b-v1/vicuna-7b-v1_webgpu.wasm ${TVM_HOME}/web/dist/www/dist/vicuna-7b-v1/
26+
rm -rf ${TVM_HOME}/web/.ndarray_cache/vicuna-7b-v1-params
27+
ln -s `pwd`/dist/vicuna-7b-v1/params ${TVM_HOME}/web/.ndarray_cache/vicuna-7b-v1-params
2828
fi

site/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ If you have a Mac computer with Apple silicon, here are the instructions for you
3737

3838
## Chat Demo
3939

40-
The chat demo is based on [vicuna-7b-v0](https://huggingface.co/lmsys/vicuna-7b-delta-v0) model. More model support are on the way.
40+
The chat demo is based on [vicuna-7b-v1.1](https://huggingface.co/lmsys/vicuna-7b-delta-v1.1) model. More model support are on the way.
4141

4242
{% include llm_chat.html %}
4343

web/gh-page-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"shape": [32, 32, 128],
55
"dtype": "float32"
66
},
7-
"wasmUrl": "dist/vicuna-7b/vicuna-7b_webgpu.wasm",
7+
"wasmUrl": "dist/vicuna-7b-v1/vicuna-7b-v1_webgpu.wasm",
88
"cacheUrl": "https://huggingface.co/mlc-ai/web-lm/resolve/main/vicuna-0b/",
9-
"tokenizer": "dist/vicuna-7b/tokenizer.model",
9+
"tokenizer": "dist/vicuna-7b-v1/tokenizer.model",
1010
"maxGenLength": 512,
1111
"meanGenLength": 128,
1212
"maxWindowLength": 2048

web/llm_chat.js

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,35 +51,13 @@ class Conversation {
5151

5252
function defaultConversation(maxWindowLength = 512) {
5353
return new Conversation({
54-
system: "A chat between a curious human and an artificial intelligence assistant. " +
55-
"The assistant gives helpful, detailed, and polite answers to the human's questions.",
56-
roles: ["Human", "Assistant"],
54+
system: "A chat between a curious user and an artificial intelligence assistant. " +
55+
"The assistant gives helpful, detailed, and polite answers to the user's questions.",
56+
roles: ["USER", "ASSISTANT"],
5757
maxWindowLength: maxWindowLength,
58-
messages: [
59-
["Human", "What are the key differences between renewable and non-renewable energy sources?"],
60-
[ "Assistant",
61-
"Renewable energy sources are those that can be replenished naturally in a relatively " +
62-
"short amount of time, such as solar, wind, hydro, geothermal, and biomass. " +
63-
"Non-renewable energy sources, on the other hand, are finite and will eventually be " +
64-
"depleted, such as coal, oil, and natural gas. Here are some key differences between " +
65-
"renewable and non-renewable energy sources:\n" +
66-
"1. Availability: Renewable energy sources are virtually inexhaustible, while non-renewable " +
67-
"energy sources are finite and will eventually run out.\n" +
68-
"2. Environmental impact: Renewable energy sources have a much lower environmental impact " +
69-
"than non-renewable sources, which can lead to air and water pollution, greenhouse gas emissions, " +
70-
"and other negative effects.\n" +
71-
"3. Cost: Renewable energy sources can be more expensive to initially set up, but they typically " +
72-
"have lower operational costs than non-renewable sources.\n" +
73-
"4. Reliability: Renewable energy sources are often more reliable and can be used in more remote " +
74-
"locations than non-renewable sources.\n" +
75-
"5. Flexibility: Renewable energy sources are often more flexible and can be adapted to different " +
76-
"situations and needs, while non-renewable sources are more rigid and inflexible.\n" +
77-
"6. Sustainability: Renewable energy sources are more sustainable over the long term, while " +
78-
"non-renewable sources are not, and their depletion can lead to economic and social instability.\n"
79-
]
80-
],
81-
offset: 2,
82-
seps:["###"],
58+
messages: [],
59+
offset: 0,
60+
seps:[" ", "</s>"],
8361
});
8462
};
8563

@@ -307,6 +285,7 @@ class LLMChatPipeline {
307285
callbackUpdateResponse(step, outputPrompt);
308286
}
309287
}
288+
this.conversation.messages[this.conversation.messages.length - 1][1] = outputPrompt;
310289
return outputPrompt;
311290
}
312291

web/local-config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"shape": [32, 32, 128],
55
"dtype": "float32"
66
},
7-
"wasmUrl": "dist/vicuna-7b/vicuna-7b_webgpu.wasm",
8-
"cacheUrl": "vicuna-7b-params/",
9-
"tokenizer": "dist/vicuna-7b/tokenizer.model",
7+
"wasmUrl": "dist/vicuna-7b-v1/vicuna-7b-v1_webgpu.wasm",
8+
"cacheUrl": "vicuna-7b-v1-params/",
9+
"tokenizer": "dist/vicuna-7b-v1/tokenizer.model",
1010
"maxGenLength": 512,
1111
"meanGenLength": 128,
1212
"maxWindowLength": 1024

0 commit comments

Comments
 (0)