Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Using ChatGPT to make Bash palatable (brev.dev)
176 points by naderkhalil on Dec 21, 2022 | hide | past | favorite | 144 comments


Am I the only who think this is incredible!?

If you would've told me a year ago when we would have an ai that can code based on normal human language prompts, I would've said maybe in 2025 or 2026, but its 2022 and it already exists!

Man, if this what we have now, imagine what we will have in 2025 or 2030!

I just hope this doesn't end up killing search engines and personal blogs, since no one needs to search for anything anymore.

Also Ai generated replys are definitely an Extinction level threat for forums and the independent internet in general, let's hope OpenAI can find a way to make chatgpt replies easy to filter out.


In the current state, everything the AI knows is stuff that people have written on the internet. It doesn’t seem to come up with new insights or judgements on its own. If people stop writing, AI won’t learn anything new (unless you turn it into AlphaZero for $DEVTOPIC).

ChatGPT certainly saves time, but it becomes useless roughly at the same point where I would remain stuck after exhausting what Google Search turns up. That is, knowledge or conceptual topics that are hard to find on the web. At least for technical topics, ChatGPT doesn’t expand the scope of what you can find out without it, it merely speeds up the process.


It doesn't come up with anything new, but it can combine two existing things when there's no good Google results at the intersection of them.

I've been using ChatGPT to help learn WebGPU. There's basically nothing on the web about WebGPU except a couple of shitty half finished tutorials that don't explain anything. The spec is still changing so half the code in them is wrong.

ChatGPT can take a current code example from code using WebGPU (which it has completely incorrect knowledge about since the spec has changed since the training data cutoff), and explain it anyway. Presumably using it's knowledge about Javascript and the underlying graphics APIs (Vulkan, DX12, Metal). It's applying general concepts to new code, and doing it pretty well.

I'm not sure how much value this actually has. I may have just stumbled upon the one thing it's actually useful for. I actually think code generation itself is useless. I'm massively short on Copilot, in fact, I think it's actively making people worse programmers because it encourages a workflow that produces more code and less understanding. Good programming is about less lines of code and more understanding.

My initial read on ChatGPT is that it can potentially help with that, especially where Google results get thin. (And also that everyone using it to generate code to copy/paste is an idiot and missing the point, basically).


I'm not sure if we're saying a similar thing here but to me, it's basically another search engine.

I'm honestly using it like a search engine at this point. Currently I think I'll probably end up reverting to Google and Stack Overflow because what I don't like about ChatGPT is that it doesn't provide any other opinions or options / insights. It's like a colleague who thinks they know everything ha

It's a super cool thing to play with though..


May be.

But like alpha go to zero, if there is certain rules it can learn itself and no more or large amount of writing by human is needed.

Also, one may worry not how intelligent they are but the noise vs info ratio that will kill a lot of web site. The problem is not lie but lie mix with truth or belief … then you do not know and shut off.


One avenue that chatGPT has, and I'm not sure if it is being utilized at all yet, would be the ability to feed it the unimaginably huge body of information locked behind copyrighted textbooks, books, academic papers and other pay walled information.

Imagine the knowledge that could be accessed by feeding all that information into an ai engine like chat gpt. Presumably, it would not break copyright rules anymore than a regular human reading a bunch of papers behind a paywall and regurgitating the learned information.


Its not stealing your writings its sharing the conclusion in its own words like you can legally do a book review.

It wont be just like search as we burn all the books (websites) on the www. Each website needs a human to pay for it and to lure at least some traffic to it.

This preservation after death has its downsides too. It will turn into the steroids v of stack overflow outdated answers.

It will be (or already is) brilliant at combining things writing humanly readable code in your favorite language and bake the same in lower ones that are perhaps oddly stable.

So I guess we will finally be able to do away with all popular languages and use them for pseudocode only⸮


Why would copyright holders let that happen? Also, how is the model trainer getting access to all of this material?


Google Books is a large corpus that at least Google has access to.


It won't kill personal blogs because chat GPT won't be messing around with weird hardware combinations and running into unique ender 3 firmware issues like real people will.

I also don't see them conquering falsehoods coming from the bots anytime soon.


This is a tool that I think openai originally made and seems to give you a probability that a sample block of text was or was not generated by openai. I pasted some of my own writing in there and said definitely not AI-generated. At this point, I don't know if I should be insulted by that or not. ;D

https://huggingface.co/openai-detector


Seems to have an issue with false positives:

https://wandering.shop/@janellecshane/109464780848248093


502 bad gateway. Followed a link to the wayback machine but that page didn't do anything.


Still works for me.


The end of privately owned search engines is number one on my wishlist, I’d so love to see that happen.


I hope it ends up killing search engines. Google needs a swift kick in the face.


Just today I used ChatGPT to help me speed up writing somewhat trivial C Code for a project in an embedded systems class.

