updating velvet chat template
This commit is contained in:
parent
66e6d10b61
commit
39795570db
1 changed files with 6 additions and 3 deletions
|
@ -573,8 +573,11 @@ int32_t llm_chat_apply_template(
|
||||||
// Velvet template
|
// Velvet template
|
||||||
std::string leading_space = "";
|
std::string leading_space = "";
|
||||||
std::string trailing_space = "";
|
std::string trailing_space = "";
|
||||||
bool trim_assistant_message = true;
|
bool trim_assistant_message = false;
|
||||||
bool is_inside_turn = false;
|
bool is_inside_turn = false;
|
||||||
|
std::string system_message = "";
|
||||||
|
std::string last_message(chat.back()->content);
|
||||||
|
ss << "<s>";
|
||||||
for (auto message : chat) {
|
for (auto message : chat) {
|
||||||
if (!is_inside_turn) {
|
if (!is_inside_turn) {
|
||||||
ss << leading_space << "<instruction>" << trailing_space;
|
ss << leading_space << "<instruction>" << trailing_space;
|
||||||
|
@ -583,9 +586,9 @@ int32_t llm_chat_apply_template(
|
||||||
std::string role(message->role);
|
std::string role(message->role);
|
||||||
std::string content(message->content);
|
std::string content(message->content);
|
||||||
if (role == "system") {
|
if (role == "system") {
|
||||||
ss << content << "\n\n";
|
system_message = content + "\n\n";
|
||||||
} else if (role == "user") {
|
} else if (role == "user") {
|
||||||
ss << content << leading_space << "</instruction>";
|
ss << (content==last_message ? system_message : "") << content << leading_space << "</instruction>";
|
||||||
} else {
|
} else {
|
||||||
ss << trailing_space << (trim_assistant_message ? trim(content) : content) << "</s>";
|
ss << trailing_space << (trim_assistant_message ? trim(content) : content) << "</s>";
|
||||||
is_inside_turn = false;
|
is_inside_turn = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue