5 ms·
I don't trust the code quality evalution. The other day at work I wanted to split my string by ; but only if it's not within single quotes (think about splittin
by afiodorov 3y ago
I don't trust the code quality evalution. The other day at work I wanted to split my string by ; but only if it's not within single quotes (think about splitting many SQL statements). I explicitly asked for stdlib python solution and preferrably avoid counting quotes since that's a bit verbose.
GPT4 gave me a regex found on https://stackoverflow.com/a/2787979 https://stackoverflow.com/a/2787979 (without "), explained it to me and then it successfully added all the necessary unit tests and they passed - I commited all of that to the repo and moved on.
I couldn't get 70B to answer this question even with multiple nudges.
Every time I try something non GPT-4 I always go back - it's feels like a waste of time otherwise. A bit sad that LLMs follow the typical winner-takes-it-all tech curve. However if you could ask the smartest guy in the room your question every time, why wouldn't you?
---
Edit: USE CODE MODE and it'll actually solve it.
- rushingcreek 3y agoThanks for the feedback, could you please post the cached Phind link so we can take a look? It might also be helpful to try Phind Chat mode in cases like this. EDIT: It seems like Phind-70B is capable of getting the right regex nearly every time when Chat mode is used or search results are disabled. It seems that the search results are polluting the answer for this example, we'll look into how to fix it.
- afiodorov 3y agohttps://www.phind.com/search?cache=r2a52gs77wtmi277o0xi4z2a https://www.phind.com/search?cache=r2a52gs77wtmi277o0xi4z2a
- rushingcreek 3y agoPhind-70B worked well for me just now: https://www.phind.com/agent?cache=clsxokt2u0002ig09n1e11bj9 https://www.phind.com/agent?cache=clsxokt2u0002ig09n1e11bj9. For writing/manipulating code, Chat mode might work better than Search.
- afiodorov 3y agoYou're right! It solved it. I didn't know about the Code/Search distinction. I still struggled for it to write me the unit tests. It does write them, they just don't pass. But this is definitely much closer to GPT4 than I originally thought.
- dsp_person 3y agowoah I've been using phind for at least a few months and can't believe I never noticed the "Chat" button
- MaxikCZ 3y agoNow if we could get an AI that would switch code/search mode on its own
- retreatguru 3y agoYou may want to improve the ui/ux for getting to your chat. It’s very hard to find on your homepage even when looking for it.
- nimchimpsky 3y ago[dead]
- Perseids 3y agoI've tried it with a question which requires deeper expertise – "What is a good technique for device authentication in the context of IoT?" – and the Search mode is also worse than the Chat mode: - Search: https://www.phind.com/search?cache=s4e576jlnp1mpw73n9iy4sqc https://www.phind.com/search?cache=s4e576jlnp1mpw73n9iy4sqc - Chat: https://www.phind.com/agent?cache=clsyev95o0006le08b5pjrs14 https://www.phind.com/agent?cache=clsyev95o0006le08b5pjrs14 The search was heavily diluted by authentication methods that don't make any sense for machine-to-machine authentication, like multi-factor or biometric authentication, as well as the advice to combine several methods. It also falls into the, admittedly common, trap of assuming that certificate based authentication is more difficult to implement than symmetric key (i.e. pre-shared key) authentication. The chat answer is not perfect, but the signal-to-noise ratio is much better. The multi-factor authentication advice is again present, but it's the only major error, and it also adds relevant side-topics that point in the right direction (secure credential storage, secure boot, logging of auth attempts). The Python example is cute, but completely useless, though (Python for embedded devices is rare and in any case you wouldn't want a raw TLS socket, but use it in a MQTTS / HTTPS / CoAP+DTLS stack, and last but not least, it provides a server instead of client, even though IoT devices mostly communicate outbound).
- kunalgupta 3y agosame exp
- deleted 3y ago[deleted]
- romeros 3y agoit really feels like GPT-4 is Google and Everybody else is Yahoo/Bing. i.e cute but not really
- unshavedyak 3y agoAgreed, though i'm _really_ interested in trying 1M token Gemini. The idea of uploading my full codebase for code assist stuff sounds really interesting. If i can ever get access to the damn thing...
- phillipcarter 3y agoI'm curious how they'll handle this. My understanding is that it takes quite a long time to get an answer, since there's no magic "semantic database" built for you behind the scenes.
- l33tman 3y agoThat use-case seems inefficient to solve like that in the long run as well, like if you really would have to use a million tokens to do every small query you require on your data it would be prohibitively costly except doing as an experiment.
- behnamoh 3y agoDon't get your hope high—Google's article mentioned they'll limit it to 128K (at least in the beginning).
- HKH2 3y agoIn my experience, Bing's image search is way better than Google's. Also, I'm not going to use a search engine that I have to log in or do a captcha for.
- SubiculumCode 3y agousually id say no, but google's results these last months have been terrible
- ldjkfkdsjnv 3y agoYup, LLMs broke well known benchmarks
- jeffbee 3y ago> I wanted to split my ... SQL statements ... avoid counting quotes ... GPT4 gave me a regex ... I commited all of that to the repo I see that the future is brighter than ever for the information security industry.
- xyzzy_plugh 3y agoSure is! We've got a bright and oh so plentiful road ahead, pending we can avoid blowing up the planet.
- meindnoch 3y agoDoesn't handle escaped quotes, and the time complexity of that regex is very bad.
- eru 3y agoThe time complexity for all matching a string against any fixed regular expression is O(length of string). If you want to talk about constant factors, we need to leave our comfortable armchairs and actually benchmark. [Just to be clear, I am talking about real regular expressions, not Franken-xpressions with back-references etc here. But what the original commenter described is well within the realm of what you can do with regular expressions.] You are right about escaped quotes etc. That's part of why parsing with regular expressions is hard.
- meindnoch 3y agoThe time complexity for deciding whether an N-letter string matches a regex or not, is O(N). The time complexity of finding all matches is not O(N) - which is needed in OPs case, because they want to split the string. Also, OP's solution uses lookahead assertions, so it's not a real regular expression. (I wonder if we can summon @burntsushi for expert opinion on this?)
- eru 3y agoYou are right that the lookahead might be expensive. (There's probably a way that a sufficiently smart compiler of (ir-)regular expressions can optimize this expression to be still matchable quickly; but Python's regular expression matcher is probably not that smart. I'm not sure if any real world matcher is.) > The time complexity of finding all matches is not O(N) [...] If you are happy find a maximal set of non-overlapping matches, you can still do it in O(N). By 'maximal' I mean that you can't greedily find another match (without removing any of the existing matches.) A sketch of the technique is: take your pattern and wrap it up like this '.?{pattern.?}' (where ? means non-greedy repetition) and match that against your input string. You can do non-greedy repetition and the very limited form of sub-pattern capturing that you need to find all the matches of 'pattern' without breaking O(N) time. I'm not sure whether you can find the global maximum number of non-overlapping matches, instead of a just a greedy maximum, in O(N) time.
- planb 3y agoI didn't take a look at the code, but to me it sounds quite dangerous to take an implementation AND the unit tests straight from an LLM, commit and move on. Is this the new normal now?
- Xenoamorphous 3y agoI guess most people would review the code as if it had been written by a colleague?
- DougBTX 3y agoYes, a great way to think of it is as a widely read intern: https://www.oneusefulthing.org/p/on-boarding-your-ai-intern https://www.oneusefulthing.org/p/on-boarding-your-ai-intern You’ve still got to avoid prompting for questionable code in the first place, eg, splitting SQL statements on semicolons with an ad-hoc regex is going to fail in edge cases, but may be sufficient for a specific task.
- afiodorov 3y ago>but may be sufficient for a specific task Yes more than sufficient for an internal tool - we can assume good intentions of the users of the tool since people want for this to actually work and have no intention of hacking.
- phanimahesh 3y agoExcept now it's a vector if anyone gets access to this internal tool. I would be fine with this for one off scripts but absolutely can not consider anything less than full sql parsing or something equally robust if it is exposed over the network, even if only internally and behind authn and authz.
- docmars 3y agoFor this reason, I tend to ask LLMs additional questions like: "show me another way to do this" or specifically "how would someone with a higher need for security write this?"... knowing that I'm likely to get a more refined answer from different sources that have probably discussed deeper security implications around the same goals, for instance.
- sebstefan 3y agoCan you try this? "Can you give me an approach for a pathfinding algorithm on a 2D grid that will try to get me from point A to point B while staying under a maximum COST argument, and avoid going into tiles that are on fire, except if no other path is available under the maximum cost?" I've never found an AI that could solve this, because there's a lot of literature online about A* and tiles with cost, and solving this requires a different approach