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

feat(llama.cpp): Add support to grammar triggers #4733

Merged
merged 1 commit into from
Feb 2, 2025

Conversation

mudler
Copy link
Owner

@mudler mudler commented Feb 2, 2025

Description

Thanks to the great upstream work in llama.cpp ( ggml-org/llama.cpp#9639 thanks 🫶 @ochafik ! ) it is now possible to enable grammars with a set of trigger words. This allows to force a special schema in answers only if a trigger word is detected as part of the text of the LLM. This, for example, allows to models that uses tags before returning the json (e.g. [TOOL_CALL], <tool_call>, ... ) to identify the function call and enable the grammar - which allows the model to output text replies or JSON.

This PR enables this feature in LocalAI, and it can be enabled in the model configuration file:

function:
  grammar:
    triggers:
    - word: "foo"
      at_start: true

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

Copy link

netlify bot commented Feb 2, 2025

Deploy Preview for localai ready!

Name Link
🔨 Latest commit d28547e
🔍 Latest deploy log https://app.netlify.com/sites/localai/deploys/679f4a8ac1c3f100089c6cf4
😎 Deploy Preview https://deploy-preview-4733--localai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mudler mudler added the enhancement New feature or request label Feb 2, 2025
@mudler mudler merged commit 1d6afbd into master Feb 2, 2025
25 checks passed
@mudler mudler deleted the feat/grammar_triggers branch February 2, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant