We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0ecd650 commit 2692606Copy full SHA for 2692606
src/corebpe.rs
@@ -91,16 +91,18 @@ fn _byte_pair_merge(
91
}
92
93
pub fn byte_pair_encode(piece: &[u8], ranks: &HashMap<Vec<u8>, Rank>) -> Vec<Rank> {
94
- assert!(piece.len() > 1);
95
- _byte_pair_merge(&ranks, &piece)
+ if piece.len() == 1 {
+ return vec![ranks[piece]];
96
+ }
97
+ _byte_pair_merge(ranks, piece)
98
.windows(2)
99
.map(|part| ranks[&piece[part[0].0..part[1].0]])
100
.collect()
101
102
103
pub fn byte_pair_split<'a>(piece: &'a [u8], ranks: &HashMap<Vec<u8>, Rank>) -> Vec<&'a [u8]> {
104
assert!(piece.len() > 1);
105
106
107
.map(|part| &piece[part[0].0..part[1].0])
108
0 commit comments