Live data from Hacker News

OpenAI is good at unminifying code

glama.ai

61–70 of 321 posts

Re: OpenAI is good at unminifying code

#61

Earlier quoted context omitted.

This refers to the fact that ChatGPT generated version is missing some characters that are used in the original example. Namely, [looks like HN does not allow me to paste unicode characters, but I am referring to the block characters] can be seen in their version, but cannot be seen in the ChatGPT generated version. However, it very well might be that it is simply because I didn't include all the necessary context. D…

It's because the author miscopy-pasted the original code: those "â–‘â–’â–“â–ˆ" at the end of the O5 string are supposed to be the block characters. E.g. "â–‘" in Windows-1252 [0] is 0xE2 0x96 0xE2 which, in UTF-8, exactly the encoding for U+2592 MEDIUM SHADE [1]. [0] https://en.wikipedia.org/wiki/Windows-1252#Character_set [1] https://www.compart.com/en/unicode/U+2592

Possible that this is the mistake.

However, I don't think I miscopied the original code.

https://reactive.network/assets/index-8b4ef4ac.js

If you look for `oahkbdpqwmZO0QLCJUYXzcvunxrjft` in the output, you should see that those characters appear exactly like that. Maybe an issue with encoding of the script file?

Re: OpenAI is good at unminifying code

#62
post #20
post #4

Anyone working on decompiler LLMs? Seems like we could render all code open source. Training data would be easy to make in this case. Build tons of free GitHub code with various compilers and train on inverting compilation. This is a case where synthetic training data is appropriate and quite easy to generate. You could train the decompiler to just invert compilation and the use existing larger code LLMs to do things…

> Seems like we could render all code open source Unfortunately not really. Having the source is a first step, but you also need the rights to use it (read, modify, execute, redistribute the modifications), and only the authors of the code can grant these rights.

Doesn't it count as 'clean room' reverse engineering - or alternatively, we could develop an LLM that's trained on the outputs and side-effects of any given function, and learns to reproduce the source code from that.

Or, going back to the original idea, while the source code produced in such a way might be illegal, it's very likely 'clean' enough to train an LLM on it to be able to help in reproducing such an application.

Re: OpenAI is good at unminifying code

#63
post #12

LLMs are excellent at text transformation. It's their core strength and I don't see it being used enough.

It’s not only their core strength — it’s what transformers were designed to do and, arguably, it’s all they can do. Any other supposed ability to reason or even retain knowledge (rather than simply regurgitate text without ‘understanding’ its intended meaning) is just a side effect of this superhuman ability.

> it’s all they can do

this overlooks how they do it. we don't really know. it might be logical reasoning, it might be a very efficient content addressable human-knowledge-in-a-blob-of-numbers lookup table... it doesn't matter if they work, which they do, sometimes scarily well. dismissing their abilities because they 'don't reason' is missing the forest for the trees in that they'd be capable of reasoning if they were able to run sat solvers on their output mid generation.

Re: OpenAI is good at unminifying code

#65

JS minification is fairly mechanical and comparably simple, so the inversion should be relatively easy. It would be of course tedious enough to be manually done in general, but transformations themselves are fairly limited so it is possible to read them only with some notes to track mangled identifiers. A more general unminification or unobfuscation still seems to be an open problem. I wrote handful of programs that…

> JS minification is fairly mechanical and comparably simple, so the inversion should be relatively easy.

Just because a task is simple doesn't mean its inverse need be. Examples:

  - multiplication / prime factorization
  - deriving / integrating
  - remembering the past / predicting the future
Code unobfuscation is clearly one of those difficult inverse problems, as it can be easily exacerbated by any of the following problems:

  - bugs
  - unused or irrelevant routines
  - incorrect implementations that incidentally give the right results
In that sense, it would be fortunate if chatGPT could give decent results at unobfuscating code, as there is no a priori expectation that it should be able to do so. It's good that you've also checked chatGPT's code unobfuscation capabilities on a more difficult problem, but I think you've only discovered an upper limit. I wouldn't consider the example in the OP to be trivial.

Re: OpenAI is good at unminifying code

#66
post #9
post #6

Earlier quoted context omitted.

Unminifying isn't decompiling. It's just renaming variable and functions and inserting line breaks.

No but it’s a baby brother of the same problem. Compiling is a much more complex transform but ultimately it is just a code transform.

It is true that compilation and minification are both code transformations (it's a correct reduction [1]), but this doesn't seem a very useful observation in this discussion. In the end, everything you do to something is an operation. But that's not very workable.

In practice, compilation is often (not always, agreed!) from a language A to a lower level language B such that the runtime for language A can't run language B or vice-versa, if language A has a runtime at all. Minification is always from language A to the same language A.

The implication is that in practice, deminification is not the same exercise as decompilation. You can even want to run a deminification phase after a decompilation phase, using two separate tools, because one tool will be good at translating back, and the other will be good at pretty printing.

[1] https://en.wikipedia.org/wiki/Reductionism

Re: OpenAI is good at unminifying code

#69
post #9
post #6

Earlier quoted context omitted.

Unminifying isn't decompiling. It's just renaming variable and functions and inserting line breaks.

No but it’s a baby brother of the same problem. Compiling is a much more complex transform but ultimately it is just a code transform.

[deleted]

Re: OpenAI is good at unminifying code

#70
post #4

Anyone working on decompiler LLMs? Seems like we could render all code open source. Training data would be easy to make in this case. Build tons of free GitHub code with various compilers and train on inverting compilation. This is a case where synthetic training data is appropriate and quite easy to generate. You could train the decompiler to just invert compilation and the use existing larger code LLMs to do things…

There was a paper about this at CGO earlier this year [1]. Correctness is a problem that is hard to solve, though; 50% accuracy might not be enough for serious use cases, especially given that the relation to the original input for manual intervention is hard to preserve.

[1]: https://arxiv.org/abs/2305.12520

Post reply on HN