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

[Cache] Add cachedPrefixes for caching repeated system prompts #664

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

YiyanZhai
Copy link

This PR adds the cachedPrefixes field in MLCEngineConfig, allowing users to cache system prompts when creating MLCEngine. It reduces redundant processing of repeated instructions.

Example usage in CreateMLCEngine:

await webllm.CreateMLCEngine(
  selectedModel,
  {
    initProgressCallback: initProgressCallback,
    logLevel: "INFO",
    cachedPrefixes: [
      [ { role: "system", content: "You are a helpful assistant running in the user's browser. You need to answer questions ... " }, ]
    ],
  },
  {
    context_window_size: 2048,
  }
);

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

Successfully merging this pull request may close these issues.

1 participant