Text Generation
Transformers
PyTorch
constrained-decoding
reachability
logit-processor
structured-generation
grammar-masking
dfa
fsm
Instructions to use uuugi/gclm-constrained-decoding with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use uuugi/gclm-constrained-decoding with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="uuugi/gclm-constrained-decoding")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("uuugi/gclm-constrained-decoding", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use uuugi/gclm-constrained-decoding with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "uuugi/gclm-constrained-decoding" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "uuugi/gclm-constrained-decoding", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/uuugi/gclm-constrained-decoding
- SGLang
How to use uuugi/gclm-constrained-decoding with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "uuugi/gclm-constrained-decoding" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "uuugi/gclm-constrained-decoding", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "uuugi/gclm-constrained-decoding" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "uuugi/gclm-constrained-decoding", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use uuugi/gclm-constrained-decoding with Docker Model Runner:
docker model run hf.co/uuugi/gclm-constrained-decoding
Fix inline math text notation in Mathematical Formulation and Scaling sections
Browse files
README.md
CHANGED
|
@@ -51,7 +51,7 @@ GCLM mathematically guarantees that an LLM will strictly reach designated goal/a
|
|
| 51 |
## 📐 Mathematical Formulation
|
| 52 |
|
| 53 |
### 1. Offline Backward BFS Table Builder
|
| 54 |
-
Given an FSM
|
| 55 |
|
| 56 |
```python
|
| 57 |
# Base Step (t = 0):
|
|
@@ -62,7 +62,7 @@ R[t, s] = R[t-1, s] OR (∃ v ∈ V such that δ(s, v) >= 0 and R[t-1, δ(s, v
|
|
| 62 |
```
|
| 63 |
|
| 64 |
### 2. Strict O(1) Runtime Logits Masking
|
| 65 |
-
At decoding step
|
| 66 |
|
| 67 |
```python
|
| 68 |
# Step 1: Vectorized check for valid transitions within remaining budget
|
|
@@ -139,7 +139,7 @@ gclm_project/
|
|
| 139 |
---
|
| 140 |
|
| 141 |
### 4. FSM Complexity & Strict O(1) Runtime Scaling
|
| 142 |
-
> Scaling state count
|
| 143 |
|
| 144 |
| Vocabulary Size (V) | State Count (S) | Offline BFS Time | Memory Footprint | Online Latency per Token |
|
| 145 |
| :--- | :---: | :---: | :---: | :---: |
|
|
|
|
| 51 |
## 📐 Mathematical Formulation
|
| 52 |
|
| 53 |
### 1. Offline Backward BFS Table Builder
|
| 54 |
+
Given an FSM `(S, Σ, δ, s_0, S_goal)` and maximum token budget `T_max`, we precompute a reachability tensor `R` of shape `(T_max + 1, |S|)` via vectorized backward BFS:
|
| 55 |
|
| 56 |
```python
|
| 57 |
# Base Step (t = 0):
|
|
|
|
| 62 |
```
|
| 63 |
|
| 64 |
### 2. Strict O(1) Runtime Logits Masking
|
| 65 |
+
At decoding step `k` with remaining token budget `T_rem = T_max - k`:
|
| 66 |
|
| 67 |
```python
|
| 68 |
# Step 1: Vectorized check for valid transitions within remaining budget
|
|
|
|
| 139 |
---
|
| 140 |
|
| 141 |
### 4. FSM Complexity & Strict O(1) Runtime Scaling
|
| 142 |
+
> Scaling state count `|S|` from 10 to 10,000 (1,000x increase). Plot saved as `paper_figure_scaling.png`.
|
| 143 |
|
| 144 |
| Vocabulary Size (V) | State Count (S) | Offline BFS Time | Memory Footprint | Online Latency per Token |
|
| 145 |
| :--- | :---: | :---: | :---: | :---: |
|