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

[Grammar] Integrate with XGrammar #635

Merged
merged 10 commits into from
Nov 22, 2024
Next Next commit
[Grammar] Integrate with web-xgrammar
  • Loading branch information
CharlieFRuan committed Nov 22, 2024
commit 8d530cd00c5b136cd8b5c7237f16e8e0808bceef
5 changes: 4 additions & 1 deletion examples/json-mode/src/json_mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ async function main() {
const initProgressCallback = (report: webllm.InitProgressReport) => {
setLabel("init-label", report.text);
};
const selectedModel = "Llama-3.1-8B-Instruct-q4f32_1-MLC";
// Pick any one of these models to start trying -- most models in WebLLM support grammar
const selectedModel = "Llama-3.2-3B-Instruct-q4f16_1-MLC";
// const selectedModel = "Qwen2.5-1.5B-Instruct-q4f16_1-MLC";
// const selectedModel = "Phi-3.5-mini-instruct-q4f16_1-MLC";
const engine: webllm.MLCEngineInterface = await webllm.CreateMLCEngine(
selectedModel,
{ initProgressCallback: initProgressCallback },
Expand Down
18 changes: 14 additions & 4 deletions examples/json-schema/src/json_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ async function simpleStructuredTextExample() {
const initProgressCallback = (report: webllm.InitProgressReport) => {
setLabel("init-label", report.text);
};

// Pick any one of these models to start trying -- most models in WebLLM support grammar
// const selectedModel = "Llama-3.2-3B-Instruct-q4f16_1-MLC";
// const selectedModel = "Qwen2.5-1.5B-Instruct-q4f16_1-MLC";
const selectedModel = "Phi-3.5-mini-instruct-q4f16_1-MLC";
const engine: webllm.MLCEngineInterface = await webllm.CreateMLCEngine(
"Llama-3.1-8B-Instruct-q4f16_1-MLC",
selectedModel,
{ initProgressCallback: initProgressCallback },
);

Expand Down Expand Up @@ -106,8 +111,13 @@ async function harryPotterExample() {
setLabel("init-label", report.text);
};

// Pick any one of these models to start trying -- most models in WebLLM support grammar
// const selectedModel = "Llama-3.2-3B-Instruct-q4f16_1-MLC";
// const selectedModel = "Qwen2.5-1.5B-Instruct-q4f16_1-MLC";
const selectedModel = "Phi-3.5-mini-instruct-q4f16_1-MLC";

const engine: webllm.MLCEngineInterface = await webllm.CreateMLCEngine(
"Llama-3.1-8B-Instruct-q4f16_1-MLC",
selectedModel,
{ initProgressCallback: initProgressCallback },
);

Expand Down Expand Up @@ -216,8 +226,8 @@ async function functionCallingExample() {

async function main() {
// await simpleStructuredTextExample();
// await harryPotterExample();
await functionCallingExample();
await harryPotterExample();
// await functionCallingExample();
}

main();
28 changes: 28 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"ts-jest": "^29.1.2",
"tslib": "^2.3.1",
"@mlc-ai/web-runtime": "0.18.0-dev2",
"@mlc-ai/web-xgrammar": "../xgrammar/web",
"typescript": "^4.9.5"
},
"dependencies": {
Expand Down
203 changes: 0 additions & 203 deletions src/grammar.ts

This file was deleted.

Loading