Many use LLM use cases involve generating outputs with a specific structure.
โก๏ธ For instance when using an LLM as a judge to evaluate another model's outputs, you need it to give you not only a score, but also the rationale for this score, and maybe a confidence level. So you do not need only "score: 1", but more a dictionary like:
{
"rationale": "The answer does not match the true answer at all.""score": 1,
"confidence_level": 0.85
}
๐ค How to force your LLM to generate such a structured output?
๐๏ธ ๐๐ผ๐ป๐๐๐ฟ๐ฎ๐ถ๐ป๐ฒ๐ฑ ๐ฑ๐ฒ๐ฐ๐ผ๐ฑ๐ถ๐ป๐ด is a great technique to generate structured output: you can specify a grammar (=set of rules) that the output should follow, and ๐ฐ๐ผ๐ป๐๐๐ฟ๐ฎ๐ถ๐ป๐ฒ๐ฑ ๐ฑ๐ฒ๐ฐ๐ผ๐ฑ๐ถ๐ป๐ด ๐๐ต๐ฒ๐ป ๐ณ๐ผ๐ฟ๐ฐ๐ฒ๐ ๐๐ต๐ฒ ๐ฑ๐ฒ๐ฐ๐ผ๐ฑ๐ฒ๐ฟ ๐๐ผ ๐ผ๐ป๐น๐ ๐ฝ๐ถ๐ฐ๐ธ ๐๐ผ๐ธ๐ฒ๐ป๐ ๐๐ต๐ฎ๐ ๐ฟ๐ฒ๐๐ฝ๐ฒ๐ฐ๐ ๐๐ผ๐๐ฟ ๐ด๐ฟ๐ฎ๐บ๐บ๐ฎ๐ฟ.
I've created a guide to show you how to use it, both via our Inference API and locally using ๐ฐ๐ถ๐ต๐ญ๐ช๐ฏ๐ฆ๐ด!