Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions swift/llm/utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ def add_default_tags(self, example: Dict[str, Any]) -> None:
num_new_tags = num_media - num_media_tags
assert num_new_tags >= 0, f'Number of media: {num_media}, number of media_tags: {num_media_tags}'
history[0][0] = media_tag * num_new_tags + history[0][0]

example['query'], example['response'] = history[-1]
example['query'] = history[-1][0]
if example.get('response') is not None:
example['response'] = history[-1][1]
example['history'] = history[:-1]

def replace_media_tags(self, example) -> None:
Expand Down Expand Up @@ -2106,10 +2107,10 @@ class Internlm2Template(ChatmlTemplate):


def replace_img_tag(query: str,
response: str,
response: Optional[str],
history: History,
replace_token: str,
pattern=r'<img>(.+?)</img>') -> Tuple[str, History, List[str]]:
pattern=r'<img>(.+?)</img>') -> Tuple[str, Optional[str], History, List[str]]:
images_path = []
new_history = []
history.append([query, response])
Expand Down