Live data from Hacker News

OpenAI is good at unminifying code

glama.ai

51–60 of 321 posts

Re: OpenAI is good at unminifying code

#51
post #45

Okay, but if the unminified code doesn't match the minified code (as noted at the end "it looks like LLM response overlooked a few implementation details"), that massively diminishes its usefulness — especially since in a lot of cases you can't trivially run the code and look for differences like the article does. [ed.: looks like this was an encoding problem, cf. thread below. I'm still a little concerned about corr…

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.

Discrediting the entire output because a few missing characters would be very pedantic.

Otherwise, the output is identical as far as I can tell by looking at it.

Re: OpenAI is good at unminifying code

#52
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.

That's not how copyright and licensing works.

You could already break the law and open yourself up to lawsuits and prosecution by stealing intellectual property and violating its owners rights before there were LLMs. They just make it more convenient, not less illegal.

Re: OpenAI is good at unminifying code

#53
post #12

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

The problem is the use case is where you don't care about the risk of hallucinations or you can validate the output without already having the data in a useful format. Plus you need to lack the knowledge/skill to do it more quickly using awk/python/perl/whatever.

That's why having good test suites and tools are more important than ever.

Re: OpenAI is good at unminifying code

#55

Earlier quoted context omitted.

A mere decompilation or general reverse engineering should be fine in many if not most jurisdictions [1]. But it is a whole different matter to make use of any results from doing so. [1] https://www.law.cornell.edu/wex/reverse_engineering

https://en.m.wikipedia.org/wiki/Clean-room_design

Using an LLM (or any technique) to decompile proprietary code is not clean room design. Declaring the results "open source" is deception and theft, which undermines the free open source software movement.

Re: OpenAI is good at unminifying code

#56
post #45

Okay, but if the unminified code doesn't match the minified code (as noted at the end "it looks like LLM response overlooked a few implementation details"), that massively diminishes its usefulness — especially since in a lot of cases you can't trivially run the code and look for differences like the article does. [ed.: looks like this was an encoding problem, cf. thread below. I'm still a little concerned about corr…

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

Re: OpenAI is good at unminifying code

#57
post #45

Okay, but if the unminified code doesn't match the minified code (as noted at the end "it looks like LLM response overlooked a few implementation details"), that massively diminishes its usefulness — especially since in a lot of cases you can't trivially run the code and look for differences like the article does. [ed.: looks like this was an encoding problem, cf. thread below. I'm still a little concerned about corr…

It does seem that the unminified code is very close to the original. In some cases ChatGPT even did its own refactoring in addition to the unminification:

    // ORIGINAL:
    j.useEffect(() => {
        function r() {
            n({ height: window.innerHeight, width: window.innerWidth });
        }
        if (typeof window  window.removeEventListener("resize", r);
    }, []),

    // UNMINIFIED:
    useEffect(() => {
      const handleResize = () => {
        setSize({ height: window.innerHeight, width: window.innerWidth });
      };

      // Initial size setting
      handleResize();

      window.addEventListener('resize', handleResize);
      return () => {
        window.removeEventListener('resize', handleResize);
      };
    }, []);
Note that the original code doesn't call `handleResize` immediately, but have its contents inlined instead. (Probably the minifier did the actual inlining.) The only real difference here is a missing `if (typeof window < "u")` condition.

Re: OpenAI is good at unminifying code

#58
post #45

Okay, but if the unminified code doesn't match the minified code (as noted at the end "it looks like LLM response overlooked a few implementation details"), that massively diminishes its usefulness — especially since in a lot of cases you can't trivially run the code and look for differences like the article does. [ed.: looks like this was an encoding problem, cf. thread below. I'm still a little concerned about corr…

He also told it to reimplement from JavaScript to TypeScript.

I would guess if he just told it to rename the variables and method first, it would have been closer to the original.

Re: OpenAI is good at unminifying code

#60
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…

It can’t really compensate for missing variable and function names, not to mention comments.
Post reply on HN