kute-engine 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. kute_engine-0.2.0/Cargo.toml +49 -0
  2. kute_engine-0.2.0/PKG-INFO +59 -0
  3. kute_engine-0.2.0/README.md +39 -0
  4. kute_engine-0.2.0/bindings/python/Cargo.lock +618 -0
  5. kute_engine-0.2.0/bindings/python/Cargo.toml +28 -0
  6. kute_engine-0.2.0/bindings/python/README.md +39 -0
  7. kute_engine-0.2.0/bindings/python/src/lib.rs +305 -0
  8. kute_engine-0.2.0/bindings/python/tests/test_kute.py +145 -0
  9. kute_engine-0.2.0/crates/kute/Cargo.toml +30 -0
  10. kute_engine-0.2.0/crates/kute/README.md +32 -0
  11. kute_engine-0.2.0/crates/kute/src/lib.rs +233 -0
  12. kute_engine-0.2.0/crates/kute/tests/mvp.rs +561 -0
  13. kute_engine-0.2.0/crates/kute-adapters/Cargo.toml +18 -0
  14. kute_engine-0.2.0/crates/kute-adapters/README.md +11 -0
  15. kute_engine-0.2.0/crates/kute-adapters/src/lib.rs +259 -0
  16. kute_engine-0.2.0/crates/kute-algorithms/Cargo.toml +19 -0
  17. kute_engine-0.2.0/crates/kute-algorithms/README.md +11 -0
  18. kute_engine-0.2.0/crates/kute-algorithms/src/lib.rs +25 -0
  19. kute_engine-0.2.0/crates/kute-algorithms/src/table.rs +482 -0
  20. kute_engine-0.2.0/crates/kute-bench/Cargo.toml +22 -0
  21. kute_engine-0.2.0/crates/kute-bench/README.md +11 -0
  22. kute_engine-0.2.0/crates/kute-bench/build.rs +16 -0
  23. kute_engine-0.2.0/crates/kute-bench/src/data.rs +156 -0
  24. kute_engine-0.2.0/crates/kute-bench/src/lib.rs +259 -0
  25. kute_engine-0.2.0/crates/kute-bench/src/suite.rs +553 -0
  26. kute_engine-0.2.0/crates/kute-bpe/Cargo.toml +22 -0
  27. kute_engine-0.2.0/crates/kute-bpe/README.md +11 -0
  28. kute_engine-0.2.0/crates/kute-bpe/src/byte.rs +508 -0
  29. kute_engine-0.2.0/crates/kute-bpe/src/lib.rs +20 -0
  30. kute_engine-0.2.0/crates/kute-bpe/src/merge.rs +307 -0
  31. kute_engine-0.2.0/crates/kute-bpe/src/sequence.rs +258 -0
  32. kute_engine-0.2.0/crates/kute-core/Cargo.toml +17 -0
  33. kute_engine-0.2.0/crates/kute-core/README.md +11 -0
  34. kute_engine-0.2.0/crates/kute-core/src/lib.rs +267 -0
  35. kute_engine-0.2.0/crates/kute-types/Cargo.toml +22 -0
  36. kute_engine-0.2.0/crates/kute-types/README.md +11 -0
  37. kute_engine-0.2.0/crates/kute-types/src/config.rs +158 -0
  38. kute_engine-0.2.0/crates/kute-types/src/error.rs +43 -0
  39. kute_engine-0.2.0/crates/kute-types/src/id.rs +107 -0
  40. kute_engine-0.2.0/crates/kute-types/src/input.rs +362 -0
  41. kute_engine-0.2.0/crates/kute-types/src/lib.rs +62 -0
  42. kute_engine-0.2.0/crates/kute-types/src/vocab.rs +404 -0
  43. kute_engine-0.2.0/crates/kute-vocab/Cargo.toml +18 -0
  44. kute_engine-0.2.0/crates/kute-vocab/README.md +11 -0
  45. kute_engine-0.2.0/crates/kute-vocab/src/lib.rs +288 -0
  46. kute_engine-0.2.0/pyproject.toml +31 -0
