feat(template): read jinja templates from gguf files - #4332
Merged
Conversation
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
|
|
||
| // can either be a file in the system or a string with the template | ||
| if utils.ExistsInPath(tc.templatesPath, modelTemplateFile) { | ||
| d, err := os.ReadFile(file) |
Check failure
Code scanning / gosec
Potential file inclusion via variable
mudler
marked this pull request as draft
December 6, 2024 21:07
✅ Deploy Preview for localai ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Owner
Author
|
WIP as need to still add mapping between the transformer tokenizer and the templates (see TODO note in code comments) |
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
mudler
marked this pull request as ready for review
December 8, 2024 11:02
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Owner
Author
|
basic support should work (tested with llama3 prompt), probably is not going to cover all cases as gonja has limitations, but, since this kicks-in when no other template was defined it is safe to merge without drawbacks. |
sozercan
pushed a commit
to sozercan/LocalAI
that referenced
this pull request
Dec 8, 2024
* Read jinja templates as fallback Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Move templating out of model loader Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Test TemplateMessages Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Set role and content from transformers Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Tests: be more flexible Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * More jinja Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Small refactoring and adaptations Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds automatic detection and parsing of jinja templates in gguf files. If we fail to identify a variant and we do not have already a specific template, it injects the jinja templates which is part of the model metadata if one is found.
Alternatively, it is possible to enable jinja templates manually in the model config file, in the template config section with
jinja_template: true.Notes for Reviewers
Signed commits