Live data from Hacker News

OpenAI is good at unminifying code

glama.ai

251–260 of 321 posts

Re: OpenAI is good at unminifying code

#251

Earlier quoted context omitted.

Does it work with huge files? I'm talking about something like 50k lines. Edit: I'm currently trying it with a mere 1.2k JS file (openai mode) it's only 70% done after 20 minutes. Even if it works therodically with 50k LOC file, I don't think you should try.

It has this in the README > Large files may take some time to process and use a lot of tokens if you use ChatGPT. For a rough estimate, the tool takes about 2 tokens per character to process a file: > echo "$((2 * $(wc -c So for refrence: a minified bootstrap.min.js would take about $0.5 to un-minify using ChatGPT. > Using humanify local is of course free, but may take more time, be less accurate and not possible wit…

This only talks about the cost.

I'm more concerned about if it can actually deobfuscate such large file (context) and generate useful results.

Re: OpenAI is good at unminifying code

#252
post #225

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. This is stated as if it's a truism, but I can't understand how you can actually believe this. Converting `let userSignedInTimestamp = new Date()` to `let x = new Date()` is trivial, but going the other way probably requires reading and understanding the rest of the surrounding code to see in what contexts `x` is…

And I can’t understand why any reasonably intelligent human feels the need to be this abrasive. You could educate but instead you had to be condescending.

Re: OpenAI is good at unminifying code

#253
post #97

Author of HumanifyJS here! I've created specifically a LLM based tool for this, which uses LLMs on AST level to guarantee that the code keeps working after the unminification step: https://github.com/jehna/humanify

Came here to say Humanify is awesome both as a specific tool and in my opinion a really great way to think about how to get the most from inherently high-temperature activities like modern decoder nucleus sampling.

+1

Re: OpenAI is good at unminifying code

#254

This is an example of superior intellectual performance to humans. There’s no denying it. This task is intellectual. Does not involve rote memorization. There are not tons and tons of data pairs on the web of minimized code and unminified code for llms to learn from. The llm understands what it is unminifying and it is in general superior to humans on this regard. But only in this specific subject.

I don’t claim expertise in AI or understanding intelligence, but could we also say that a pocket calculator really understands arithmetic and has superior intellectual performance compared to humans?

https://chatgpt.com/share/a430518b-16f8-47bb-8cb7-d9b8518376...

Re: OpenAI is good at unminifying code

#255
post #239

This is an example of superior intellectual performance to humans. There’s no denying it. This task is intellectual. Does not involve rote memorization. There are not tons and tons of data pairs on the web of minimized code and unminified code for llms to learn from. The llm understands what it is unminifying and it is in general superior to humans on this regard. But only in this specific subject.

I'm bullish on AI, but I'm not convinced this is an example of what you're describing. The challenge of understanding minified code for a human comes from opaque variable names, awkward loops, minimal whitespacing, etc. These aren't things that a computer has trouble with: it's why we minify in the first place. Attention, as a scheme, should do great with it. I'd also say there is tons of minified/non-minified code o…

minification and unminification is a heuristic process not an algorithmic one. It is akin to decompiling code or reverse engineering. It's a step beyond just your typical AI you see in a calculator.

Re: OpenAI is good at unminifying code

#257
post #97

Author of HumanifyJS here! I've created specifically a LLM based tool for this, which uses LLMs on AST level to guarantee that the code keeps working after the unminification step: https://github.com/jehna/humanify

Would it be difficult to add a 'rename from scratch' feature? I mean a feature that takes normal code (as opposed to minified code) and (1) scrubs all the user's meaningful names, (2) chooses names based on the algorithm and remaining names (ie: the built-in names). Sometimes when I refactor, I do this manually with an LLM. It is useful in at least two ways: it can reveal better (more canonical) terminology for names…

Yes, I think you could use HumanifyJS for that. The way it works is that:

1. I ask LLM to describe what the meaning of the variable in the surrounding code

2. Given just the description, I ask the LLM to come up with the best possible variable name

You can check the source code for the actual prompts:

https://github.com/jehna/humanify/blob/eeff3f8b4f76d40adb116...

Re: OpenAI is good at unminifying code

#258
post #97

Author of HumanifyJS here! I've created specifically a LLM based tool for this, which uses LLMs on AST level to guarantee that the code keeps working after the unminification step: https://github.com/jehna/humanify

What kind of question does it ask the LLM? Giving it a whole function and asking "What should we rename ?" repeatedly until everything has been renamed? Asking it to do it on the whole thing, then parsing the output and checking that the AST still matches?

For each variable:

1. It asks the LLM to write a description of what the variable does

2. It asks for a good variable name based on the description from 1.

3. It uses a custom Babel plugin to do a scope-aware rename

This way the LLM only decides the name, but the actual renaming is done with traditional and reliable tools.

Re: OpenAI is good at unminifying code

#259
post #249

This is an example of superior intellectual performance to humans. There’s no denying it. This task is intellectual. Does not involve rote memorization. There are not tons and tons of data pairs on the web of minimized code and unminified code for llms to learn from. The llm understands what it is unminifying and it is in general superior to humans on this regard. But only in this specific subject.

> Does not involve rote memorization. There are not tons and tons of data pairs on the web of minimized code and unminified code for llms to learn from. GPT-4 has consumed more code than your entire lineage ever will and understands the inherent patterns between code and minified versions. Recognizing the abstract shape of code sans variable names and mapping in some human readable variable names from a similar patte…

And a human can do it without seeing that amount of code and consuming less energy.

Re: OpenAI is good at unminifying code

#260

Earlier quoted context omitted.

the condition is a constant so it can be safely removed

Only in the web environment. In fact the condition itself is true only when it runs in a web browser and not in a web worker.

which is the case for that code and it was added by the obfuscator
Post reply on HN