adrienbrault / json-schema-to-gbnf

Converts JSON-Schema to GBNF grammar to use with llama.cpp

Home Page:https://adrienbrault.github.io/json-schema-to-gbnf/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

Convert a JSON-Schema to a GBNF grammar, to use with llama.cpp.

This implementation aims to support more of the JSON-Schema specification than alternatives.

See src/convert.test.ts and src/regexp-convert.test.ts for examples of supported features.

Use it online: adrienbrault.github.io/json-schema-to-gbnf

Development

To install dependencies:

bun install

To run:

bun run src/index.ts "<json schema>"

To build and run the website:

bun run build-site
bunx serve build

To run tests in watch mode when developing:

bun test --watch

Resources

Alternatives

The following are alternative JSON-Schema to GBNF converters:

llama.cpp alternatives for JSON constrained output

About

Converts JSON-Schema to GBNF grammar to use with llama.cpp

https://adrienbrault.github.io/json-schema-to-gbnf/

License:MIT License


Languages

Language:TypeScript 91.7%Language:Shell 7.6%Language:HTML 0.7%