You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+124-1Lines changed: 124 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,10 +65,133 @@ for (const chunk of chunks) {
65
65
66
66
| Package | Description | Dependencies |
67
67
|---------|-------------|--------------|
68
-
|[@chonkiejs/core](./packages/core)| Local chunking (Recursive, Token) with character-based tokenization | Zero |
68
+
|[@chonkiejs/core](./packages/core)| Local chunking (Recursive, Token, Sentence, Semantic, Code, Table, Fast) with character-based tokenization | Zero |
69
69
|[@chonkiejs/cloud](./packages/cloud)| Cloud-based chunkers (Semantic, Neural, Code, etc.) via api.chonkie.ai |@chonkiejs/core|
70
70
|[@chonkiejs/token](./packages/token)| HuggingFace tokenizer support for core chunkers |@huggingface/transformers|
71
71
72
+
## Chunkers
73
+
74
+
All chunkers are available from `@chonkiejs/core` and follow the same pattern: `await ChunkerClass.create(options)` returns an instance, then `await chunker.chunk(text)` returns a `Chunk[]`.
75
+
76
+
### TokenChunker
77
+
78
+
Splits text into fixed-size token chunks with optional overlap.
79
+
80
+
```typescript
81
+
import { TokenChunker } from'@chonkiejs/core';
82
+
83
+
const chunker =awaitTokenChunker.create({
84
+
chunkSize: 512, // max tokens per chunk (default: 512)
85
+
chunkOverlap: 50, // overlapping tokens between chunks (default: 0)
86
+
tokenizer: 'character', // tokenizer model name or Tokenizer instance (default: 'character')
87
+
});
88
+
const chunks =awaitchunker.chunk(text);
89
+
```
90
+
91
+
### RecursiveChunker
92
+
93
+
Recursively splits text using a hierarchy of rules: paragraphs → sentences → punctuation → words → characters. The most general-purpose chunker.
prefix: false, // attach delimiter to start of next chunk (default: false)
189
+
consecutive: false, // split at start of consecutive delimiter runs (default: false)
190
+
forwardFallback: false, // search forward if no boundary found in backward window (default: false)
191
+
});
192
+
const chunks =chunker.chunk(text); // synchronous
193
+
```
194
+
72
195
## Contributing
73
196
74
197
Want to help grow Chonkie? Check out [CONTRIBUTING.md](CONTRIBUTING.md) to get started! Whether you're fixing bugs, adding features, improving docs, or simply leaving a ⭐️ on the repo, every contribution helps make Chonkie a better CHONK for everyone.
0 commit comments