xm

xmllm – Structured LLM streaming output using lenient XML parsing

Hacker News

xmllm – Structured LLM streaming output using lenient XML parsing

Hi HN. I made a little JS library for streaming structured data from LLMs using leniently-parsed XML as a medium. E.g. await simple('fun pet names', { schema: { name: Array(String) }, model: 'openrouter:mistralai/ministral-3b' }); // => ["Daisy", "Whiskers", "Rocky"] Demos: xmllm.j11y.io When using LLMs, I've ended up gravitating towards boring time-tested XML-esque tag-based delimiters instead of JSON/function-calling for the following reasons: - Diverse presence in training corpuses (consider flavours of content commonly adjacent to these syntaxes vs. JSON) - HTML was built for fallible humans to write; LLMs are equally fallible. Let them cook [html]! - IME better and more consistent adherance than very delicate JSON/YAML etc. - Lenient by nature (following Postel's law of being liberal in what you accept) - No provider lock-in to function-calling/'tool' APIs - Supports streaming with 'eventually-fulfilled schemas' for progressive UI updates - CSS-style selections when you need more flexibility than schemas It is provider/API/model-agnostic and has good schema-adherance across models from Qwen 2.5B and Ministral 3B all the way up to the frontier stuff like Claude and GPT-4o. It has in-built model preferencing and fallbacks (like asking it to prefer Claude but fall back to Mistral via e.g. openrouter/togetherai/whatever), plus 'inner' truncation to avoid context limitations. I originally built this for my own projects I've found it to be a stable abstraction and quick to prototype with on the client-side especially (with the proxy feature). I wanted to share it here mostly to gather feedback and hear what other people are doing to source structured schema-conforming data from LLMs? I know there's new work being done in constraining big param LLMs to fixed grammars, and that's probably the future, but I've no real context or knowledge about that and for the past few years I've just been trying to /get stuff done/ in a reliable and consistant way. Hence this project. Demos and sandbox-y things (try the top flag generator thing!) https://xmllm.j11y.io Repo: https://github.com/padolsey/xmllm Blog post (+background and other reflections): https://blog.j11y.io/2024-12-15_xmllm/ And please, if you've a moment: I'm vvv interested in what people are currently using to get reliable structured data from LLMs? Perhaps most are completely satisfied with Function-Calling APIs?

Share card

Actual performance

5points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Product HuntOn track for Day 1 leaderboard · Strong signals: claude, model, new · Missing: mac, agents, macos
93%93% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Indie HackersFits the IH revenue-focused audience · Strong signals: supports, para · Missing: reddit linkedin, podcasting, created
88%88% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: ide, io · Missing: https docs, excited, just released
58%58% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
AppSumoStrong fit for a featured deal · Strong signals: plus · Missing: platform, intuitive, reviews
52%52% predicted probability of success on AppSumo, based on ML models trained on real launch data.
TrustMRRLess likely to generate early MRR · Strong signals: way, para · Missing: mobile apps, ios, personal
34%34% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Strong signals: arr, training · Missing: mrr, revenue, profit
16%16% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Missing: web3, chat, crypto
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Incorrect prediction on native model

Similar products

Us
Using zod to get structured and typed output from ChatGPT in TypeScript35%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Using zod to get structured and typed output from ChatGPT in TypeScript

Hacker News35
LL
LLMdantic: Structured Output Is All You Need38%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

LLMdantic: Structured Output Is All You Need

Hacker News8
Go
Go-xmlrpc - golang XML RPC using go generate(generate xml parse code)21%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Go-xmlrpc - golang XML RPC using go generate(generate xml parse code)

Hacker News1
St
Structured output from LLMs without reprompting63%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Structured output from LLMs without reprompting

Hacker News174
LL
LLGTRT: TensorRT-LLM+Rust server w/ OpenAI-compat and Structured Output72%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

LLGTRT: TensorRT-LLM+Rust server w/ OpenAI-compat and Structured Output

Hacker News6
Gu
Guiding LLM outputs using Zod42%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Guiding LLM outputs using Zod

Hacker News3
Pi
Pico-ASHA – Audio streaming to hearing aids using a RPi Pico W76%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Pico-ASHA – Audio streaming to hearing aids using a RPi Pico W

Hacker News3
A
A minimal implementation of LLM output watermarking35%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

A minimal implementation of LLM output watermarking

Hacker News2
Ge
Generate human-readable ndiff output when comparing 2 Nmap XML files35%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Generate human-readable ndiff output when comparing 2 Nmap XML files

Hacker News1
Vi
Video Streaming Platform Using Svelte – Persian43%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Video Streaming Platform Using Svelte – Persian

Hacker News2