@@ -0,0 +1,49 @@
1
+ [workspace]
2
+ resolver = "2"
3
+ members = ["crates/*", "plugins/hrm"]
4
+ # The Python bindings link against an interpreter; they build with maturin and
5
+ # stay out of the default workspace so `cargo test --workspace` needs no Python.
6
+ exclude = ["bindings/python", "backends/rustbpe"]
7
+
8
+ [workspace.package]
9
+ version = "0.2.0"
10
+ edition = "2021"
11
+ license = "MIT OR Apache-2.0"
12
+ rust-version = "1.80"
13
+ authors = ["Kannaka Labs"]
14
+ repository = "https://github.com/kannaka-labs/kute"
15
+ homepage = "https://github.com/kannaka-labs/kute"
16
+ keywords = ["tokenizer", "bpe", "tokenization", "vocabulary"]
17
+ categories = ["text-processing", "encoding"]
18
+
19
+ [workspace.dependencies]
20
+ kute-types = { path = "crates/kute-types", version = "0.2.0" }
21
+ kute-core = { path = "crates/kute-core", version = "0.2.0" }
22
+ kute-vocab = { path = "crates/kute-vocab", version = "0.2.0" }
23
+ kute-bpe = { path = "crates/kute-bpe", version = "0.2.0" }
24
+ kute-algorithms = { path = "crates/kute-algorithms", version = "0.2.0" }
25
+ kute-adapters = { path = "crates/kute-adapters", version = "0.2.0" }
26
+ kute-bench = { path = "crates/kute-bench", version = "0.2.0" }
27
+ kute-hrm = { path = "plugins/hrm", version = "0.2.0" }
28
+ kute = { package = "kute-engine", path = "crates/kute", version = "0.2.0" }
29
+
30
+ serde = { version = "1", features = ["derive"] }
31
+ serde_json = "1"
32
+ thiserror = "1"
33
+ sha2 = "0.10"
34
+ base64 = "0.22"
35
+ semver = { version = "1", features = ["serde"] }
36
+ fancy-regex = "0.16"
37
+ regex = "1"
38
+ rayon = "1.10"
39
+ rustc-hash = "2"
40
+ clap = { version = "4", features = ["derive"] }
41
+ flate2 = "1"
42
+
43
+ # Tests train real vocabularies; a little optimization keeps the suite quick.
44
+ [profile.dev]
45
+ opt-level = 1
46
+
47
+ [profile.release]
48
+ lto = "thin"
49
+ codegen-units = 4
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.4
2
+ Name: kute-engine
3
+ Version: 0.2.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Topic :: Text Processing
8
+ Requires-Dist: pytest>=8 ; extra == 'test'
9
+ Requires-Dist: tiktoken>=0.8 ; extra == 'test'
10
+ Provides-Extra: test
11
+ Summary: Kannaka Universal Tokenization Engine: train, exchange and apply vocabularies for text, bytes, structured records and event sequences
12
+ Keywords: tokenizer,bpe,tokenization,vocabulary
13
+ Author: Kannaka Labs
14
+ License: MIT OR Apache-2.0
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
17
+ Project-URL: Issues, https://github.com/kannaka-labs/kute/issues
18
+ Project-URL: Repository, https://github.com/kannaka-labs/kute
19
+
20
+ # kute (Python)
21
+
22
+ Python bindings for the Kannaka Universal Tokenization Engine. The Rust engine
23
+ does the work; this package is a thin layer over it.
24
+
25
+ ```python
26
+ from kute import Engine, Vocabulary
27
+
28
+ engine = Engine()
29
+ vocab = engine.train(
30
+ source="./agent_messages.jsonl",
31
+ algorithm="bpe",
32
+ adapter="jsonl",
33
+ vocab_size=2048,
34
+ vocabulary_id="example:agent:messages",
35
+ )
36
+ tokens = engine.encode('{"from": "kannaka", "intent": "request_observation"}', vocabulary=vocab)
37
+ original = engine.decode(tokens, vocabulary=vocab)
38
+ results = engine.evaluate(vocabulary=vocab, dataset="./evaluation.jsonl")
39
+ vocab.save("agent-vocabulary.kvf")
40
+ same = Vocabulary.load("agent-vocabulary.kvf")
41
+ ```
42
+
43
+ `encode` returns a list of token ids. Those ids only mean something with the
44
+ vocabulary that produced them, so `decode` takes the same vocabulary.
45
+
46
+ `decode` returns `str` for vocabularies trained through the `text` adapter and
47
+ `bytes` for everything else. `decode_bytes` always returns `bytes`.
48
+
49
+ ## Build
50
+
51
+ ```
52
+ pip install maturin
53
+ cd bindings/python
54
+ maturin develop --release # into the active virtualenv
55
+ # or: maturin build --release # wheel under target/wheels
56
+ pip install pytest tiktoken
57
+ pytest tests
58
+ ```
59
+
@@ -0,0 +1,39 @@
1
+ # kute (Python)
2
+
3
+ Python bindings for the Kannaka Universal Tokenization Engine. The Rust engine
4
+ does the work; this package is a thin layer over it.
5
+
6
+ ```python
7
+ from kute import Engine, Vocabulary
8
+
9
+ engine = Engine()
10
+ vocab = engine.train(
11
+ source="./agent_messages.jsonl",
12
+ algorithm="bpe",
13
+ adapter="jsonl",
14
+ vocab_size=2048,
15
+ vocabulary_id="example:agent:messages",
16
+ )
17
+ tokens = engine.encode('{"from": "kannaka", "intent": "request_observation"}', vocabulary=vocab)
18
+ original = engine.decode(tokens, vocabulary=vocab)
19
+ results = engine.evaluate(vocabulary=vocab, dataset="./evaluation.jsonl")
20
+ vocab.save("agent-vocabulary.kvf")
21
+ same = Vocabulary.load("agent-vocabulary.kvf")
22
+ ```
23
+
24
+ `encode` returns a list of token ids. Those ids only mean something with the
25
+ vocabulary that produced them, so `decode` takes the same vocabulary.
26
+
27
+ `decode` returns `str` for vocabularies trained through the `text` adapter and
28
+ `bytes` for everything else. `decode_bytes` always returns `bytes`.
29
+
30
+ ## Build
31
+
32
+ ```
33
+ pip install maturin
34
+ cd bindings/python
35
+ maturin develop --release # into the active virtualenv
36
+ # or: maturin build --release # wheel under target/wheels
37
+ pip install pytest tiktoken
38
+ pytest tests
39
+ ```