Skip to content

Commit b1c3713

Browse files
committed
Remove logic for appending or prepending tokens
ghstack-source-id: faf0542 ghstack-comment-id: 2311228673 Pull Request resolved: #4920
1 parent b284866 commit b1c3713

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

examples/models/llama2/export_llama_lib.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,9 @@ def _load_llama_model_metadata(
569569
):
570570
is_fairseq2 = weight_type == WeightType.FAIRSEQ2
571571
metadata = {
572-
"append_eos_to_prompt": is_fairseq2, # For language llama, tell the runtime to always append EOS token(s) to prompt.
573572
"get_bos_id": 3 if is_fairseq2 else 1,
574573
"get_eos_ids": [3] if is_fairseq2 else [2],
575574
"get_max_seq_len": model_args.max_seq_len,
576-
"get_n_bos": 1,
577-
"get_n_eos": 2 if is_fairseq2 else 1,
578575
"get_vocab_size": model_args.vocab_size,
579576
"use_kv_cache": use_kv_cache,
580577
"use_sdpa_with_kv_cache": use_sdpa_with_kv_cache,

examples/models/llama2/runner/runner.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424

2525
namespace torch::executor {
2626
namespace {
27-
static constexpr auto kAppendEosToPrompt = "append_eos_to_prompt";
2827
static constexpr auto kEnableDynamicShape = "enable_dynamic_shape";
2928
static constexpr auto kBosId = "get_bos_id";
3029
static constexpr auto kEosIds = "get_eos_ids";
3130
static constexpr auto kMaxSeqLen = "get_max_seq_len";
32-
static constexpr auto kNBos = "get_n_bos";
33-
static constexpr auto kNEos = "get_n_eos";
3431
static constexpr auto kVocabSize = "get_vocab_size";
3532
static constexpr auto kUseKVCache = "use_kv_cache";
3633
static constexpr auto kUseSDPAWithKVCache = "use_sdpa_with_kv_cache";
@@ -54,11 +51,8 @@ Runner::Runner(
5451
#endif
5552
),
5653
metadata_({
57-
{kAppendEosToPrompt, false},
5854
{kEnableDynamicShape, false},
5955
{kMaxSeqLen, 128},
60-
{kNBos, 1},
61-
{kNEos, 1},
6256
{kUseKVCache, true},
6357
{kUseSDPAWithKVCache, false},
6458
}) {
@@ -174,8 +168,8 @@ Error Runner::generate(
174168

175169
Result<std::vector<uint64_t>> encode_res = tokenizer_->encode(
176170
prompt,
177-
metadata_.at(kNBos),
178-
metadata_.at(kAppendEosToPrompt) ? metadata_.at(kNEos) : 0);
171+
/* bos */ 0,
172+
/* eos */ 0);
179173

180174
ET_CHECK_OK_OR_RETURN_ERROR(
181175
encode_res.error(), "Failed to encode prompt %s", prompt.c_str());

0 commit comments

Comments
 (0)