add prefix suffic
This commit is contained in:
@@ -78,8 +78,8 @@ function removeLatestMsg(a::agent)
|
||||
end
|
||||
end
|
||||
|
||||
function generatePrompt(a::agent;
|
||||
userToken::String=" [/INST]", assistantToken=" [INST]",
|
||||
function generatePrompt_tokenSuffix(a::agent;
|
||||
userToken::String="[/INST]", assistantToken="[INST]",
|
||||
systemToken="[INST]<<SYS>> content <</SYS>>")
|
||||
prompt = nothing
|
||||
for msg in a.messages
|
||||
@@ -100,6 +100,28 @@ function generatePrompt(a::agent;
|
||||
return prompt
|
||||
end
|
||||
|
||||
function generatePrompt_tokenPrefix(a::agent;
|
||||
userToken::String=" [/INST]", assistantToken=" [INST]",
|
||||
systemToken="[INST]<<SYS>> content <</SYS>>")
|
||||
prompt = nothing
|
||||
for msg in a.messages
|
||||
role = msg[:role]
|
||||
content = msg[:content]
|
||||
|
||||
if role == "system"
|
||||
prompt = replace(systemToken, "content" => content)
|
||||
elseif role == "user"
|
||||
prompt *= userToken * content * " "
|
||||
elseif role == "assistant"
|
||||
prompt *= assistantToken * content * " "
|
||||
else
|
||||
error("undefied condition role = $role")
|
||||
end
|
||||
end
|
||||
|
||||
return prompt
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -154,7 +176,6 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end # module
|
||||
Reference in New Issue
Block a user