llguidance 1.3.0__cp39-abi3-win_amd64.whl → 1.5.0__cp39-abi3-win_amd64.whl
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.
- llguidance/_lib.pyd +0 -0
- llguidance/_lib.pyi +20 -0
- llguidance/mlx.py +1 -1
- llguidance/numpy.py +19 -0
- llguidance/torch.py +19 -0
- {llguidance-1.3.0.dist-info → llguidance-1.5.0.dist-info}/METADATA +12 -6
- llguidance-1.5.0.dist-info/RECORD +20 -0
- {llguidance-1.3.0.dist-info → llguidance-1.5.0.dist-info}/WHEEL +1 -1
- llguidance-1.3.0.dist-info/RECORD +0 -20
- {llguidance-1.3.0.dist-info → llguidance-1.5.0.dist-info}/licenses/LICENSE +0 -0
llguidance/_lib.pyd
CHANGED
|
Binary file
|
llguidance/_lib.pyi
CHANGED
|
@@ -570,6 +570,26 @@ class LLExecutor:
|
|
|
570
570
|
State rollback is performed to maintain matcher consistency.
|
|
571
571
|
"""
|
|
572
572
|
|
|
573
|
+
def consume_token_par(
|
|
574
|
+
self,
|
|
575
|
+
matchers: List[Tuple[LLMatcher, TokenId]],
|
|
576
|
+
) -> List[bool]:
|
|
577
|
+
"""
|
|
578
|
+
Consume a single token for each matcher in parallel.
|
|
579
|
+
|
|
580
|
+
Args:
|
|
581
|
+
matchers: List of tuples containing:
|
|
582
|
+
- LLMatcher: The matcher object
|
|
583
|
+
- TokenId: The token ID to consume
|
|
584
|
+
|
|
585
|
+
Returns:
|
|
586
|
+
List[bool]: Success/failure for each matcher (in order).
|
|
587
|
+
|
|
588
|
+
Note:
|
|
589
|
+
Matchers that fail (return False) are left in an error state,
|
|
590
|
+
consistent with the behavior of consume_token on a single matcher.
|
|
591
|
+
"""
|
|
592
|
+
|
|
573
593
|
class JsonCompileOptions(TypedDict, total=False):
|
|
574
594
|
# defaults to ","
|
|
575
595
|
item_separator: Optional[str]
|
llguidance/mlx.py
CHANGED
|
@@ -8,7 +8,7 @@ from .numpy import get_bitmask_shape, allocate_token_bitmask, fill_next_token_bi
|
|
|
8
8
|
from numpy.typing import NDArray
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
@mx.custom_function # type: ignore[
|
|
11
|
+
@mx.custom_function # type: ignore[untyped-decorator]
|
|
12
12
|
def apply_token_bitmask_kernel(data: mx.array, mask: mx.array) -> mx.array:
|
|
13
13
|
source = """
|
|
14
14
|
uint batch = thread_position_in_grid.y; // Batch index
|
llguidance/numpy.py
CHANGED
|
@@ -80,3 +80,22 @@ def fill_next_token_bitmask_par_with_draft_tokens(executor: LLExecutor,
|
|
|
80
80
|
batch, vocab = bitmask.shape
|
|
81
81
|
assert bitmask.flags["C_CONTIGUOUS"], "Mask must be contiguous"
|
|
82
82
|
executor.unsafe_compute_mask_ptr_with_draft_token(matchers, bitmask.ctypes.data, vocab * 4, batch)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def consume_token_par(executor: LLExecutor,
|
|
86
|
+
matchers: List[Tuple[LLMatcher, int]]) -> List[bool]:
|
|
87
|
+
"""
|
|
88
|
+
Consume a single token for each matcher in parallel.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
executor: The LLExecutor to use for parallel execution.
|
|
92
|
+
matchers: List of tuples containing (LLMatcher, token_id).
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
List[bool]: Success/failure for each matcher (in order).
|
|
96
|
+
|
|
97
|
+
Note:
|
|
98
|
+
Matchers that fail (return False) are left in an error state,
|
|
99
|
+
consistent with the behavior of consume_token on a single matcher.
|
|
100
|
+
"""
|
|
101
|
+
return executor.consume_token_par(matchers)
|
llguidance/torch.py
CHANGED
|
@@ -77,3 +77,22 @@ def fill_next_token_bitmask_par_with_draft_tokens(executor: LLExecutor,
|
|
|
77
77
|
batch, vocab = bitmask.shape
|
|
78
78
|
assert bitmask.is_contiguous(), "Mask must be contiguous"
|
|
79
79
|
executor.unsafe_compute_mask_ptr_with_draft_token(matchers, bitmask.data_ptr(), vocab * 4, batch)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def consume_token_par(executor: LLExecutor,
|
|
83
|
+
matchers: List[Tuple[LLMatcher, int]]) -> List[bool]:
|
|
84
|
+
"""
|
|
85
|
+
Consume a single token for each matcher in parallel.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
executor: The LLExecutor to use for parallel execution.
|
|
89
|
+
matchers: List of tuples containing (LLMatcher, token_id).
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
List[bool]: Success/failure for each matcher (in order).
|
|
93
|
+
|
|
94
|
+
Note:
|
|
95
|
+
Matchers that fail (return False) are left in an error state,
|
|
96
|
+
consistent with the behavior of consume_token on a single matcher.
|
|
97
|
+
"""
|
|
98
|
+
return executor.consume_token_par(matchers)
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: llguidance
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
License-File: LICENSE
|
|
5
5
|
Summary: Bindings for the Low-level Guidance (llguidance) Rust library for use within Guidance
|
|
6
6
|
Author: Michal Moskal
|
|
7
7
|
License-Expression: MIT
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
9
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
10
|
-
Project-URL: repository, https://github.com/microsoft/llguidance
|
|
11
10
|
Project-URL: issue_tracker, https://github.com/microsoft/llguidance/issues
|
|
11
|
+
Project-URL: repository, https://github.com/microsoft/llguidance
|
|
12
12
|
|
|
13
|
+
<div align="right">
|
|
14
|
+
<a href="https://discord.gg/cjPfAK43dz"><img src="https://img.shields.io/badge/Discord-Join%20Us-5865F2?logo=discord&logoColor=white" alt="Discord"></a>
|
|
15
|
+
<a href="mailto:guidanceai@microsoft.com"><img src="https://img.shields.io/badge/Email-guidanceai%40microsoft.com-0078D4?logo=microsoft-outlook&logoColor=white" alt="Email"></a>
|
|
16
|
+
<img src="https://img.shields.io/badge/Hours-10am--2pm%20Pacific-gray" alt="Hours">
|
|
17
|
+
</div>
|
|
18
|
+
|
|
13
19
|
# Low-level Guidance (llguidance)
|
|
14
20
|
|
|
15
21
|
<p align="center">
|
|
@@ -35,7 +41,7 @@ Project-URL: issue_tracker, https://github.com/microsoft/llguidance/issues
|
|
|
35
41
|
## About
|
|
36
42
|
|
|
37
43
|
This library implements constrained decoding (also called constrained sampling or
|
|
38
|
-
structured outputs) for Large
|
|
44
|
+
structured outputs) for Large Language Models (LLMs).
|
|
39
45
|
It can enforce arbitrary context-free grammar on the output of LLM
|
|
40
46
|
and is fast - on the order of 50μs of CPU time per token
|
|
41
47
|
(for 128k tokenizer) with negligible startup costs.
|
|
@@ -111,14 +117,14 @@ Thus, with 16 cores and a 10ms forward pass, llguidance can handle batch sizes u
|
|
|
111
117
|
|
|
112
118
|
## Building
|
|
113
119
|
|
|
114
|
-
- [install rust](https://www.rust-lang.org/tools/install); 1.
|
|
120
|
+
- [install rust](https://www.rust-lang.org/tools/install); 1.87 or later
|
|
115
121
|
|
|
116
122
|
If you just need the C or Rust library (`llguidance`),
|
|
117
123
|
check the [parser](./parser/README.md) directory.
|
|
118
124
|
|
|
119
125
|
For Python bindings:
|
|
120
126
|
|
|
121
|
-
- install python 3.
|
|
127
|
+
- install python 3.10 or later; very likely you'll need a virtual env/conda
|
|
122
128
|
- run `./scripts/install-deps.sh`
|
|
123
129
|
- to build and after any changes, run `./scripts/test-guidance.sh`
|
|
124
130
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
llguidance\__init__.py,sha256=tlrM-GzMdClgSIEblgA4ixP10h51VDJY5ejIP5FFJJw,620
|
|
2
|
+
llguidance\_grammar_from.py,sha256=kEgwhVYBq3NE_O9MGjIRpci7dgOneLC9CvVGWpKEO84,2452
|
|
3
|
+
llguidance\_lib.pyd,sha256=cnSFoKOc8xH8BUF2z-ywPDoj0TqqnEnSqPy29qia19g,7291904
|
|
4
|
+
llguidance\_lib.pyi,sha256=ov5iAQT137lnMSQuLZ9TyfgP9TsOEbhsO7R-6V7Czp8,25530
|
|
5
|
+
llguidance\_struct_tag.py,sha256=wEJd9KGZTpS-R1ZXyyRFmr-48aYOZw_tI4PhIRy9h4g,4548
|
|
6
|
+
llguidance\_tokenizer.py,sha256=9jonF41IUypGtV6lVUl9l9FGAyn9HNnDb9HKNDywZuQ,1120
|
|
7
|
+
llguidance\_util.py,sha256=6RMYO61KUynAym7KcbDn9VEMGcGdv7rj2yo6fITC-u8,274
|
|
8
|
+
llguidance\cli.py,sha256=-vXUfe8u-qdFyaFjwDNd0OjUZ0UvKERl7Zr-Ea9KvKc,2461
|
|
9
|
+
llguidance\gbnf_to_lark.py,sha256=YsFNyVXrzG3-cjqlcrcuoG1RdquVtZJz43X_lSAXL7Y,17187
|
|
10
|
+
llguidance\hf.py,sha256=3LNNqC4_KafPe6bKP-Ba0aGsOVg3MqvuMvY6QYth0fY,1980
|
|
11
|
+
llguidance\llamacpp.py,sha256=2LdNjiNku-8xGcswGEQga57FUsRgzdf4Z4BrLVBUfAg,2352
|
|
12
|
+
llguidance\mlx.py,sha256=iOWqkhYItQRDOcQtOnH2tmtYmtiQGD_Y_RIYjYe4DZY,2507
|
|
13
|
+
llguidance\numpy.py,sha256=NMJxvI_rG2m_kYLDXuSAnxJfjkea9hvcUIyvl70OhnM,4048
|
|
14
|
+
llguidance\py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
+
llguidance\tiktoken.py,sha256=sE4QWj88dANfdM0Y50ZvFI7ku6zBFomUCE4bRTtewF4,1135
|
|
16
|
+
llguidance\torch.py,sha256=Kr-mlF1FXQD4Iwuv_AvSpj_kXKX9FVTw-_un8JK9deU,4090
|
|
17
|
+
llguidance-1.5.0.dist-info\METADATA,sha256=RSr9amkc8jFvwW_LqUP-0bL7soHZz7MwVrhRj9VekB0,10893
|
|
18
|
+
llguidance-1.5.0.dist-info\WHEEL,sha256=OD0Is1kLHE07aD7XukSVDFU8ymUMI4Fdg0tKYWce3N0,95
|
|
19
|
+
llguidance-1.5.0.dist-info\licenses\LICENSE,sha256=mQaUD2Gx8LUz-n2ZuvVReLKAj74RPqUd-_rYVyzNXys,1162
|
|
20
|
+
llguidance-1.5.0.dist-info\RECORD,,
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
llguidance-1.3.0.dist-info/METADATA,sha256=2y5QnhlB2fabweFtiAIpeabETYQh9xdTFSjyJjyElO0,10436
|
|
2
|
-
llguidance-1.3.0.dist-info/WHEEL,sha256=dtDRtmb8ugdlQQiOTIfQg6qwccecUkp34WgpWvjGLGA,94
|
|
3
|
-
llguidance-1.3.0.dist-info/licenses/LICENSE,sha256=mQaUD2Gx8LUz-n2ZuvVReLKAj74RPqUd-_rYVyzNXys,1162
|
|
4
|
-
llguidance/__init__.py,sha256=tlrM-GzMdClgSIEblgA4ixP10h51VDJY5ejIP5FFJJw,620
|
|
5
|
-
llguidance/_grammar_from.py,sha256=kEgwhVYBq3NE_O9MGjIRpci7dgOneLC9CvVGWpKEO84,2452
|
|
6
|
-
llguidance/_lib.pyd,sha256=f1re0RSpRXHw6hDwX-2F-BI398uGWzDcha3PzVfoYwY,7515136
|
|
7
|
-
llguidance/_lib.pyi,sha256=tc0mb-ZKH3LjodEf_aIdLPXFLuEbqGI3flxQpxZn-Bw,24893
|
|
8
|
-
llguidance/_struct_tag.py,sha256=wEJd9KGZTpS-R1ZXyyRFmr-48aYOZw_tI4PhIRy9h4g,4548
|
|
9
|
-
llguidance/_tokenizer.py,sha256=9jonF41IUypGtV6lVUl9l9FGAyn9HNnDb9HKNDywZuQ,1120
|
|
10
|
-
llguidance/_util.py,sha256=6RMYO61KUynAym7KcbDn9VEMGcGdv7rj2yo6fITC-u8,274
|
|
11
|
-
llguidance/cli.py,sha256=-vXUfe8u-qdFyaFjwDNd0OjUZ0UvKERl7Zr-Ea9KvKc,2461
|
|
12
|
-
llguidance/gbnf_to_lark.py,sha256=YsFNyVXrzG3-cjqlcrcuoG1RdquVtZJz43X_lSAXL7Y,17187
|
|
13
|
-
llguidance/hf.py,sha256=3LNNqC4_KafPe6bKP-Ba0aGsOVg3MqvuMvY6QYth0fY,1980
|
|
14
|
-
llguidance/llamacpp.py,sha256=2LdNjiNku-8xGcswGEQga57FUsRgzdf4Z4BrLVBUfAg,2352
|
|
15
|
-
llguidance/mlx.py,sha256=Q2cNocnFB3xqCCg614iE0wPcumBFJBvo0pG5JTpShds,2494
|
|
16
|
-
llguidance/numpy.py,sha256=eMIihG5rcPWFMMWjwl-ZPSkcEo8BXKZFUHaIHkxnFhw,3409
|
|
17
|
-
llguidance/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
llguidance/tiktoken.py,sha256=sE4QWj88dANfdM0Y50ZvFI7ku6zBFomUCE4bRTtewF4,1135
|
|
19
|
-
llguidance/torch.py,sha256=PzTI7wRiznXnH7u4_iEP6NL2wmL2cN8p-UlR0PE8JJ4,3451
|
|
20
|
-
llguidance-1.3.0.dist-info/RECORD,,
|
|
File without changes
|