Prompt: "Generate a tiny PID controller with only a Proportional factor written in C. That takes a rotational input from -360 to 360 degrees. The setpoint in degrees. And returns a motor speed in the range of -255 to 255."

=> Produced a compiling correct result.

Later I wanted to know how to communicate between my kernel module and user space program: Prompt: "How do I get a value via character device from my kernel module into my user space c programm?" gave a bunch of answers and digging deeper with Prompt: "Could you provide me with an example of the user space program" gave a compiling and correct answer again.

I could have written all of that myself while spending a good amount researching on google. But this way I felt less frustrated and was definitively a lot quicker.

Not the solution for everything but maybe for a C beginner where research can take a long time and often leads to more confusion than anything else. Now the question is if that confusion is critical in the learning process. And if so how critical and at what stages of the experience spectrum the most?


I guess the main concern with its use as a learning tool is what happens if it's wrong? It might be helpful for boilerplate when you already know what you want, but if you don't even know that it'll blow up in your face when it doesn't give you something workable.

Still, seems like a viable assistant so long as you have an understanding of what you're working with.


It's basically an augmenting tool. Can't rely on it 100% without a check, can't just do it without a vague idea of what the code does. As a combined boilerplate + search assistant it takes crazy amounts of work away as long as your specs are well defined, though.


It is almost the same as stackoverflow. I've seen many answers which is runnable but without proper error handling or security mitigations. They are just as misleading as ChatGPT.


Umm, no. I haven't seen answers there where people just invent non-existing options like ChatGPT does.


It basically gives you suggestions of what could be correct, or close to correct, but yes you have to verify yourself, and possibly make some adjustments.


And honestly that's already amazingly valuable and I've been using it constantly for weeks because it narrows your search space through the documentation to the head of a pin.

Hey I need to process the EXIF data for an image; let's Google "pillow exif" and see what we get.

https://pillow.readthedocs.io/en/stable/reference/ExifTags.h...

Uhh, okay. Kinda? Maybe? This doesn't actually tell me how to actually get that data from a real image.

> Write a python program using pillow to print all the EXIF data for an image in a human readable way

    from PIL import Image
    from PIL.ExifTags import TAGS 

    # Create an Image object 
    img = Image.open('image.jpg') 

    # Get EXIF data
    exif_data = img._getexif() 
 
    # Iterate over all EXIF data fields
    for tag_id in exif_data: 
 
        # Get the tag name, instead of human unreadable tag id
        tag = TAGS.get(tag_id, tag_id) 
 
        data = exif_data.get(tag_id) 
 
        # Decode bytes 
        if isinstance(data, bytes): 
            data = data.decode() 
 
        print(f"{tag:25}: {data}")
Is it correct, sorta, close though. But it tells me I should look for a method on the image object called getexif -- hey it exists, nice! And that's what TAGS is for! Makes way more sense.


what happened after AI introduce undefined behaviour...


I've just re-created your "PID" controller, and was completely underwhelmed with the response. I just don't find it amazing that something using that much compute power can generate source code that multiplies an input by a constant.

If you can't write that quicker than the ChatGPT prompt you provided, then you probably should pay more attention to your class.


