3 ms·
LLMs work by outputting a value for each token, then using those values to generate a probability distribution. Usually, this will be through a function like s
by MereInterest 3y ago
LLMs work by outputting a value for each token, then using those values to generate a probability distribution. Usually, this will be through a function like softmax [0], but there's nothing preventing you from doing some post-processing first. That post processing could be aware of the tokens that would be valid as the next token in a JSON format, and set the probabilities of all other tokens to zero. That way, even if the training data contains malformed JSON, the generator is still constrained to produce valid JSON.
[0] https://en.wikipedia.org/wiki/Softmax_function https://en.wikipedia.org/wiki/Softmax_function
- RyEgswuCsn 3y agoBut that is not the LLM learning to produce valid JSON —— as some other commenters mentioned, you can get valid json without the LLM. Sure it could be useful, but not really impressive.