Ask HN: AI to study my DSL and then output it?
Ideally I want to contain and run LLM output of my domain-specific language, but it seems that I would need to fine-tune existing models. What’s the easiest online or local solution?
How to automatically generate: a broad array of security tests; the most efficient code; the most readable and extensible code
26 comments
[ 3.4 ms ] story [ 74.0 ms ] threadWhat I want to do is train for some inputted amount of documentation, sample code, and maybe even interpreter implementation source and then ask it: “Generate lots of instructions to gain elevated access.” Or maybe even: “Generate social media widget site.” But of course, in the given language.
Implementation of PaLM in Elemental (I guess?): https://thetaplane.com/ai/palm
https://huggingface.co/blog/codeparrot
for some idea of how to train a code generator.
I’m still noodling on how to send a full page screenshot to a model and get it to return the individual images (or the bounds of them) in the page.
- Use multi-shot prompting with something like guardrails to try prompting a commercial model until it works. [1]
- Use a local model with a final layer that steers token selection towards syntactically valid tokens [2]
[1] https://github.com/ShreyaR/guardrails
[2] "Structural Alignment: Modifying Transformers (like GPT) to Follow a JSON Schema" @ https://github.com/newhouseb/clownfish (full disclosure: this is my work)
This technique generalizes to pretty much any grammar one can specify. I weakly hypothesize that by making it impossible for the LM to output syntactically invalid text, the model's task performance improves not just because all of its outputs are valid, but also because part of the model's "processing power" gets "rerouted" from trying to understand and follow the grammar it's writing, to applying improved reasoning overall.
> Does structured decoding increase the observability of emergent world models in these models? To make an analogy: I may not represent an opinion of how something works if I am not confident in it, but if I am forced to present an opinion we might find out that I in fact have (or have not) grasped something.
In practice, however, without tight integration with beam search, the autoregressive nature of these models means that the syntactic steering may result in the models rabbit-holing themselves without forward looking visibility that's obvious from the defined grammar. I.e. if it was forced to choose between "Don't Jump" and "Do run" in some hypothetical example, the set of tokens that it would likely be deciding between is "Don't" and "Do" with no idea what is going to end up syntactically required after those tokens.
See previous comment here: https://news.ycombinator.com/item?id=35447368
EDIT: suspension is halting?
I'd be super impressed if any other approach worked as well and would fall under the category of "easy". Keep us updated on what you go with!
If you have a particular data structure you want to have the LLM generate or manipulate, which there aren't large quantities of in the training set, you might want to consider writing a translator that will translate it into a format the LLM natively 'speaks', using the LLM on that, and then translating back into your DSL.
Going this direction and also adding examples in some sort of vector store, as others have suggested, could be a good direction.
Right now, we are playing around with the idea of using a classification layer to detect which schema elements are likely involved, and then dynamically including explanations for those elements in the final prompt.
Our attempts at fine tuning ended after about 2 weeks of struggling. I don't think it's viable for a certain range of domain-specific tasks.
https://github.com/neuml/txtai/blob/master/examples/33_Query...