How 1rgs/jsonformer works
Jsonformer wraps a Hugging Face model and tokenizer to produce schema-shaped JSON: it walks object and array schemas, inserts fixed structure into a progressive prompt, and delegates value generation to the model. Number and string generation use stopping criteria, while number generation also restricts allowed tokens. The package additionally exports a value-highlighting formatter. The graph reflects the sampled runtime code and README; it does not expand the unsampled notebooks into product components.
Main entry points: main.py Scalar generation · logits_processors.py Number token filter · format.py Value highlighter
Components 10
Schema generation
- Jsonformer
jsonformer/main.py - Schema traversal
jsonformer/main.py - Prompt assembly
jsonformer/main.py - Scalar generation
jsonformer/main.py
Token constraints
- Number token filter
jsonformer/logits_processors.py - Stopping criteria
jsonformer/logits_processors.py
Output formatting
- Value highlighter
jsonformer/format.py
Other components
- Caller
- Hugging Face model
- Tokenizer
Connections 11
- Caller → Jsonformer: calls
README.md - Jsonformer → Schema traversal: traverses schema
jsonformer/main.py - Schema traversal → Prompt assembly: builds progress
jsonformer/main.py - Schema traversal → Scalar generation: generates values
jsonformer/main.py - Scalar generation → Hugging Face model: generates tokens
jsonformer/main.py - Scalar generation → Tokenizer: encodes and decodes
jsonformer/main.py - Scalar generation → Number token filter: applies filter
jsonformer/main.py - Scalar generation → Stopping criteria: uses criteria
jsonformer/main.py - Number token filter → Tokenizer: inspects vocabulary
jsonformer/logits_processors.py - Stopping criteria → Tokenizer: decodes tokens
jsonformer/logits_processors.py - Caller → Value highlighter: formats values