← All projects
Project record1 mention
Originally shared on Hacker News

structlm

A library that generates schemas for structured JSON outputs from LLMs using a TypeScript-like custom schema definition, based on the idea that LLMs read TypeScript types better than JSON schema types. Reported results show accuracy on par with or better than JSON schemas while using 20-40% fewer tokens.

Last shared
01 / The problem

What it addresses

JSON schema types are less effectively read by LLMs and consume more tokens than TypeScript-style type definitions.

02 / Source history

Shared over time

Each entry reflects what was shared on that date. Details may have changed since then.

  1. structlm

    A library that generates schemas for structured JSON outputs from LLMs using a TypeScript-like custom schema definition, based on the idea that LLMs read TypeScript types better than JSON schema types. Reported results show accuracy on par with or better than JSON schemas while using 20-40% fewer tokens.

    Problem: JSON schema types are less effectively read by LLMs and consume more tokens than TypeScript-style type definitions.

    Posted by @lunarcave · Original source ↗

    Source text · @lunarcave · · Source ↗

    I've been tinkering around with a library that can generate schemas for structured JSON outputs, according to a Typescript-like custom schema definition: https://github.com/nadeesha/structlm