by agentcoops · 1y ago · 0 comments
Interestingly, Knuth has stated that his development of Literate Programming:
http://literateprogramming.com/
was more important than TeX --- fortunately, his publishing _TeX: The Program_:
https://www.goodreads.com/book/show/499934.Computers_Typeset...
has been very helpful to folks developing successors and add-ons and new versions, facilitating the creation of web2c and change files which made tools such as pdftex and omega and xetex and luatex possible).
Maybe I was just unlucky or you had better luck with another model. But I was very surprised to here this because Typst is my chief example for a language that LLMs are bad at.
Claude did generated a rather good template for what I needed. It did not compile at first but I copy-pasted the errors and it fixed them.
Not all was good, though. It used literal bullets instead of `-` required for lists, but on whole the experience was positive.
It had taken me less time to fix the template than it would been taken to write it from scratch.
Something which Claude was good at. I throw him a crude ASCII "art" representation of what I want and get the right Typst code back.
You can't escape hallucinations, of course, but they can be mitigated somewhat. Don't ask it to generate a bunch of code at once. Feed it a snippet of code, and tell it precisely what you want it to do. These are general LLM rules applicable to any language and project, and I've had success with them with Typst. I also used it just to get explanations, or general ideas about how to do something, and then figure out the actual syntax and working code myself. It's strange that you haven't had luck with pasting docs. That has usually worked well for me.
I also think that LLMs don't struggle as much with Typst because the language is relatively simple, and there is little bad and outdated content about it online, so they weren't trained on it. I assume that the API probably hasn't changed as much either and there haven't been many compatibility issues, so it's not as important which version the LLM was trained on.
I did not try Claude though. Perhaps that performs better.
edit: I just prompted chatGPT with this and pasted the result into the Typst editor. 20 compile errors.
>Make a Typst doc with two columns per page and US page dimensions
Same prompt but for Latex and pasted in overleaf. No problems.
Interestingly, I've had the opposite experience. ChatGPT and Claude repeatedly gave me errors, apologized profusely, and then said, "ah, I had the wrong keyword. It's actually <blahblah>"--and that would simply give me another error and a subsequent apology.
At least Gemini had the good taste of telling me that it didn't know how to do what I wanted with typst.
It's certainly possible that I was trying to do something a little too unusual (who knows), but I chalked it up to the LLMs not having a large enough corpus of training text.
On the bright side, the typst documentation is quite good and it was just a matter of adjusting example code that got me on track.
> I chalked it up to the LLMs not having a large enough corpus of training text.
I'm inclined to believe the opposite, actually. It's not so much about the size of the training data, but the quality of it. Garbage in, garbage out. Typst is still very young, and there's not much bad code in the wild.
And the language itself plays a large role. A simple language with less esoteric syntax and features should be easier to train on and generate than something more complex. This is why I think LLMs are notoriously bad at generating Rust code. There's plenty of it to train on, but Rust is a deep pit of complexity and unusual syntax. Though it helps when the language is strict and statically typed, so that the compiler can catch issues early. I would dread relying on generated Python code, despite of how popular and simple it is on the surface.