File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1673,14 +1673,18 @@ struct LLMEmbedder : public Conditioner {
16731673 size_t max_length = 100000000 ) {
16741674 std::vector<std::pair<std::string, float >> parsed_attention;
16751675 if (attn_range.first >= 0 && attn_range.second > 0 ) {
1676- parsed_attention.emplace_back (text.substr (0 , attn_range.first ), 1 .f );
1676+ if (attn_range.first > 0 ) {
1677+ parsed_attention.emplace_back (text.substr (0 , attn_range.first ), 1 .f );
1678+ }
16771679 if (attn_range.second - attn_range.first > 0 ) {
16781680 auto new_parsed_attention = parse_prompt_attention (text.substr (attn_range.first , attn_range.second - attn_range.first ));
16791681 parsed_attention.insert (parsed_attention.end (),
16801682 new_parsed_attention.begin (),
16811683 new_parsed_attention.end ());
16821684 }
1683- parsed_attention.emplace_back (text.substr (attn_range.second ), 1 .f );
1685+ if (attn_range.second < text.size ()) {
1686+ parsed_attention.emplace_back (text.substr (attn_range.second ), 1 .f );
1687+ }
16841688 } else {
16851689 parsed_attention.emplace_back (text, 1 .f );
16861690 }
You can’t perform that action at this time.
0 commit comments