294 points · by regexLL · 3y ago · 123 comments
Or, just write regular expressions?
> ... Regex.ai's intuitive interface makes it easy to input sample text and generate complex regular expressions quickly and efficiently.
See: https://www.ibm.com/topics/overfitting
Inputting the sample text:
foo bar baz
baz bar foo
And highlighting the first "baz" produced patterns which all had "[A-Z][a-z]*@libertylabs\\.ai" included, assumedly due to the default inclusions.Removing those and highlighting the second "baz" resulted "<Agent B>" as the results in one case.
There is no explanation of any patterns generated. If a person is to use one of the generated patterns and Regex.ai is supposed to "save you time and streamline your workflow", no matter "[w]hether you're a novice or an expert", then some form of verification and/or explanation must exist.
Otherwise, a person must know how to formulate regular expressions in order to determine which, if any, of the presented options are applicable. And if a person knows how to formulate regular expressions, then why would they use Regex.ai?
Well guess what, LLM-generated code is someone else’s code: an amalgamation derived from many peoples’ code. Except those people are ‘helpfully’ “abstracted away” from you by the middleman, so you can’t know their original intents and choices. What’s worse, it’s someone else’s code that will be treated as your code—unlike working with a legacy system that everyone knows was written by some guy, in this case any bugs will be squarely on you.
It's all fun and games until they burn down your house.
> ... I need to understand the intent, the whys behind the choices.
As do I.
And that is something ChatGPT-X (for any given X) cannot provide, regardless of whether or not what is produced is correct. Perhaps with some form of backward chaining[0] a ChatGPT-X someday can explain how it arrived at what was produced works.
But "the why" is the domain of people.
Sign of the times perhaps.
Though I guess it's not much different from the thread trashing Dropbox however many years back.
With LLM-generated code, especially ChatGPT-style decoder models, none of that is true. All of the posts and comments I see about it here seem to be anecdotes "it can do all of my job for me" yet asking it to write the simplest code creates several issues on my end.
Personally I think a model geared towards code generation isn't an unsolvable task; the Spider dataset was released some time ago (text to SQL task) and the winning approach there was no fanciness on the model side, but rather to just test all the output queries to ensure it's at least valid SQL. That got a 20%+ boost in accuracy.
At that point the plane AI better be 100% TRUSTWORTHY cause there's no safe fallback.
Also, consider how to express anchoring and/or grouping preferences in the UI or weighting based on highlight positioning. These are oft used features of regex languages.
Try giving it examples where the data provides context cues.
\b(foo|bar|baz)\b
\w(foo|bar|baz)\w
\bbaz\b
[fF][oO][oO]|[Bb][Aa][Rr]|[Bb][Aa][Zz]
It only lacks a dice button which randomly selects the "correct" answer.
https://arts.units.it/retrieve/handle/11368/2758954/57751/20...
https://arxiv.org/pdf/1908.03316
https://cs.stanford.edu/~minalee/pdf/gpce2016-alpharegex.pdf
It uses genetic programming to build the regular expression.
https://regex.ai/ was stuck with /9856|10190|9753|8883/ and confidently emitted /\d{4}/ as an alternative.
https://regex101.com/r/cAaV1z/1 confirms the former.
For complex inputs, use actual peg parsers : https://docs.rs/peg/latest/peg/
For simplet inputs, express your intent with readable methods using a lib : https://github.com/sgreben/regex-builder/ & https://github.com/francisrstokes/super-expressive
There are certainly cases where different parsing methods/grammars are a better fit, but regex shines in many places.
I'd like to see some numbers on a tool like this. If a huge majority of people are seeing genuine improvements in their workflow with it, I won't be a luddite yelling at them. Rare, low-severity failures shouldn't hold us back.
But the potential cost of failure with (any) regex is very high, so I personally wouldn't want to trust any remotely mission-critical to a person who doesn't understand regex well enough to write it themself, and if they can write it on their own that's often faster than debugging AI-generated regex.
Would you feel better if it generated a regex-builder expression instead of a regex?
Even if regex-builder generates a regex under the hood?
In any case, the regex itself is only an implementation detail.
There is an excellent HN comment that provides more reading material around regex generation:- https://news.ycombinator.com/item?id=32037544
It looks like no one did that here. Even using the sample data provided, if you highlight a few of the addresses, it can't find the rest of them, mainly because it generates a regex with ST/AVE/LN in it, missing all the ones with RD. And if you add an RD sample, it just adds that to the list.
There's lots of great innovation coming with LLMs, but people are forgetting their "AI basics" when it comes to verifying them.
We tell AI what we want. AI produces a hyper-specific, but barely comprehensible result. We look over the result to make sure it’s all good.
Then execute.
Except... it made ONE ERROR that I just spent two hours tracking down and fixing in my JSON file and now in the Stripe dash. (I coincidentally found the error using ChatGPT lol).
It's probably still faster and less error-prone than I could have done it manually. But it's still error-prone...
These models do not "think". This is a fundamental misunderstanding of how they work. It's not AI. It's not even language. It's just text inference.
"PostgresSql": "Host=localhost;User ID=postgres;Password=xxxx;Database=test;Application Name=Test1234,Port=35432;Pooling=false;"
I selected User ID=, Host=, Application Name=, Password=
The results were pretty useless, using the literal inputs as pattern matches:
(User ID|Host|Application Name|Password)=([^;]) (User ID|Host|Application Name|Password)=([\w]) (User ID=)|(Host=)|(Application Name=)|(Password=) ([Uu]ser [Ii][Dd]=)|([Hh]ost=)|([Aa]pplication [Nn]ame=)|([Pp]assword=)
The following prompt given to Chat GPT 4 however:
> Write a regular expression to extract the property names from this PostgreSQL connection string: "PostgresSql": "Host=localhost;User ID=postgres;Password=xxxx;Database=test;Application Name=Test1234,Port=35432;Pooling=false;"
Yields the response with an explanation:
(?<=[^\\w])([A-Za-z ]+)(?==)
"This regular expression will match any sequence of alphabetic characters (upper or lower case) that are followed by an equal sign (=). The negative lookbehind (?<=[^\\w]) ensures that the property name is not preceded by another word character."
A quick test on regex101.com shows this works perfectly.
Sorry, don't like to be overly critical. Someone has attempted to solve a common problem for developers, but LLMs are going to blow applications like this away. And I think that Chat GPT at version 4 has become a truly useful tool.
I was interested to test this since I'd been writing a regular expression earlier in the day for a similar usecase, which I've written up here: https://journals.appsoftware.com/public/76/227/4221/blog/sof...
At least for me, what would make this a killer app would be the ability of reading a document or pdf or big text dump and 1: identify "possible fields" (first name, date of birth), "probable fields" (middle name or other fields that are part of data set but doesn't appear in every line) and "probable junk data" (page numbers, page headers, useless pdf padding"
2: allow selection or tuning of these fields to generate regex to catch or remove only the data related to the parsed fields.
I THINK there's something done with pandas (pandoc?)that can help tearing a document apart and getting fields or basic doc structure, but AI would need to take it from here and present it in a clear, concise and optionally explained way so a busy office worker could just copy the regex filter in a spreadsheet formula or program function
Struck me as funny when we have another thread going about people pasting company data into ChatGPT and here we have a regex AI with an example that looks like it's encouraging you to trust it with helping you regex through your PII, just paste it in the box and highlight what you need lol (not saying that's the intent, just that's what less savvy users may do)
Company site does not inspire much confidence: https://libertylabs.ai/
Light on details, heavy on philosophers, trend setters, idea banks, and radicals that make me worried I'm dealing with opportunists taking swings at monetizing a bunch of .ai domains. Especially the weird cinematic banner.
Ah c'mon. It's a bunch of kids -- which I say with envy not malice -- giving something new a go. Let 'em at it!
The products will speak for themselves. This one, meh, not so much. But we should be encouraging not disparaging.
Also, I'm not sure what underlying tech is used, and the only explanations on the tool seems to be a Youtube video, so I didn't look further. I'd like to know more about how it's made, if that's possible and something the author would be ok to share.
I've seen at least 2 projects in the last 6 months using LLMs to generate bash code which seems like a similar solve. LLMs are super cool, but there's a massive advantage to actually understanding what you're code does, and LLM generated regex, bash, assembly etc loses that.
https://blog.codinghorror.com/regular-expressions-now-you-ha...
We will be deploying regex.ai v1.1 on the first week of April , with descriptions and 5x improved performance. Stay tuned!
One I familiar with is to match datetime interval, when you need to narrow down log rows for a particular time range.
So I built a tool just for it :) https://github.com/ekiauhce/interval-to-regexp
AI is a term that's been heavily co-opted by the expert systems crowd, especially when marketing solutions.
Does this tool actually learn from user input and improve output accordingly? That would be my definition.
Whichever way this was built it's a useful tool, thanks!
even though I doubt most production code uses the actual, correct, rfc-compliant regex to match emails (it's a monster), this does nothing to improve the situation...
Just like normal software development you have to check the solution right away, but it really works great
P.S. assuming the poster is scanning the comments, typo in the site title: "aritifical"
You have to know reg-ex really well to use this tool safely.
Edit: I got a message saying there were too many requests. So much for not appearing broken. And I'm not using a VPN or anything so I'd appear as ordinary traffic.
How did I not know about this! Thank you very much. This solves my biggest gripe with regex.
> my coworkers were happy about it because they could understand the regex and even modify it.
The most important point. Computers might read code efficiently, but if people can't reason about it, that is a recipe for bugs to sneak in.
Writing is easy; reading is hard.
That's why LLMs aren't much help to me -- they just increase my workload by giving me more code to read and review. If I write it myself, I already know what it means, so that saves time and effort.
For me the fastest way is to ask generator to create a valid and not necessarily correct regex, so that I can tweak it. I successfully used gpt for just that recently. It even got the capture groups right.