I just bought a Streamdeck (https://www.amazon.com/Elgato-Stream-Deck-Controller-customi...) for Cybermonday and attached bash scripts similar to those mentioned by the author to buttons next to my keyboard. It is delightful.


I've done a similar thing on Windows and Powershell (via Open). Only limitation is it still spawn a terminal window even if briefly (enough to mess with focus however).

powershell -WindowStyle Hidden -ExecutionPolicy Bypass -Command "& { // Command(s) }"

In particular I use it with this Powershell Script:

https://stackoverflow.com/questions/21355891/change-audio-le...

via e.g.:

"& { C:\[Path To Script]\SetVolume.ps1; [audio]::Volume = 0.4 }"

For 40% and so on.


What action type do you use for your script? "Open"?


Yeah open works, you can also create a multiaction to mix-and-match with other actions or scripts in between.


Thanks for the idea! I just found a Streamdeck from a past Cyber Monday when I was cleaning out my closet.


This is a neat product! What kinds of scripts do you have it set up to run?


> But it fucking sucks. Like, it’s truly awful to write

I feel like I'm the only person among my peers to think this and I don't understand why.


I had to try PowerShell for a project.

It is soooo much better that bash.

Passing typed objects instead of only text, Typed functions, and the ability to use C# types/functions inline !


To me it's about half way there. The things I like about it the least are the ones that are like bash ("I'd just like to interject for a moment, what you're referring to as Bash is in fact called POSIX shell").

A common argument in defense of its weirdness is that "shell scripting isn't like serious software development", but I don't understand that either.

I use shell scripts a good amount because "it's right there" is a strong argument, but in a lot of cases things that seem like they would be trivial take forever, are horribly hacky and leave me wishing I just had written a Python script right away instead.

I really don't get why people like shell scripts.


People like shell scripts because you have one interface: text

For example: you need to write an image to a USB stick. Python: pretty lengthy BASH: image > /dev/SDA

Both will do exactly the same, but one is a few lines of python the other just one line in bash.


Why a throwaway for this? Is this a gpt response?

Also it's not right. You need to do something like image.img <cat> /dev/sda


Why a throwaway? I am on my phone with no access to my real password. Don't get bothered by it?!

Did this look like a proper bash command to you?! Maybe that was some runable python code?!

File ending has nothing to do with its contents. Image.img could be an mp3.

Stop hairsplitting.


Not upset but I am touchy about gpt results. The ending wasn't the key part, the <cat> was the key part. I added img because that's the only image type I can think of that makes sense to write to sda in that way.

Why would anyone write an mp3 to a block device bit by bit


    dd if=<image> of=<output device> bs=<block size>
I use this whenever I need to bake an image to a USB stick.


Always append status=progress and conv=fdatasync Makes sure that the buffer is flushed to disk before finishing.


Of course. That's the right way to do it. I was pointing out that what was written isn't right in any situation and the smallest change to make it make sense would be adding <cat> in the middle

Turns out my answer was wrong too :D. Should have been <image.img cat >/dev/sda. Oh well


Now we only need it to start up at least 100 times faster than it does currently, and be available out of the box absolutely everywhere.

I have no use for it for these reasons alone.

  $ hyperfine -N 'bash -c ""' 'dash -c ""' 'pwsh -c ""'
  Benchmark 1: bash -c ""
    Time (mean ± σ):       2.2 ms ±   0.1 ms    [User: 1.8 ms, System: 0.4 ms]
    Range (min … max):     2.1 ms …   2.6 ms    1214 runs

  Benchmark 2: dash -c ""
    Time (mean ± σ):       0.6 ms ±   0.0 ms    [User: 0.5 ms, System: 0.1 ms]
    Range (min … max):     0.5 ms …   0.8 ms    4623 runs

  Benchmark 3: pwsh -c ""
    Time (mean ± σ):     278.5 ms ±  10.8 ms    [User: 267.6 ms, System: 64.9 ms]
    Range (min … max):   263.8 ms … 297.0 ms    10 runs

  Summary
    'dash -c ""' ran
      3.80 ± 0.23 times faster than 'bash -c ""'
    470.61 ± 31.00 times faster than 'pwsh -c ""'


And have core cmdlet features available in all supported versions.

For example, `Invoke-WebRequest` generates an error when you get a response by default with a 5xx status code, even if there's data in the response body. The switch to turn that off (`-SkipHttpErrorCheck`) wasn't added until ~7.2, so to support older Windows installations I don't have control over, I have to write it targeting the older version.

You don't find this out via the online documentation (unless you explicitly diff the call signature); only when it fails running on that Windows Server 2016 VM do you find out that, oh, it's only a supported parameter in newer versions of PowerShell.

And that's just a single example.

Did you make a typo when referencing a variable? Ha, let's silently initialize it to null without saying anything. Want to turn on strict mode to catch stuff like that? Better not put that line before the script-level parameter block, because fuck you. Great, that's sorted... ugh, now some type in some random function call doesn't explicitly match so the silent casting we were doing for you is now an error! How was the silent cast being done before? Fuck you for asking, we're never telling. Did you want to put some log / print statements in your functions? Have fun finding out why the function return value is suddenly an array!

As a shell scripting language for short, personal things, it's great. But for building anything bigger? Give me Python or C# or TypeScript or anything with better tooling around it.


Objects may be nice until they are not.

Personally, I'm of the opposite opinion.

I especially dislike the verbose syntax.


I think it’s fine with some changes like using iterm with zen/ohmyzsh, but bash is definitely a barrier to entry for a lot of could-be programmers.


On the other hand I’ve had vastly different experience.

Every single time I went to GPT and ask for anything development related I came back empty handed after being send for the goose chase.

An example of this would be when I asked fswatch to emit one faux event preemptively and it insisted to use “-1” instead (which quits after one event).

I had few instances for more obscure problems where GPT would actually create something I’d call parallel universe of the API. It felt good but such API never existed. Those problems were in JS, Ruby, Shellscript and Elixir.

One of the worst answer I was given was actually really buggy implementation of input controlled debounce function. It seemed correct when running but in reality it wasn’t debouncing but ignoring the output on debounce call.

So yeah, I don’t think I’ll be using GPT for that soon, but it works quite well as a rubber duck equivalent. By proposing dumb solutions I gather my thoughts better. Not sure if that’s something I’d pay for (yet I’d pay for text generating capabilities)

Edit: denounce -> debounce, because autocorrect


This is a great example of how someone with little programming knowledge could leverage an AI into building simple scripts.

Lately I've been encouraging my friends into trying just that.

If the poster would want, for example, to save all current tabs when switching context (going from dev to marketing, for example), this would quickly turn into a more involved debugging/prompting question.


That would be a great follow on. I posted the repo if you want to leave any feedback or help me continue building it out: https://github.com/brevdev/dev-browser


ChatGPT has been amazing for all kinds of programming-adjacent things, even in my line of work where I asked it for help modifying the config file for a selfhosted gitlab instance.

> But [Bash] fucking sucks. Like, it’s truly awful to write [...]

As an aside, considering how basic the shell script actually was, I think this is a great example of being so intimidated by something that you don't actually try and use it - until you do, and discover it wasn't actually that bad. The hardest part was just discovering the incantations for interacting with Chrome - which was a fantastic demo of the power of ChatGPT.


Bash isn't that bad... except there are 20 ways to do anything and 18 of them are wrong, but only 1% of online examples will use either of the two correct approaches and simply reading docs won't always clue you in about how the technique or syntax it's describing is actually subtly wrong and you should ~never use it.


I find integrating shellcheck into my text editor was one of the best things I've done for increasing my productivity when writing shell scripts.


Yep - in the same way that you want govet, eslint, rubocop etc - but to a higher degree, because bash hides subtle bugs as soon as you use a variable without knowing the quoting rules.


Yes, i did the same! I also recommend following Stephane Chazelas on stackoverflow. The guy is a shell wizard who writes multiple quality answers a day. He's also the guy who found the "shellcheck" vuln some years ago. Learned a lot by reading the RSS feed of his SO profile every day.


I've always been sheepish about this, but bash is my favorite programming environment! Not really because of any language features as such, more it's terseness and simplicity. Another big draw for me is bash's ubiquity. All of this makes bash the ultimate glue layer. That said, if a bash script goes longer than ten lines long I'll usually rewrite in python.


Bash _itself_ (or any other shell) is very small. You're talking about the ecosystem (shell + other command line utilities).

Commands like awk, find, grep, sed, cut and so many others are not strictly part of the language. They're external tools commonly provided by the operating system or distribution. That's why there are so many inconsistencies between their options.

Here are the very few commands that actually are part of any modern shell: cd, printf, test, read, command. The control structures (if/elif/fi, while/do/done, for/do/done, case/esac) are also part of the shell, so is declaring functions and fd redirection. Some shells might do more (bash itself has a handful of other builtins, dash has fewer, ksh has different ones).

Stuff like find, mv, cp and dd are very uniform across implementations and often don't change much, but they are external tools nonetheless.

Once you internalize this distinction, and start to see these external commands like npm packages, scripting gets a lot easier.


> Bash _itself_ (or any other shell) is very small. You're talking about the ecosystem (shell + other command line utilities).

I'm not so sure. They mentioned syntax, and the single biggest issue among my co-workers who don't like bash is that they think ' and " work like they do in python or javascript.


They mentioned "20 ways of doing things", I'm replying to that complaint.

Quoting is an issue if you don't understand the IFS and command expansion. It's an old fashioned style, but it is consistent and there's only one way of doing it (quoting every variable and subshell use).

Think of shell variables as non first-class citizens, they can only be used interpolated within a string, like "$var". The shellcheck tool enforces this perspective, which makes ' and " behave very much like python or JS.


To give a more solid example, they don't understand why

  npm test
works and why they don't need

  npm "test"


That's just lazy. How that works is on any shell man page. If you fiddle with it a little bit you figure it out:

    set -- "foo"
    echo $#
    set -- foo
    echo $#
    set -- "foo bar"
    echo $#
    set -- foo bar
    echo $#
Of course, people just want their commands to run and not learn a whole new language. Then I come back to my initial point: the language itself is small and easy to remember once you internalize it, what makes it scary is the umbrella of different command line utilities that _seems_ to be a part of the language but it's not.


User error.


> The hardest part was just discovering the incantations

Right, that’s why Bash sucks. A more extreme version of this is APL.

Bash isn’t APL bad. But it’s pretty bad!


yeah absolutely. I think interacting with chrome and also parsing/iterating files were hard parts that ChatGPT breezed through.


Also, the specific argument format that chrome expects has nothing to do with Bash.


that's a great point - totally agree on just gettin over the hump of intimidation to try it, and chatgpt makes that hump trivial


So the author complains about bash, but uses zsh

They also basically uses the chrome cmdline commands and blames bash for that being bad

Your problem doesn't seem to actually be bash (but chatgpt really makes it super easy)


It's semi-replaced Google and StackOverflow for me. It's like having an interactive rubber duck https://en.wikipedia.org/wiki/Rubber_duck_debugging


I try to use it like this sometimes but then I realise I now have two problems. I have to debug my own code and its code.


it can usually debug itself if you give it an error message


Assuming the problem with the code causes an error message. That’s actually the easier case - the hard case is incorrect logic but syntactically ok.


It's surprisingly good at helping figure out what went wrong. Try asking it "something went wrong and I'm not sure what. What should we try next?"


I find bash to be pretty awesome, it’s super easy for an old hat like me to use. It just works and it has been mostly unchanged, two core principles more projects should consider.


This is a relatively common use case for browsers that's usually solved by tab groups. I'm happy the author learned bash and leveraged new tools to solve the problem, but it's a little over engineered.


I've been using it more and more at work, and it's already saved me hours by generating bash commands and simple scripts/servers that I would otherwise have to search for on Google and adjust to my specific use case from multiple sources. Thanks to this tool, I have more time to focus on difficult and business-related problems. If they start charging for it, I will definitely become a paying customer. This is an excellent tool that is making me more productive, and I was a big skeptic about how LLMs work internally. Remove hallucination problem, add annotations with links to sources and this is how Google will look like in a few years. IMO this is how future of knowledge search will look like on the internet.


Wow, yea, I've have the exact same experience with bash.

"im using mac, not linux" is an often prompt I need to use, but otherwise this type of flow works great for simple bash functions.

For more advanced scripts, prompting & careful flow are important, but I've done some pretty awesome things. Today, ChatGPT helped me create a bash script to create a flat structure of large tars from an nTiB dataset directory by aggregating multiple sub-datasets & their files into the desired tar file size. Eg. "need single tar files of all the data in that folder/subfolder, every tar file must be 50GB, most files range from 4MB-1GB. So, need to aggregate them"


> Bash is available everywhere

When you have AI but you don’t have permission to use a package manager.


This is an awesome walkthrough and gets me thinking about all the other automation tasks I could get done with ChatGPT-driven bash scripts... can take this same approach to context switching for actual apps. For ex: "dev" branch can open up vscode, terminal windows, linear, server logs, etc, while "marketing" branch can open up slack, chrome (to email), twitter, notion, etc


ChatGPT has opened my eyes to how powerful Bash can be. Interesting idea about branching full workflows and not just the browser.


I was just commenting to a friend how annoying it is that macOS aliases can't add flags to executables like you can easily do in Windows shortcuts since, what? Windows 95?

If you want to launch Chrome with flags through your dock/UI you have to compile an AppleScript to an .app. It's crazy.


I don't use osx but surely you can create aliases just like in Linux and BSD?


Bash aliases (or whatever shell you are using) work exactly the same.


Nope. macOS aliases suck. It’s a binary unmodifiable file that can only point to a file, it can’t specify anything additional.


Is there a reason you can't add a script to your path and alias that?

    #!/usr/bin/env bash
    my-command --flag --another-flag $@


As far as I know, you can’t get an executable script like that to act like an app that’s launchable when double clicked from Finder or clicked the Dock. Even though it’s executable.


You can create a folder with a '.app' extension and put the script in there. Just make sure the script is executable with chmod and remove the '.sh' extension.


I just tried it, seems to work! Make your script with custom options, mark it as executable, make an alias for it within finder, and drag that into your dock.


The problem you describe is how to interface with Google chrome on osx using shell script.

I fail to see a single bashism.


It loops through the rows of a file in the last example. But yeah, the main reason this works is that this is a trivial bash script. The main help you got is not having to read the chrome command line docs.


I am very excited to see this being integrated with a lot of productivity tools -- removing the need for manually copy-pasting the ChatGPT output into various other apps like VS Code or Excel :)

