Merge pull request #34 from veden/dev

Templates: Added automatic detection of chat templates from tokenizer_config.json
This commit is contained in:
Brian Dashore
2023-12-21 22:34:53 -05:00
committed by GitHub
2 changed files with 22 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ from exllamav2.generator import(
from gen_logging import log_generation_params, log_prompt, log_response
from typing import List, Optional, Union
from templating import PromptTemplate, find_template_from_model, get_template_from_config, get_template_from_file
from templating import PromptTemplate, find_template_from_model, get_template_from_model_config, get_template_from_tokenizer_config, get_template_from_file
from utils import coalesce, unwrap
# Bytes to reserve on first device when loading with auto split
@@ -124,9 +124,13 @@ class ModelContainer:
self.prompt_template = get_template_from_file(prompt_template_name)
else:
# Try finding the chat template from the model's config.json
self.prompt_template = get_template_from_config(
self.prompt_template = get_template_from_model_config(
pathlib.Path(self.config.model_config)
)
if self.prompt_template == None:
self.prompt_template = get_template_from_tokenizer_config(
model_directory
)
# If that fails, attempt fetching from model name
if self.prompt_template is None: