pub struct TextSegmenterConfig {
pub min_chars: usize,
pub target_chars: usize,
pub max_chars: usize,
pub overlap_chars: usize,
}Expand description
Size limits for text segments, in UTF-8 bytes (characters, for ASCII text).
Defaults are chosen for retrieval quality, not to fill the 8K context.
A vector that averages several ideas scores lower for a query matching only
one of them, so segments follow the author’s own units: every paragraph of
at least min_chars is its own segment. Shorter fragments (labels, one-line
notes) are merged with their neighbours up to target_chars.
Gemma’s tokenizer averages roughly four characters per token on English prose: 60 characters is a short sentence, the 1,000-character target is about 250 tokens and the 1,800-character maximum about 450.
Fields§
§min_chars: usizeParagraphs at least this long are never merged with each other.
target_chars: usizeStop merging short fragments once a chunk reaches this size.
max_chars: usizeLonger paragraphs are split at sentences. A merged chunk can exceed this slightly, since headings and the gaps between paragraphs are not counted.
overlap_chars: usizeWhen a long paragraph is cut at a sentence, its last sentence (if no longer than this) is repeated at the start of the next piece. There is no overlap across paragraph breaks the author chose.
Trait Implementations§
Source§impl Clone for TextSegmenterConfig
impl Clone for TextSegmenterConfig
Source§impl Debug for TextSegmenterConfig
impl Debug for TextSegmenterConfig
Source§impl Default for TextSegmenterConfig
impl Default for TextSegmenterConfig
Source§impl<'de> Deserialize<'de> for TextSegmenterConfig
impl<'de> Deserialize<'de> for TextSegmenterConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for TextSegmenterConfig
Source§impl PartialEq for TextSegmenterConfig
impl PartialEq for TextSegmenterConfig
Source§impl Serialize for TextSegmenterConfig
impl Serialize for TextSegmenterConfig
impl StructuralPartialEq for TextSegmenterConfig
Auto Trait Implementations§
impl Freeze for TextSegmenterConfig
impl RefUnwindSafe for TextSegmenterConfig
impl Send for TextSegmenterConfig
impl Sync for TextSegmenterConfig
impl Unpin for TextSegmenterConfig
impl UnsafeUnpin for TextSegmenterConfig
impl UnwindSafe for TextSegmenterConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.