Skip to content

Commit 33b4163

Browse files
committed
Store default sequence breakers in a slice
It's nicer when the length is not hardcoded
1 parent b5d0d04 commit 33b4163

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

mistralrs-core/src/sampler.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIter
1616
use serde::{Deserialize, Serialize};
1717
use tokenizers::Tokenizer;
1818

19-
pub const SEQUENCE_BREAKERS: [&str; 4] = ["\n", ":", "\\", "*"];
19+
pub const SEQUENCE_BREAKERS: &[&str] = &["\n", ":", "\\", "*"];
2020

2121
#[derive(Clone, Debug)]
2222
/// Stop sequences or ids.
@@ -79,12 +79,8 @@ impl DrySamplingParams {
7979
Ok(Self {
8080
base: base.unwrap_or(1.75),
8181
allowed_length: allowed_length.unwrap_or(2),
82-
sequence_breakers: sequence_breakers.unwrap_or(
83-
SEQUENCE_BREAKERS
84-
.map(|x| x.to_string())
85-
.into_iter()
86-
.collect(),
87-
),
82+
sequence_breakers: sequence_breakers
83+
.unwrap_or(SEQUENCE_BREAKERS.iter().map(|x| x.to_string()).collect()),
8884
multiplier,
8985
})
9086
}
@@ -96,10 +92,7 @@ impl Default for DrySamplingParams {
9692
multiplier: 1.0,
9793
base: 1.75,
9894
allowed_length: 2,
99-
sequence_breakers: SEQUENCE_BREAKERS
100-
.map(|x| x.to_string())
101-
.into_iter()
102-
.collect(),
95+
sequence_breakers: SEQUENCE_BREAKERS.iter().map(|x| x.to_string()).collect(),
10396
}
10497
}
10598
}

0 commit comments

Comments
 (0)