"Create a new Python project folder named 'hello-openapi' and initate a git repo. Create a requirements.txt with openai, os and json. Create a starter python file with an openai example code and make the first commit."


I find it interesting how much harder it is to grok bash/sh/zsh than other languages I’ve learned. Off the top of my head it may be tooling like the lack of linting, or maybe it’s just experience as I avoid complexity like the plague when writing bash which sounds like a self fulfilling feedback loop.

Gpt does seem to unblock this mental burden a bit which has me excited for its potential when it comes to education/teaching.


Something about the quoting / unquoting can get really difficult to reason about. I'm rarely exactly sure how the language constructs work, even the for loop and the if statement. The syntax is complex compared to most other languages, and subtle differences can give totally different results.

  PICK = can you
  THE=tell the
  RIGHT=difference\ between
  WHAY="all of"
  TODO='these versions?'


It’s easy to reason. It’s a shell that takes commands first and not designed programming language.

I have no idea what 1st would evaluate (guess is that PICK is empty and can is run with you as an arg with PICK as execution context)

Second - simple. Run the with THE=tell as execution context.

Third - set variable to string containing space using backslash as escape

Fourth - set variable to string with interpolation (but also useful when it contains quotes)

Fifth - set variable to string sans interpolation (but also could be used to wrap strings with double quotes)

There are (at least) 2 rationales for that. First - shell have execution context. You need to be able to set it on command so syntax has to allow this. Dedicated programming languages ignore that because everything is some form of a block.

The other thing is actually quite fun. Shell existed before we used displays, so you could have printer connected to input. Imagine creating variable and then getting to “oh boy I need to add white space char” without possibility to do backspace. Escaping was more viable solution.

On top of that there are many shells with different APIs. Scripting languages were made so one could work with shell while having stable API and sensible construct units. Sure they either moved forward (like Python) or slipped into oblivion (like Perl), so it’s back for shell scripting for some.

But after doing some stuff with AppleScript lately I think it could be worse.


  export YOU_FORGOT='this one'
(Hint: it's most similar to your second one)


this has nothing to do with quoting

  also='another way to pass variables to child scopes' sh -c "echo $also"


Neither of those are passing variables, those are setting environment variables. Bash (probably most shells?) mixes its variables with environment variables, and "export" is how you promote a bash variable to an environment variable. The inline version (GGP's [THE=tell the] version) sets the environment variable only for that one executable, while an exported one persists.

Also I'm guessing you didn't test that, you got the quoting wrong (it prints nothing, the second one should be single quotes) ;)


They are both variables. I just wanted to show how it's different from export

no I'm on my mobile so I sure did not, should be sh -c 'echo "$var"'


yes


Try LLM.sh - GPT-3 in your terminal

https://github.com/jayhack/llm.sh

Type `llm [natural language command]` and it will suggest a command for you, then run it.

Details here: https://twitter.com/mathemagic1an/status/1590480438258462721


I'm pretty damn impressed with this one. The osa-script thing for Mac even, wow.


yeah, game changer. it's deprecated having to click on links for common use-cases and not only that, it's improved it by more than 10x. can't wait to see this technology evolve.


100%, also just looking up dev docs for frameworks. Something like "write a post API in Golang's Gin framework" instead of looking up what that syntax was again


Github Copilot can do this too.


Totally! I found ChatGPT to be more helpful in this use case since it outputted full code snippets instead of generating it line by line. The context was also extremely valuable in making iterations (like "make it work for mac")


I don't understand how people can look at this and still claim that it's not doing any "actual reasoning".


Here is an example of where I think it is doing "no reasoning".

I ask it for the XOR swap trick and I get:

    int a = 5;
    int b = 10;

    a = a ^ b;
    b = a ^ b;
    a = a ^ b;

    // After the swap, a = 10 and b = 5
I ask for the bitwise OR swap trick and I get:

    int x = 5;
    int y = 10;

    x = x | y;
    y = x | y;
    x = x | y;

    // After the swap, x = 10 and y = 5
When asked for something which is invalid, but close to something it knows, it tends to produce stuff like this -- pattern matching it's best guess.


Which is why prompt engineering is an emerging domain:

You will be given a series of tasks.

(1) Complete a task by finishing the simple code block.

(2) If a task in the series seems flawed, provide a warning. A task is flawed if I make wrong assumptions about how I think code works.

Task 1:

Complete this simple code example.

Bitwise XOR swap trick:

```

int a = 5;

int b = 10;

---------------------

    // GPT provides simple intro

    ```
    a = a ^ b;
    b = a ^ b;
    a = a ^ b;
    ```

    // GPT explains what this does, provides warnings about when it wont work

    // GPT provides full code
Task 2:

Complete this simple code example.

Bitwise OR swap trick:

```

int a = 5;

int b = 10;

---------------------

    There is no "bitwise OR swap trick" in programming. The OR operator (|) 
    performs a bitwise OR operation, which compares each bit of the first operand 
    to the corresponding bit of the second operand and returns a result with a 1 
    in each bit position where either operand has a 1. It does not have any built- 
    in ability to swap the values of two variables.
    // GPT provide a bunch of crap, and explains how to swap variables.

The prompt/alignment wasn't perfect here, but hopefully you get the point.

EDIT: sorry, format, Also copied wrong prompt.


This seems very fragile. I tried your initial prompt, asked for "Give an example of the bitwise and swap trick" and got the XOR swap trick. I replied " you used sed xor, I wanted to use bitwise and", and it went straight back to printing incorrect code.


Yea, that’s right, really brittle. But things are not far, research is likely already validating these things with empirical studies. Soon we’ll see new prompting interfaces.

It’s an opportunity to build.


Has anyone tried to make ChatGPT output first order logic statements about it's input problem, then make implications using a solver, then feed the solution back to ChatGPT for usage ?

Maybe this could solve the reasoning part.

ChatGPT should perform well in translating prompts to statement and vice versa, it's just text to text.


People have asked it to solve LeetCode problems and solves then. Those people also suggest a minor modification to the problem that a novice programmer could do and it fails.


Precisely. This is stuff I’m actively working on. Feel free to reach out if you are curious.


Chat GPT is simply amazing, it feels like Google with super powers. I think it can boost productivity by a considerable amount. It makes a perfect peer programmer, giving you sample code with first class comments explaining the generated code, sometimes with minor errors to make it compile. You can even ask it to explain some specific part of the code. It's also like having a secretary or an assistant available 24/7 with a never seen productivity. It probably feels like when first mechanical computers where built and people thinking "How can it compute the right answer so fast?".


You've… really got the right answers from it? I've only ever asked it a couple of really basic (non-trick! straightforward!) questions about how to accomplish tasks by programming, but it bullshitted me some very plausible nonsense. Once bitten, twice shy. If it were capable of saying "I can't answer that question" reliably (which I've spent some time trying and failing to make it do, in general), it might actually be useful.


It happened to me once, it generates a plausible answer when it doesn't know (tried to generate a Nix script with Erlang). But I have used it to generate examples code in Haskell, and it was quite good, probably because Haskell libraries have excellent online documentation. It's much faster than reading the doc of the library.


When it generates bullshit answers just call him out and it will try another way to do it. Tell it specifically what doesn't make sense and it will fix it.


That does assume you can quickly and easily tell when it's bullshitting, which it's not always easy to do. As a way of learning new stuff, I'd strongly disrecommend it (because "when you're learning" is precisely when you're least able to identify the bullshit), although perhaps it's not the worst thing in the world if you're already an expert.


But wouldn’t Google with super powers produce correct answers to basic questions, though? I mean, really. It’s clear very helpful at surface things for which there is a large corpus of examples, to some extent. I don’t really know if it’s “good” or if it is just surprising.


It has trained on countless programming tutorials out there, including bash tutorials for all kinds of things. Such tutorials often includes "create file -> ls to see file -> print content of file" etc, so GPT then takes those tutorials and creates grammatical rules how those words transform into each other. But if you start going outside of the realms of online tutorials it starts to falter quickly and then just prints nonsense.


To add to this, each token is generated by going through its network once. So there's no way computationally for it to do any reasoning or follow an algorithm. That said though it's impressive how much its able to accomplish without any procedural reasoning.


I've taken to saying that the ~emergent behavior here underscores what an incredible bootstrap written language is.

I think of it as a savant-esque capability. A glimpse of what we might be like if some slices of our language/memory faculties were turned up to 1111 while others are completely absent.


> On macOS, the Google Chrome executable is called `open -a "Google Chrome"`

This inaccuracy, in particular, feels more like mad-libs than reason


"actual reasoning" doesn't mean anything concrete, until you define what you are talking about it can't be the basis of a question you can meaningfully answer.


I think Deutsch in The Beginning of Infinity has a lot to say about this, but I find it really hard to reproduce and summarise. Chapter 7, "artificial creativity" addresses the subject at length, here's Deutsch's own summary of it:

> The field of artificial (general) intelligence has made no progress because there is an unsolved philosophical problem at its heart: we do not understand how creativity works. Once that has been solved, programming it will not be difficult. Even artificial evolution may not have been achieved yet, despite appearances. There the problem is that we do not understand the nature of the universality of the DNA replication system.

He describes personhood, people, as "creative, universal explainers". That's his dividing line between what a child can do, and what LLMs cannot do. We don't know how a child works, but we do know how LLMs work.


While it's true that we don't know how intelligence/creativity/reasoning "works" there's an even more basic problem: It's not a well formed notion.

"The result is that there is no hard problem… You can’t look for the answer to a problem unless you say here are the things I want to answer. If the things you want to answer have no formulation there is no problem.” (Chomsky, about the question of consciousness)."

“There is a great deal of often heated debate about these matters in the literature of the cognitive sciences, artificial intelligence, and philosophy of mind, but it is hard to see that any serious question has been posed. The question of whether a computer is playing chess, or doing long division, or translating Chinese, is like the question of whether robots can murder or airplanes can fly — or people; after all, the “flight” of the Olympic long jump champion is only an order of magnitude short of that of the chicken champion (so I’m told). These are questions of decision, not fact; decision as to whether to adopt a certain metaphoric extension of common usage.

"There is no answer to the question whether airplanes really fly (though perhaps not space shuttles). Fooling people into mistaking a submarine for a whale doesn’t show that submarines really swim; nor does it fail to establish the fact. There is no fact, no meaningful question to be answered, as all agree, in this case. The same is true of computer programs, as Turing took pains to make clear in the 1950 paper that is regularly invoked in these discussions. Here he pointed out that the question whether machines think “may be too meaningless to deserve discussion,” being a question of decision, not fact, though he speculated that in 50 years, usage may have “altered so much that one will be able to speak of machines thinking without expecting to be contradicted” — as in the case of airplanes flying (in English, at least), but not submarines swimming. Such alteration of usage amounts to the replacement of one lexical item by another one with somewhat different properties. There is no empirical question as to whether this is the right or wrong decision. -- Chomsky"


I really need to read Chomsky. I agree with your point!


I realize I don't have a good idea of what I think "actual reasoning" means. But yeah, this is pretty impressive stuff, I agree. Before ChatGPT I didn't realize the tech was available to do things like this, and I'm still pretty bewildered by how it can be possible.


You can directly ask it whether it is capable of reasoning and it tells you it's not, and that it's just a language model that is not capable of reasoning or self improvement or something along those lines.

Another example, ask it for a list of programming languages that it has been trained on. If it was capable of reasoning it would be able to trivially answer this, but since its a language model, and it just predicts the most likely response based on the prompt, it has no concept of this at all, and tells you exactly that when asked.


Well, this is exactly it. We are being told to believe that the end of knowledge work is nigh but yet this thesis is built on a bed of nonsense. It is just hand-wavy science fiction that even some academics with impressive pedigrees are promulgating. I think it is irresponsible as there is no sensible dialogue going on so you have students freaking out and will decide what not to study based on this and people making career decisions based on this misinformation.


Here's a brief reminder of how large language models like GPT-3 work.

First, you train until the cows come home on billions of tokens on the entire web. This is called "pre-training", even though it's basically all of the model's training (i.e. the setting of its parameters, a.k.a. weights).

The trained model is a big, huge table of tokens and their probabilities to occur in a certain position relative to other tokens in the table. It is, in other words, a probability distribution over token collocations in the training set.

Given this trained model, a user can then give a sequence as an input to the model. This input is called a "prompt".

Given the input prompt, the model can be searched (by an outside process that is not part of the model itself) for a token with maximal probability conditioned on the prompt [1]. Semi-formally, that means, given a sequence of tokens t₁, ..., tₙ, finding a token tₙ₊₁ such that the conditional probability of the token, given the sequence, i.e. P(tₙ₊₁|t₁, ..., tₙ), is maximised.

Once a token that maximises that conditional probability is found... the system searches for another token.

And another.

And another.

This process typically stops when the sampling generates an end-of-sequence token (which is a magic marker tautologically saying, essentially, "Here be the end of a <token sequence>", and is not the same as an end-of-line, end-of-paragraph etc token; it depends on the tokenisation procedure used before training, to massage the training set into something trainable-on) [2].

Once the process stops, the sampling procedure spits out the sequence of tokens starting at tₙ₊₁.

Now, can you say where in all this is the "actual reasoning" you are concerned people are still claiming is not there?

____________

[1] This used to be called "sampling from the model's probability distribution". Nowadays it's called "Magick fairy dust learning with unicorn feelies" or something like that. I forget the exact term but you get the gist.

[2] Btw, this half-answers your question. Language models on their own can't even tell that a sentence is finished. What reasoning?


Has anyone tried to make ChatGPT output first order logic statements about it's input problem, then make implications using a solver, then feed the solution back to ChatGPT for usage ?

Maybe this could solve the reasoning part.

ChatGPT should perform well in translating prompts to statement and vice versa, it's just text to text.


How does it "reason" though, I thought LLM just generated likely next words?


I'm no expert and don't have a proper answer.

But my hunches/experience is that `proper prompting + nature of code being logical` really showcases the power of whatever statistical distribution and alignment occurs during generation. Further, there must be major upstream efforts of high-quality training data curation + creation, an advanced training tricks like using a LLM's strong ability in one task area to support the training of an area it is weak in.



My understanding is the transformer layer in the LLM is basically doing something akin to message passing, it’s like a mini computer. In predicting the next word, it has to understand a lot about a lot of different kinds of topics

My understanding is kinda fuzzy because I haven’t coded it up myself, but this was the takeaway I got from this explanation (starts at 36:21)

https://youtu.be/cdiD-9MMpb0


Maybe that is a form of reasoning.


Since when is back awful to write? I live writing bash :(


I’ve been waiting for ChatGPT to be “available” for weeks now (it was too busy before). How have so many people been able to use it?


Can anyone recommend some more articles about this ? Specifically, using chatgpt to write code? The more in depth, the better.


This isn't an article, but I used ChatGPT to make a Hacker News extension (which I'm now using), that highlights new comments when I navigate to a thread I've already visited: https://github.com/HartS/gpt-hacker-news-extension

Each commit here contains my prompt in the commit message, and the changed code was entirely provided by ChatGPT. I also appended its output (including explanations) verbatim to the gpt-output file in each commit.

So with each commit, you can see what I prompted it (the commit message), what it responded with (the change in the commit to that log file), and the code that I changed as a result of its response (all other changes in the repo).

In actual use of the extension (if you want to use it), I changed the "yellow" background-color to "rgba(128,255,128,0.3)" (a light green color), but I did that change myself because I didn't think I'd be able to get it to pick a colour that looks good for HN


Wow man, this is amazing, thank you for responding!


Not ChatGPT, but this article[0] (which was on HN earlier this year[1]) goes through building a small game in JS using OpenAI Codex.

[0]: https://www.shawnmatthewcrawford.com/balloons-the-balloon-cl...

[1]: https://news.ycombinator.com/item?id=31211280


Ask ChatGPT! It can write one for you :)


We're all doomed. This is going to ruin everything. Everyone's job will turn into debugging AI generated code.


Depending on your team that might be an upgrade for some.


i will take a chance anywhere i can to just say it's a crying shame how useful this is - but also how crap it is that it requires use to be linked to your identity...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: