Commit 84f59a7f authored by Nathan Habib's avatar Nathan Habib
Browse files

cleanup

parent 3f1c6d20
...@@ -3,7 +3,6 @@ import os ...@@ -3,7 +3,6 @@ import os
from datetime import timedelta from datetime import timedelta
from pathlib import Path from pathlib import Path
from typing import Dict, List, Literal, Optional, Tuple, Union from typing import Dict, List, Literal, Optional, Tuple, Union
import jinja2
import torch import torch
import torch.nn.functional as F import torch.nn.functional as F
...@@ -1321,21 +1320,9 @@ class HFLM(TemplateLM): ...@@ -1321,21 +1320,9 @@ class HFLM(TemplateLM):
""" """
Method to apply a chat template to a list of chat history between user and model. Method to apply a chat template to a list of chat history between user and model.
""" """
try: return self.tokenizer.apply_chat_template(
chat_templated = self.tokenizer.apply_chat_template(
chat_history, tokenize=False, add_generation_prompt=True chat_history, tokenize=False, add_generation_prompt=True
) )
except jinja2.exceptions.TemplateError:
eval_logger.warning(
"Failed to apply chat template. removing the system role in chat history."
)
chat_history = [msg for msg in chat_history if msg["role"] != "system"]
chat_templated = self.tokenizer.apply_chat_template(
chat_history, tokenize=False, add_generation_prompt=True
)
return chat_templated
def get_model_info(self) -> dict: def get_model_info(self) -> dict:
""" """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment