Build your front end in React, then let ChatGPT be your Redux reducer
spindas.dreamwidth.org
spindas.dreamwidth.org
I OCR'd the text with Google Lens, described who had what, and after a bit of prompt engineering (e.g., adding "Be sure to get your math correct" to make the AI's arithmetic check out, and convincing the AI to split shared items evenly), it totally worked: https://gist.github.com/spinda/967322dda1c04d9864f3efd45addc...
Then I started experimenting with describing a hypothetical check-splitting app to the AI, and asking it to feed me JSON commands to update the UI in response to messages from me telling it what the user was doing. The results were promising! And then the similarity to the Redux data loop jumped out, and I built this generic plugin to wire ChatGPT up to apps for real.
Having to tell chatGPT to make sure it gets it’s math right is not confidence inspiring.
Wonderful example @mintplant.
Two sub-questions: 1) I thought LLMs worked by predicting the most likely next token. Why would telling it to check it's math actually make it's predictions more accurate?
2) Why would asking it to check it's math change the results it produces? Shouldn't it just do the same thing a second time and produce answers that are just as (in)accurate as it did the first time?
Saying it "split it evenly" and giving it numbers is something like saying "find me the hill next to this valley". This will lead you to the valley on the left, then to the tiny hill right behind it. The hill right behind it in this example is where all the weights about splitting stuff evenly are hanging around.
Giving it "split evenly and make sure the math is correct" is like saying "find me the the hill next to this valley, but make sure it's the tallest". So it will lead you to the same valley, but then to a different hill, because of adding "tallest" it will lead you to the intersection of where all the weights about splitting stuff evenly and correct math were found.
I.e. there is other stuff you can engineer about - saying stuff like "Write the result step by step and check for correctness." afterwards will navigate it to the same hill but then towards the "all math tests are here" hill which is where step by step calculations weights are and it will find it's new home there, giving you a more detailed output and more chances to be right since the prediction is easier - basically it "splits" the task into smaller, easier to predict chunks, like you split ugly code into small testable functions to understand it.
Then I told it to sound even more human and it does even better.
But it is not deterministic. For each token it picks at random, from a probability distribution generated by the neural network. You can make it deterministic if you set temperature=0. In general it is stochastic, if you sample again with the same prompt you get a different answer.
We don't compute in our heads, we use calculators. chatGPT could have a calculator too. Why kill a fly with a sledge hammer?
In some papers they even use named symbols. So you could have "[code]width=10; height=20[/code]. What is the area? ... The area is [code]width * height[/code].
I find this fascinating but not terribly impressive. Its fascinating that such a rudimentary skill prompted you to dive down this rabbit hole. The unimpressive part is that it's a rudimentary skill yet your over engineered solution still only required rudimentary skills.
For the type of queries you are doing (sending whole context), the output is comparable (and just as wrong) between chatGPT and GPT-3.
People keep saying ChatGPT isn't that impressive because it's just "regurgitating knowledge" and has no insight into it, or things along those lines. But I find it insanely impressive that you can specify something like:
"Provide your answer in JSON form. Reply with only the answer in JSON form and include no other commentary."
And it will do exactly that. Or tell it to explain you something "in the style of Shakespere".
I just asked it about quantum physics as Shakespere and got this (plus a lot more):
---
Oh sweet youth, listen closely as I impart
The secrets of the quantum realm, a place of art
Where particles and waves, both small and large
Exist in states both definite and in charge
---
That is really fascinating stuff.
…But I’ve also had it clearly tell me in an answer that 2 is an odd number.
This is because it is an excellent language translator and it is trained on the principles of “call & response”
I think what's interesting is that many types of creativity may really just be re-synthesizing "stuff we already know."
So a lot of the negative comments along the lines of, "it can't be creative because it never thinks of anything beyond its training data" don't click with me. I think synthesizing two existing concepts into some third thing is actually a form of creativity.
These nets may not learn the same way we do exactly, and they may not possess the same creative abilities as us — but there's definitely something interesting going on. I for one am taking a Beginner's Mind view of it all. It's pretty fascinating.
I would stop that kind of evolution, as it can be catastrophic, but I know that humanity is not able to stop itself from evolving further.
An 18 year old will have been training for ~160,000 hours on a volume of raw data that is probably far beyond our ability to currently store let alone train an AI with.
As far as training for a specific task, all that training on other matters kicks in to help the human learn or accomplish a “novel” task more rapidly, for example, knowing how to read and interpret the instructions for that task, knowing how to move your appendages and the expected consequences of your physical interactions with a material object. You’re certainly not taking a fetus with a blank slate and getting it to accomplish much at all.
If you are also saying AIs will be a more intelligent species, able to adapt better on Earth than humans, that requires extraordinary evidence. A human could solve complex problems no other species it machine can solve on nothing more than a handful of rice for a week. Where is the similar scale species/machine?
And even then for proper agi it would need to close the loop after inducing an hypothesis with testing.
Meatbags are going to be useful for a while still.
It can translate code from one language to another. Code that it has never seen before. Or between natural language and programming language.
It's certainly not perfect but it is reasoning all right
Its funny how many people will immediately poke holes in it for software development, but two years ago I could not imagine an AI could write code like chatgpt is doing now.
As shown by this post, we're still discovering what's possible with the tools we have now.
Also, human programmers aren't amazing at writing defect free code.
On that thought, does anyone even still use Copilot?
The AI can output a lot of text but can you input a 100000 line code base into it? No you can't. You can't even input 50 lines of code that is already in the data set!
And by failure I mean somethin akin to a blue screen and not that the output was wrong, there was no output!
This is obviously true, and yet we've invented so many things. From the wheel, to control of fire, to farming and animal husbandry, to mathematics, to metallurgy, to physics, to semiconductors, etc.
The interesting question is, was the invention of all those things simply the re-synthesis of "stuff we already know?" If the answer is yes, doesn't that mean we're now on the cusp of a something akin to a singularity? We can now synthesize nearly-unlimited streams of coherent human thought. If we had a way of differentiating the wheat from the chaff, we could analyze what would have been millennia of human output in the proverbial blink of an eye. If human knowledge is just "stuff we already know", then we better buckle up. It's about to be a wild ride.
This is the key to AGI. We need verification systems, they can be a code execution environment, a database of facts, a math symbolic engine, a physical simulation, a game, or real world lab experiments. These verifiers will produce signal that can be used by the language models to improve. The cheaper and faster verification is, the faster we can iterate. Generating ideas is cheap, proof matters.
Just remember AlphaZero a bit - it started from scratch, playing against itself, in a few hours it surpassed human level. Go simulation and verification is trivial. The board is just a matrix. So learning from massive search and verification is a proven path to super-human level.
Here is a related paper:
> Evolution through Large Models
And the space is combinatorial. Most of it is unexplored. It is creativity, but also a form of search.
If you think about it the most creative is random noise. then you apply rules it it to constrain the noise or limit the predictions. And add more rules in layers. so getting the system to produce more creativity is just relaxing the rules at different layers.
Really? This seems like a straw man - I've only seen gobs and gobs of examples showing all the amazing things ChatGPT can do. I have seen some measured comments from real experts helping to explain how ChatGPT works behind the scenes, and this is usually to temper sentiments when folks start going down the "It's sentient!!" route.
This was a lengthy poem that went into the finer details of quantum physics, and it all read as decent poetry.
It might not be "Shakespere" exactly, but it knew in general what I was looking for.
It's also impressive to me that this isn't information that is scraped off some website, like Google. It's actually generating this stuff in real-time and it may have never been seen before, anywhere, ever. That is far beyond anything I've ever encountered.
Trying to use it for things I know quite well has been terrible. I know nothing in this context so it impressed me.
If it's a lesser form of intelligence, as you imply, then I almost find the results more impressive.
Different != lesser
> Probably, but
Then why even continue speaking if you agree
> our concepts seem to be tied pretty closely to language.
Me: “ChatGPT, explain how an electron orbiting a hydrogen nucleus would behave if classical mechanics held true.”
ChatGPT: “In classical electromagnetism, an electron orbiting a hydrogen nucleus would behave in a similar way to the way a planet orbits the sun, as described in my previous response. The electron would follow an elliptical path around the nucleus, and the force of attraction between the electron and the nucleus would be given by Coulomb's Law.
According to Coulomb's Law, the force of attraction between two charged particles is given by:
F = k * (q1 * q2) / r^2
Where F is the force of attraction, k is the Coulomb constant, q1 and q2 are the charges of the two particles, and r is the distance between them.
In the case of an electron orbiting a hydrogen nucleus, the force of attraction would be the force that keeps the electron in orbit. The electron would be attracted towards the nucleus by this force, but at the same time, it would be moving with a certain velocity, which would cause it to follow a curved path. This path would be an elliptical orbit, with the nucleus at one of the foci of the ellipse.
The electron's orbit would be stable as long as the force of attraction between the electron and the nucleus was strong enough to keep the electron in orbit, but not so strong that it pulled the electron into the nucleus. This balance would be determined by the size of the ellipse and the velocity of the electron. If the ellipse were too small, the electron would be pulled into the nucleus. If the ellipse were too large, the electron would escape from the orbit.
However, we know that this is not actually how an electron behaves in an atom. In reality, electrons do not follow classical orbits around the nucleus. Instead, they follow a more complex pattern described by quantum mechanics. This is because the principles of quantum mechanics are needed to accurately describe the behavior of very small particles like electrons.”
On the surface this looks impressive. Except that the answer about stable orbits is flat out wrong. The electron would spiral into the nucleus, quite quickly, because of Maxwell’s equations: a moving electron radiates electromagnetic energy. This is part of the foundational defense of quantum mechanics. If as you claim, language and concept are so closely tied, surely a language model with billions (trillions?) of parameters is capable of encoding a relational understanding of this magnitude.
https://physics.stackexchange.com/questions/413039/electron-...
> If it’s a lesser form of intelligence I almost find the results more impressive.
You get that you’re saying the least common denominator in conversational intelligence makes you go bzzzzz? That the one thing ChatGPT lacks, critical thinking, does not impress you?
You know, in the 90s, they had these things called tamagotchis… you might be interested.
Making a CRUD app in many ways has become much more complicated than it was when I started programming 10 years ago.
Today when I want to build an application, I often find myself frustrated and bemused at the state of things. Not because I find it difficult to write TailWind, or connect my Redux state to a component, but because I would have imagined the increase in the number of engineers would have led to more abstractions that would have simplified the creation of a CRUD app, which is are just glorified web forms.
I wonder if ChatGPT had even stood a chance if engineers were good at engineering. But engineers are really mostly good at boiler-plating code complex enough to ensure job security. Which ChatGPT might excel at one day.
What I would have liked to have seen is a world in which we were good at creating abstraction layers to solve an entire class of problems. But alas, I might have asked for too much.
Large teams tend towards complexity and it's understandable and frustrating at the same time.
In terms of organizing work among huge groups of people, I don't think any of the above possibilities would be feasible for an industry. We already complain about having just a handful of frameworks to choose from.
I love this quote and I think its apt here, “Any idiot can build a bridge that stands, but it takes an engineer to build a bridge that barely stands.”
Many developers are trying to get React experience on their resume to be more hireable; they do not care whether it's the best solution for the business, only that it adequately compensates them for labor that they can use to sustain their families.
With smaller organizations I think you can better control the motivations behind design solutions, but larger orgs can become a complete mess due to the politics (e.g. tech leadership encouraging all teams to use technology X, regardless of whether it makes sense for many situations). Collectively, these decisions and the resulting norms put pressure across the industry, encouraging certain behaviors and discouraging others.
I've been down a rabbit hole for the last five years researching this, and I am converging on Clojure. I don't understand why transducers aren't used everywhere, they seem to solve a gigantic class of problems that I see everywhere.
I'm also getting the feeling that Haskell folks have really done a lot of great work, and plan to learn more about their typing system next. Monads seem to be a fundamental building block.
If I try to bring this up with engineering teams, I don't get any traction because nobody wants to learn any of this stuff. It takes too much time to ramp developers up, and management is skeptical because there aren't enough large-scale communities or companies built around the concepts from their perspective. Bottom line is, it takes too much investment for too much risk.
Instead we get a lot of half-baked and wrong abstractions incrementally invented for the latest pain point instead.
Sorry, but no. If that or transducers are the things you think about on this context, you are going on the wrong direction.
Not that those aren't useful. Whatever software solves the OP's problem will certainly make plenty of usage of interpreters and lambdas (what monads and transducers are), and any developers should be able to use both of those. But those are completely removed from the problem, they aren't an attempt to solve it.
There are many different sources and sinks, but the processing pipelines tend to be the same.
Based on my research these abstractions are designed for this. Feel free to elaborate why I'm incorrect, or better abstractions.
I brought it up in the discussion relating to CRUD, because it's very similar to the code I used to write for straight CRUD. In fact both ends of the processing pipelines are identical to CRUD.
Those two are general purpose abstractions aimed at organizing code. They can certainly be used for this, just like they can be used for anything.
> transducers
Just a function composition operator. Notes: is aware of iterators like `reduce`, and merges multiple consecutive of such loops into one. (should optimizing compilers not strive to do this anyway?)
> monads
Literally just an "interface". For instance, you will be able to .map() it.
> algebraic effects
Resumable exceptions (you can go back to the "throw" with the corrected data)
CRUD is easier than ever and frankly not the pain point of software. Banishing boilerplate also isn’t a goal without trade offs, so it’s not a good litmus test to how good our tools are.
Everything after the "but..." is beyond the CRUD. If you choose to use TailWind or React or whatever to write the frontend and it increases the complexity of your app, that's your (or your client's) choice.
That said, Django was around before you started programming, so yeah perhaps the landscape (including the fads) got a bit more complicated in the past decade. But... I was there during the PHP4 era and writing a CRUD app with forms back then was much more painful than it is now... You either have to invent your own web framework or copy&paste a lot of hand crafted HTML and SQL. I tried both.
In my experience writing novels with ChatGPT, it starts to break down after a long running thread before eventually becoming almost useless. I wind up needing to remind it what it’s doing over and over.
That is likely by virtue of its limit on tokens, but I think also because the weight each token has reduces as the conversation continues.
I wonder if users would slowly watch the website go insane after using over X interactions.
For example, if I were writing a novel about a fantasy kingdom and there is an evil king, then I can write a description of the king ("The king is evil and wears a red crown") with the keyword to "include" it being "crown", "king", etc.
As the number of tokens increases with these AIs I think this problem will decrease decrease (1k was NovelAI originally, and now GPT-3 Codex is 8k). I do wonder what the "ideal" solution is in the future though. Or do you have to create a "lore book" for ChatGPT too?
(A thought I've had is that maybe we can automatically "create" the "lore book" and then re-inject that seamlessly? For example, in the fantasy kingdom example, maybe ChatGPT can generate a list of characters for each "chunk" of text and then automatically inject that into the "last" batch of text.)
Funny enough, that’s the automated version of what I do! Every X prompts, I ask ChatGPT:
List the cast of this story and their goals
I’ve found this really helps extend the shelf life of our thread :)
Tolkien kept changing his world as he went along, so the Lord of The Rings required him to make changes to the Hobbit, and his Silmarillion needed extensive edits to bring it back into synch with LoTR canon.
As for Martin (assuming you mean G.R.R.)… well, he’s already mimicking that other failure mode of ChatGPT - that response times can get long when under load, and eventually the whole session might just time out.
I wonder if there's a similar way one could work with ChatGPT, instead of having to constantly remind it of the little details, like you did.
I think a really interesting use case for this would be to have it read through a long standards document and produce a compliant implementation, and maybe point out flaws/omissions. Maybe implement a full web browser from scratch? Or something less intense like a GLTF reader/writer? Or something ludicrous like a brainfuck implementation of Office Open XML, which has like ~7000 pages of specs.
Though I've noticed sometimes it gets fringier details incorrect but remains very self-assured nonetheless.
It’s like you’re trying working with someone who only has short-term memory, and also has a tendency to make up things and be scatterbrained.
I’d be careful with this. I maintain docs for a project and asked ChatGPT how to implement a feature. The answer is in the docs obviously. It returned a really compelling step by step guide including code samples. Like a great StackOverflow answer. The problem - it was completely wrong. The code samples called API’s that didn’t exist and the whole explanation was based on the premise they did.
Compared to google/SO, I’d say that the amount of wrong/inaccurate answers are about the same, but GPT requires a lot less effort.
I had it make up functionality of a python library and then make calls to functions that don't exist.
I imagine the further you move away from popularity, the more of a bullshitter chatGPT becomes.
This is quite a workaround, have you tried the official Davinci003 api? It's rather capable now and probably faster response times. Very cool experiment regardless!
(now I'm curious how well it would handle requests using our modern Redux Toolkit API syntax...)
Technically, react is already a bit conservative and maybe past its glory. I don't think it's actually that cool anymore. I've lived through a few hype cycles in technology and this one is starting to feel a bit stale. The whole community seems stuck in a "maybe this will work ... nope" loop where they keep on "fixing" statefulness of their apps, untangling the unholy mess of CSS from their business logic, fixing performance issues, etc. That's been going on for nearly a decade now.
Of course the notion of using chat-gpt to "fix" state handling is a bit ludicrous. Sounds to me like a "maybe this will work?" type of thing.
Chatgpt is the new hammer here. And it looks like there's a wide category of nails it can wack. The right ambition level is figuring out just how big those nails are. I'd say, a more valid question to ask would be if something like chat gpt could generate a complete working UI and backend given a few prompts. I don't care if it's done in react or angular or whatever. As long as it works and the AI can iterate on it.
Separate template files can be organized neatly into directories and subdirectories as well. Templates in general can reside in their own "templates" directory and do not need to be mingled with the code. It is very clear where to look to find things.
The idea is, that you have modular statically rendered pages and then on some pages also serve a frontend framework for interactive components. I know that at least VueJS was able to be run like this. In the end, even with React or whatever other framework of its kind you use, you are still serving some HTML and some script tags, which may or may not include React, VueJS, or whatever else is the thing at the time. I am guessing, that React can work the same way that VueJS can, by simply including it on some rendered page templates, but I have not tried it.
> Here is it in Json format: ...
Seems pretty effective to get GTP-3 to spit out the results in the exact format you want. This will save me so much time parsing to get out the results I need.