Skip to content

Commit

Permalink
beam search
Browse files Browse the repository at this point in the history
  • Loading branch information
mzegla committed Aug 2, 2024
1 parent 21e680e commit 5b3c185
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cpp/src/sampler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ class GroupBeamSearcher {

// mark current sequence as finished
beam.m_sequence->set_status(SequenceStatus::FINISHED);
// Setting length since this function is used when sequence generated tokens number reaches max_new_tokens
beam.m_sequence->set_finish_reason(GenerationFinishReason::LENGTH);
// we also need to drop add ongoing / forked sequences from scheduler
sampler_output.m_dropped_sequences.push_back(sequence_id);
}
Expand Down Expand Up @@ -432,6 +434,8 @@ void GroupBeamSearcher::select_next_tokens(const ov::Tensor& logits, SamplerOutp
Sequence::Ptr forked_sequence = m_sequence_group->fork_sequence(candidate.m_sequence);
// and finish immidiately
forked_sequence->set_status(SequenceStatus::FINISHED);
// Setting length since this function is used when sequence generated eos token
forked_sequence->set_finish_reason(GenerationFinishReason::STOP);

// TODO: make it more simplier
// currently, we finish sequence and then fork it in current code
Expand Down

0 comments on commit 5b3c185

Please sign in to comment.