Skip to content

Commit ea01fbc

Browse files
authored
Fix falcon prompt template (#1696)
1 parent e712c68 commit ea01fbc

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

litgpt/prompts.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ def stop_tokens(self, tokenizer: "Tokenizer") -> Tuple[List[int], ...]:
133133

134134
class Falcon(PromptStyle):
135135
def apply(self, prompt: str, **kwargs: str) -> str:
136-
# First line could be modified. AFAIK Falcon doesn't impose a specific system prompt
137-
# The instruction to not prefix its replies doesn't work always, but better than nothing
138-
# I've also tried just "{prompt}\n" but the model seems to ramble more often
139-
return f"Do not prefix your replies with 'Bot: '\nUser: {prompt}\n"
136+
return f"{prompt}\nAnswer:"
140137

141138
def stop_tokens(self, tokenizer: "Tokenizer") -> Tuple[List[int], ...]:
142139
return (
@@ -218,14 +215,14 @@ def apply(self, prompt: Union[str, List[Dict[str, str]]], **kwargs: str) -> str:
218215

219216
def encode_header(role: str) -> List[str]:
220217
return [f"<|start_header_id|>{role}<|end_header_id|>\n\n"]
221-
218+
222219
def encode_message(message: Dict[str, str]) -> List[str]:
223220
tokens = encode_header(message["role"])
224221
# NOTE: Meta stripped this. I'm not sure I agree, but who am I to argue?
225222
tokens.append(message["content"].strip())
226223
tokens.append("<|eot_id|>")
227224
return tokens
228-
225+
229226
def has_system_prompt(messages: List[Dict[str, str]]) -> bool:
230227
return messages[0].get("role", "") == "system" if len(messages) else False
231228

@@ -309,7 +306,6 @@ def apply(self, prompt: str, **kwargs: str) -> str:
309306
return f'<|system|>\nYou are a helpful assistant.<|end|>\n<|user|>\n{prompt}<|end|>\n<|assistant|>\n'
310307

311308

312-
313309
class TinyLlama(PromptStyle):
314310
def apply(self, prompt: str, **kwargs: str) -> str:
315311
return (

0 commit comments

Comments
 (0)