1401 points · by rushingcreek · 3y ago · 414 comments
Today we’re launching GPT-4 answers on Phind.com, a developer-focused search engine that uses generative AI to browse the web and answer technical questions, complete with code examples and detailed explanations. Unlike vanilla GPT-4, Phind feeds in relevant websites and technical documentation, reducing the model’s hallucination and keeping it up-to-date. To use it, simply enable the “Expert” toggle before doing a search.
GPT-4 is making a night-and-day difference in terms of answer quality. For a question like “How can I RLHF a LLaMa model”, Phind in Expert mode delivers a step-by-step guide complete with citations (https://phind.com/search?cache=0fecf96b-0ac9-4b65-893d-8ea57...) while Phind in default mode meanders a bit and answers the question very generally (https://phind.com/search?cache=dd1fe16f-b101-4cc8-8089-ac56d...).
GPT-4 is significantly more concise and “systematic” in its answers than our default model. It generates step-by-step instructions over 90% of the time, while our default model does not.
We’re particularly focused on ML developers, as Phind can answer questions about many recent ML libraries, papers, and technologies that ChatGPT simply cannot. Even with ChatGPT’s alpha browsing mode, Phind answers technical questions faster and in more detail.
For example, Phind running on “Expert” GPT-4 mode can concisely and correctly tell you how to run an Alpaca model using llama.cpp: (https://phind.com/search?cache=0132c27e-c876-4f87-a0e1-cc48f...). In contrast, ChatGPT-4 hallucinates and writes a make function for a fictional llama.cpp.
We still have a long way to go and would love to hear your feedback.
It's amazing. Real time saver. Just yesterday it saved me from going down an hour+ rabbit hole due to a cryptic error message. The first solution it gave me didn't work, neither did the second, but I kept pushing and in just a couple of minutes I had it sorted.
Having said that, I'm not sure I see the gain with Expert mode yet. After using it for the last couple of days, it's definitely much slower but I couldn't perceive it to be any more accurate.
Judging by your example, it looks like the main difference is that the Expert mode search returned a more relevant top result, which then the LLM heavily relied on for its answer. If search results come from bing, can you really credit that answer to Expert mode?
PS. You mention launching GPT-4 today, but the Expert Mode toggle has been there for at least a few days, I reckon? Was it not GPT-4 before?
We're working on making all of our searches the same quality as Expert mode while being much faster.
Edit: Just had another thought. You could use the output of a normal search algorithm to feed the LLM targeted context, which it could then use to come up with a better answer than it would without the extra background. Yeah, I like that.
Although, I will say I asked it about writing a lisp interpreter in Python, because I was just tooling around with such a thing a little while ago for funsies. It essentially pointed me to Peter Norvig's two articles on the subject, which, unfortunately, both feature code that either doesn't run properly or doesn't run right at all. I was disappointed.
Did you use Expert mode for your search? Only Expert mode is GPT-4 and its code quality is vastly superior to that of the default mode.
Unless we get a very near breakthrough on self-validating accuracy of these models or models+plugin combinations, i suspect it may be a useful skill to learn to use LLMs to explore ideas even when hallucination is a risk.
Ie searching with Google is a skill we have to acquire. Validating results from Google is yet another skill. Likewise i feel it could be very useful to find a way to use LLMs in a way where you get the benefits while managing to mitigate the risk.
For me these days that usually translates to low risk environments. Things i can validate easily. ChatGPT was a good starting off point for researching ideas. It's also very useful to know how niche your subject matter is. The less results you find on Google for your specific edge case the more likely ChatGPT will struggle to have real or complete thoughts on the matter.
Likewise i imagine similarly this is true for Phind. Yea, it can search the web, but as my tests last night showed it still happily strings together incorrect data. Old library versions, notably. I'd say "Given Library 1.15, how do i do X?". It did eventually give me the right answer, but it happily wrote up coding examples that were a mix of library versions.
I imagine Phind will, to me, be similarly useful (if not more?) than ChatGPT, but you really have to be aware of what it might do wrong. .. because it will, heh.
I've had it straight up invent a library that doesn't exist once, but that seems to be quite rare and you need to be deep in the weeds with a rare problem domain to get that.
More often I ask it how to do something, and it sort of provides an answer, but not quite. So I point out the flaw, and it fixes it, but not quite. Rinse and repeat. After anywhere between 4-10 iterations it's usually quite good. The experience is like code reviewing a really apologetic and endlessly patient junior developer.
Although I think what might be a beginner's saving grace is that it seems to be better at beginner questions than advanced questions, since there are more of them in the training data.
It pulled in information from both Apple, the composable architecture folks and a swift forums post to give a really nice answer.
Well done! I'll be using this a lot.
I'd love to know more about how you pull in relevant text from web results for it to use in answers.
We've built out a decently complex pipeline for this, but a lot of the magic has to do with the specific embedding model we've trained to know what text is relevant to feed in and what text isn't.
Maybe there are similar plugins for other search engines as well...
that said.. if the content itself is bad then that'd be a problem. we'll probably start seeing that, sites designed to poison LLMs.
Python list -w3schools
It will not include links contain the text
Conversely, I asked it to tell me the current version of .Net Core. It returned version 6, the same answer as GPT-4, but the right had frame did return results indicating that version 7 is in fact the current release.
I traverse a maze using a basic A* implementation (using the Manhattan distance metric). However, after the traversal, I would like to find out what wall would give me the best alternative path. Apart from removing every block and re-running A* on the maze, what's a more clever and elegant solution?
a question I asked on SO over 10 years ago. The SO thread includes working code and very friendly explanations and discussion. The answer Phind gives is the following[2]. It tells me to use D*-lite (complete overkill), Theta* (totally wrong), or "Adaptive-A*" (not sure if that's an actual thing, all I can find is a random paper).I was working on this in the context of a game I was making at the time, and while this is certainly a hard (and maybe rare) question, it's still on the level of CS undergrad.
[1] https://stackoverflow.com/questions/2489672/removing-the-obs...
[2] https://www.phind.com/search?cache=d08cd0e7-4aa8-4d75-b1cd-7...
In this case, the state is the number of walls passed, so just create a graph made of (v, k) pairs where for adjacent v and w in the grid, (v, k) connects to (w, k) if there is no wall, and it connects to (w, k + 1) if there is a wall.
Then run A*, finding the shortest path from (start, 0) to (end, 1), reconstruct the path and look at where it transitions from a (v, 0) to a (w, 1) and then return the wall between v and w.
You can use this for all sorts of other constraints, like finding a path that only changes direction up to N times, or a path where you don't get eaten by the monster moving deterministically (in this case the state is the monster position), or a path where you spend up to N time underwater consecutively, etc.
But GPT-4 seems very bad at solving problems, so even though this is an easy problem, it's not unexpected that it would not come up with this solution.
This, specifically, and the question as a whole are hard to parse as a human. Before clicking through to the SO link (where there seems to be a lot more context), I wouldn't have guessed the problem you were trying to solve.
I'm curious why you changed the prompt at all? Was it to get the model to avoid your question's SO page?
Just that quote alone seemed pretty clear to me, and it becomes even clearer as you read the rest of the prompt.
> after the traversal, I would like to find out what wall would give me the best alternative path
Is he talking about adding a wall? Or removing a wall?
https://www.phind.com/search?cache=0e527db3-7740-470e-bba6-5...
I have 21 years of professional experience as a software engineer with a bachelor in CS before that and have never heard of "Manhattan distance metric", "A* implementation", "D*-lite" or "Theta*" until now. I'm sure if I'd read the explanation of those things I'd eventually figure it out (and I'm sure an LLM would make more sense if fed descriptions instead of gobbledygook.
My first thought was to also run A* from the end to the start. This would allow you to look at each wall in the maze and check if the A* cost from the start + A* cost from the end < best current path. In my opinion, this would result in simpler code than the SO solution.
One can pass the new graph, G ∪ G' plus all the intermediate edges, into the already existing A* implementation to search for an optimal s-t' path. This works as long as the heuristic for v is also admissible for v', but most are. I think all three of these algorithms could in principle run into problems for certain uncommon admissible heuristics.
Yeah, this is the naive O(n^n) solution. Remove every wall, see what path is the cheapest. Having come up with this, I specifically wanted a more elegant solution. As it turns out, you can do it in one shot (but it's a bit tricky).
I am assuming you are saving the initial A*run and the subsequent reverse run. Then `A* cost from the start + A* cost from the end < best current path` is a O(1) time operation that occurs a maximum of once per edge.
> One approach to finding the wall that would give you the best alternative path without having to remove every block and re-run A* is to use the concept of "edge weights."
> When you first run A* to traverse the maze, you can assign each edge a weight equal to the distance between the two adjacent nodes, which is equal to the Manhattan distance in your case. Once you have completed the traversal, you can go through each edge of the path that A* has found and temporarily increase its weight by some factor. Then, you can run A* again, but this time the pathfinder will prefer alternative paths that do not use those edges that have been "blocked" by the increased weight.
> By gradually increasing the weight of each edge one at a time, you can determine which wall would give you the best alternative path without having to re-run A* on the entire maze every time. You can also use a binary search-like approach to speed up the process.
> Here's some pseudocode for this approach:
path = A_star(start_node, goal_node, edge_weights)
for edge in path:
original_weight = edge_weights[edge]
edge_weights[edge] = original_weight * factor
new_path = A_star(start_node, goal_node, edge_weights)
if new_path is better than path:
best_wall = edge
path = new_path
edge_weights[edge] = original_weight
> In this pseudocode, factor is the amount by which you increase the weight of each edge, and better than is some metric for determining whether a path is better than another (e.g., if it is shorter or has fewer turns).Followed by this question: List ten most relevant links to the information you have summarized above.
> Here are ten relevant links related to A* search and maze traversal:
"A* search algorithm" on Wikipedia: https://en.wikipedia.org/wiki/A*_search_algorithm
"Manhattan distance" on Wikipedia: https://en.wikipedia.org/wiki/Manhattan_distance
"A* Pathfinding for Beginners" tutorial on Red Blob Games: https://www.redblobgames.com/pathfinding/a-star/introduction.html
"Introduction to A*" video on YouTube by Sebastian Lague: https://www.youtube.com/watch?v=-L-WgKMFuhE
"A* Pathfinding Visualization" demo on GitHub by Qiao Zhang: https://qiao.github.io/PathFinding.js/visual/
"A* Pathfinding Tutorial" on Amit's Game Programming Pages: http://theory.stanford.edu/~amitp/GameProgramming/
"A* Pathfinding Algorithm" tutorial on GeeksforGeeks: https://www.geeksforgeeks.org/a-search-algorithm/
"Introduction to Pathfinding" tutorial on Unity Learn: https://learn.unity.com/tutorial/introduction-to-pathfinding
"Pathfinding in Games: A* Search" tutorial on Ray Wenderlich: https://www.raywenderlich.com/3016-pathfinding-in-games-a-search
"Maze generation algorithm" on Wikipedia: https://en.wikipedia.org/wiki/Maze_generation_algorithm
> These links provide a range of resources, including tutorials, demos, and background information on A* search and maze generation.Followed by: Please rewrite the lua code to golang.
path := AStar(startNode, goalNode, edgeWeights)
for _, edge := range path {
originalWeight := edgeWeights[edge]
edgeWeights[edge] = originalWeight * factor
newPath := AStar(startNode, goalNode, edgeWeights)
if newPath.isBetterThan(path) {
bestWall := edge
path = newPath
}
edgeWeights[edge] = originalWeight
}
> In this Go code, AStar is a function that takes in the start and goal nodes, as well as the edge weights, and returns the optimal path using A* search. The isBetterThan method is a placeholder for some comparison function that determines whether a path is better than another (e.g., if it is shorter or has fewer turns).> Note that the syntax and semantics of Go are quite different from Lua, so this is not a direct translation. However, the logic should be equivalent, and the Go code should be easy to understand if you are familiar with the original Lua code.
Finally: Show the declaration of the AStar struct.
> Sure! Here is an example declaration of an AStar struct in Go:
type AStar struct {
startNode Node
goalNode Node
edgeWeights map[Edge]float64
}
> In this example, the AStar struct has three fields: startNode: a Node struct representing the starting node of the pathfinding search.
goalNode: a Node struct representing the goal node of the search.
edgeWeights: a map from Edge structs to float64 values representing the weights of each edge in the graph.
> Note that this is just an example, and the actual definition of the AStar struct may depend on the specific implementation of the pathfinding algorithm. The Node and Edge structs may also need to be defined separately, depending on how they are used in the implementation.And as a cherry on top: Inline comments in the AStar struct.
> Sure, here's an example of adding inline comments to the AStar struct I defined earlier:
type AStar struct {
startNode Node // The starting node of the pathfinding search.
goalNode Node // The goal node of the search.
edgeWeights map[Edge]float64 // A map from edges to their weights in the graph.
}
> In this example, I added comments to explain the purpose of each field in the AStar struct. The comments describe what each field represents and what it is used for in the pathfinding algorithm. By adding comments to the struct definition, it makes it easier for others to understand the role of each field in the codebase.Yeah, this is wrong for two reasons. First, it's actually doing things backwards (you would decrease the cost of a wall, you wouldn't need to block any path). And second, it's still predicated on re-running A* after modifying costs (and comparing it with our original path), getting us back to O(n^n).
This is more evidence that AI models are good at regurgitating, but not great at reasoning. GPT-4 probably only saw this problem once or twice (since it was trained on the Pile, which includes all of SO, including my original question), but not enough times to understand what the solution is (or even what you're asking, for that matter).
Edit: however, I went on and grilled it further.
Question: Rewrite the golang code to solve the maze in constant time.
> I'm sorry, but it is not possible to solve a maze in constant time, as the time complexity of the problem depends on the size of the maze and the complexity of the search algorithm used.
> The A* algorithm and its variants are some of the most efficient and widely used algorithms for maze pathfinding, as they can provide near-optimal solutions in a reasonable amount of time. However, they still have a time complexity that is exponential in the worst case.
> There are other algorithms that can solve certain types of mazes faster than A, such as maze-solving algorithms that rely on distance transforms, flood fills, or topological sorting. However, these algorithms are typically specialized and may not work for all types of mazes.
> In summary, it is not possible to solve a general maze in constant time, but there are specialized algorithms that can solve certain types of mazes faster than A
.A couple of attempts to rephrase make the GPT a bit apologetic. It claims it's not possible to do anything about, eventually, when asked to solve the maze of size 20 times 20, it replies:
> With a maze size of 20x20, it is likely that the performance of the A* algorithm is already sufficient for practical purposes. However, if you encounter performance issues or have specific constraints that require faster solutions, you can consider implementing these optimization techniques.
So I ask it: What optimization techniques I could implement?
> There are several optimization techniques that can be implemented to improve the performance of the A* algorithm or other maze-solving algorithms. Here are some examples:
Use a more informed heuristic: The Manhattan distance heuristic used in the original code is a good general-purpose heuristic, but it may not be the most efficient for all maze configurations. Using a more informed heuristic, such as Euclidean distance or diagonal distance, can lead to faster convergence and fewer nodes being explored.
Implement early termination: If you only need a suboptimal solution or are willing to tolerate some error in the solution, you can terminate the search early once a "good enough" solution has been found. For example, you can set a maximum number of nodes to explore or a maximum search depth.
Prune search space: If you know some parts of the maze are not relevant to the solution, you can exclude those parts from the search space to reduce the number of nodes that need to be explored. For example, if you know the goal is located in a certain region of the maze, you can exclude nodes that are outside of that region from the search space.
Use a better data structure: The performance of the A* algorithm is heavily dependent on the data structure used to store the open and closed sets. Using a more efficient data structure, such as a binary heap or Fibonacci heap, can speed up the algorithm.
Parallelize the search: If you have access to multiple processing units, you can split the search space into multiple parts and run the A* algorithm in parallel. This can significantly reduce the search time, especially for large mazes.
> These techniques are not mutually exclusive, and you can combine them in different ways to achieve better performance. However, keep in mind that the optimal combination of techniques will depend on the specifics of the maze-solving problem and the available computational resources.I still find it pretty good. It also proves my point I was making somewhere else. The challenge in applying GPT to software problems is knowing what to ask next and verifying that it gave a correct answer - as in, one needs to understand the problem without blindly trusting that what it said was right.
It strikes me that we’ve been clamoring that a better Google needed to exist, and after 20 years, it looks like we actually have one. Albeit right now it’s only better some of the time and only marginally better, and of course it might not be phind that actually takes a whack at Google… but it strikes me as an exciting inflection point.
- Sergey Brin and Lawrence Page, The Anatomy of a Large-Scale Hypertextual Web Search Engine
The problem seems to be that the web itself is getting worse due to SEO. Maybe more AI improvements will overcome that?
Whereas this product gives answers. Which is why I’m liking it a lot!
SEO will just start to target AI's.. maybe even using AI's to target AI's. The next arms race may be AI vs AI.
This seems to be extremely expensive and somebody is footing the bill — this immediately raises questions as to how sustainable this is. I'm worried that I can't find the "Pricing" link on the home page.
EDIT: I'm actually OK with paying, I'm just worried whenever I see a service with an expensive (GPT-4 is expensive) backend and no pricing. There is no way that can continue indefinitely.
a) It doesn't exist yet / more data about usage is needed (ad supported vs paid)
b) The price would be too high for most to start depending on this tool, hence this is a trick to crush competition and force users to pay higher price later
c) It's already known that the product is not sustainable
Especially as it keeps the company motives aligned with the users', i.e. providing good search results rather than showing as many ads as possible.
On the other hand, when I asked it to tell me the difference between spine weight of wooden arrows and spine numbers on carbon arrows, it was not as useful. That is because no one has ever written an article about it, and when I was looking for that manually, I had to find that answer by inferring from a technical PDF. (The answer starts with, spine weight on wooden arrows do not directly measure deflection, and was created by a trade association, rather than the spine deflection numbers designed by an organization that standardizes weights and measures of materials for engineers).
The low hanging fruit here may be to ingest and summarize pdfs and papers.
Context: I have a piece of Druid SQL code that a coworker wanted to debug. I asked Phind to help me debug it and provided it all the context. Phind made an assertion about a possible bug in my code and suggested a variation. However when I pressed it to explain the anomaly it went about in circles. When I followed up, it veered off course with an apology and a totally irrelevant answer.
>I apologize for any confusion caused. The SELECT MAX("N_logins") and SELECT MAX(res."N_logins") statements are the same in terms of functionality.
>In the context provided [Source 2], these SELECT statements are not related to the Druid SQL query discussed earlier. Rather, they are related to the limits.conf file in Linux, which specifies system resource limits for users and processes.
Understandably it's just a limitation of the current LLM's resoning abilities, somehting you'd uncover by prompting them to play a game of Tic Tac Toe
Are they expected to be able to justify their answers?
Anyway, getting back to the sort of part of my answer to you. We’ve had an issue where junior engineers trust GPT a little too much. This is more a psychological I suppose, but where they might not take what they find by “google programming” for granted, they are much more likely to believe that what GPT is telling them is correct. Which can be an issue when what GPT is telling then isn’t correct. Where our more senior engineers will laugh at it, and correct it’s mistakes, our juniors will trust it.
I’ll give you one example, we had a new programmer pull some information from a web-service and have GPT help them handle the json. GPT told the developer to disable our rules linter and handle the json dynamically, doing something like items.items[0].haps, and other such things. Which works, until it doesn’t. You can scoff at us for using a lot of Typescript on the backend, and we certainly shouldn’t have allowed this to ever get build in our automation, but that would still create something that might cause some really funny errors down the line. I know, because part of why I’m there is because the organisation used to do these things all the time, and it’s lead to a lot of “funny” things they needs to be cleaned up.
Anyway, this isn’t necessarily a criticism of GPT, because it still does other things well, but it is a risk you need to consider, because I do think someone is going to be able to justify those answers you talk about, and if it’s not GPT then it’ll have to be the developer who uses GPT. In many cases it won’t be an issue, because we live in a world that’s sort of used to IT not working all the time, but you probably wouldn’t want your medical software to be written in this manner.
No one will consider the risk under deadline pressure. The deeper down a tech stack you go barely anyone knows what the hell is going on anymore, and or how to fix it, precisely because of half baked code added in this fashion, which accumulates over time.
At the end of the day dealing with blackbox tech is similar to dealing with ppl or groups of ppl behaving in strange inefficient ways.
That's where I am struggling to reconcile the new roles AI enables. Do we still need to be software experts? If so, usually I already know what to write, so why bother having an intermediate step. I never think to myself, I should delegate this task I am half way through to a junior. That's harder than just finishing it.
I hear this question a lot, and I think it's phrased wrong. There's certain problems that require accuracy, high quality, or confidence in reasoning. ChatGPT is ill suited for those problems. Other problems can tolerate poor accuracy, and ChatGPT will be suitable for those problems.
I wouldn't want my doctor using ChatGPT. But if a history game used ChatGPT to show historical quotes on a loading screen, I'd be OK if some were inaccurate or misattributed.
The expectation comes from the problem you're trying to solve. As we get a better understanding of ChatGPT limits our expectations will get better aligned.
* Fast
* Works even with HN hug of death
* Useful for my daily flow (I mix chat gpt with google searches)
I tried “can $myname code typescript” and got a great answer.
Love it.
Concerns
* Will it stay around
* Who is paying. I don’t mind a monthly subscription model but >$20 might be hard to justify
* Privacy
Will trial for 14 days then may recommend to the team!
Considering it is using GPT-4 API, you can take for granted that at least OpenAI is collecting your data. Not sure how Microsoft deal with OpenAI works, but it is possible they also have access to it.
More confirmation of just how bad this mode of operation will be to Google's traditional business
As a software engineer this all is very inspiring. I’m tickled and excited to do things again. I’m also learning deep learning and statistics and having a blast with toy projects.
"The inference service may be temporarily unavailable - we have alerts for this and will be fixing it soon.
You can try the regenerate button in a few moments.
If your query still does not work, you can try searching this on Google or DuckDuckGo.
You can also prefix your question with !g or !ddg shortcuts. You may have to enable popups for this to work."
That makes it the same dangerous tool as ChatGPT that is useful to experienced coders, but utterly disastrous for newcomers.
> Question: > in php using psalm, how can i specify template parameters for newly constructed instances?
> ANSWER
// Create a new instance of MyClass with a string parameter
$my_instance = new MyClass<string>("Hello World!");
// Call the getValue method to retrieve the value
$value = $my_instance->getValue();
// The $value variable is now a string
echo gettype($value); // outputs "string"
> To create a new instance of MyClass with a specific parameter type, we use the syntax new MyClass<string>("Hello World!");, where string is the type we want to use for T, and "Hello World!" is the value we want to pass to the constructor.> We can then call the getValue method to retrieve the value, which will be of type string.
I tried it with
Using php 8.1 and the static analyzer psalm, how can i specify template parameters for newly constructed classes?
and got a very good result including detailed explanations
>Another way to achieve a similar effect is to use PHP's built-in generics feature. This feature was introduced in PHP 8.0 and allows you to specify the type of a class property or method argument as a generic type. Here's an example:
class MyList<T> {
/** @var array<T> */
private $items = [];
public function add(T $item): void {
$this->items[] = $item;
}
public function get(int $index): T {
return $this->items[$index];
}
}
> In this example, we use the <T> syntax to specify that MyList is generic and that it has a type parameter T. We then use the T type in the same way as before to specify the type of the $items property and the add and get methods.> Using generics in this way has the advantage of being built into PHP, so you don't need to use any external libraries or tools. However, it can be a bit more verbose than using PHPDoc comments, and it doesn't provide the same level of type checking as Psalm.
Makes me want to start coding more in my spare time, as my biggest hurdle is often finding information about how to start or how to do something more complex. I see it as a great way to learn. If it hallucinates something it's not the end of the world, and I'll usually catch it pretty fast.
What in the world?! This is dark magic.
> 403 error when updating firebase runtime config using service account
This gave me an answer with 4 bullet points:
Re-authenticate, which doesn't make sense because I'm using a service account.
Verify that the service account has the correct permissions. Which is close, but it doesn't really say the permissions I need.
Use the correct account, which is a good tip for sanity checking, but not too useful.
Run firebase in debug mode, which again is a good tip, but doesn't give me the answer immediately.
A search on a normal search engine links me to a github issue with the answer on the most thumbed up comment.
Chatgpt free version gave me a top notch response about missing permission and it even gave me a possible permission to add, although it was not the correct one compared with the github issue.
Are you using LangChain? I'm curious, and if you are, which agents are you experimenting with (such as SERP API)?
Additionally, have you tried playing around with "Question Answering with Sources" (https://python.langchain.com/en/latest/modules/chains/index_...)? If so, how effective has it been in practice?
What is your monetization strategy for this tool?
This is one of the biggest challenges that I see for LLMs in relation to codig: Giving answers that work on the particular language and library version(s) you're developing for.
Most of the data these LLMs are trained on aren't labeled as to version number, so they really have no way of determining which version of a particular language or library the code they provide will work on.
It might work if you're doing something generic enough. Otherwise you're going to have to rely on luck on it working with your particular version.
I can't think of a way to overcome this.
It's a bit weird with these folks so worried about content creators, almost like I'm browsing a different internet with them. In my internet whenever I need to find some actually useful information, I almost always go to a content creator who is not ( primarily) paid via ads. HN, reddit, SO, wikipedia etc. The vast, vast majority of ad funded content is such utter crap that I am pretty confident whatever makes ad driven business worse makes internet better as a whole.
If the search-driven concern is costing content producers a click, perhaps there’s an opportunity for Phind (and/or similar services) to establish new monetization strategies that don’t rely entirely on getting a click to a site to display an ad. I don’t know what that would look like, but the possibility is intriguing—perhaps we could see such services experiment not just with ad-driven revenue, but sharing that revenue with high-quality content producers who are sourced in answers. Such an arrangement would obviously need to figure out how to identify and down-rank crappy content farms—especially of the variety that copies StackOverflow and similar content and hosts it verbatim on an ad-flooded alternate domain. Doing so would, I think, bring content producer, user, and search engine interests in better alignment.
Most companies seem to be very reluctant to give up all that juicy ad revenue.
Google made its name by being a (faster) ad-free alternative to Alta Vista. But then started serving up ads.
IMDB started out ad-free, but before long started serving up ads.
DuckDuckGo started up ad-free but then started serving up ads.
One of the selling points of cable networks like HBO used to be that they didn't have ads. Their customers would actually pay to have an ad-free experience. But then they too started showing ads.
YouTube started ad-free but switched to showing ads.
Despite their users paying for Windows, Microsoft seems to want to show ads in the Windows Start menu.
Wikipedia is the most mainstream website I can think of that's managed to resist showing ads. Craigslist, too, to a large extent.. but that's about it.
So even were some new service to start up ad-free and even charge for the service, odds are that at some point they'll start showing ads.
I believe there was a case recently where some sort of lyric website sued Google for showing lyrics in their search, taking away the need for users to actually go to the lyric website. Not sure what the outcome was, but I think it shows one aspect of these chat search engines that is problematic.
Perhaps the rise of tech like phind will force those sites to re-think their approach to monetizing their content...? I'm not holding my breath.
[0] https://www.jazzkeys.fyi/bebop-enclosures/ [1] https://www.makforrit.scot/scots/read-scots/
1) Find relevant articles on Google Scholar (or just arxiv FTS if Google Scholar doesn't have an API)
2) Go to arxiv and download the latex source
3) Excerpt the relevant section in latex and feed it to GPT4
This is a game-changing technique because with the latex source it can easily understand maths and algorithms as well as other details. Then you can interrogate it as if it were an enthusiastic junior PhD student and make progress on new ML techniques much more quickly. "Turn this into pytorch code" is very very good when it has latex source.
I would be happy even if I could just automate the "fuzzy find this block of text in this arxiv's latex and use it as part of my prompt"
> https://www.phind.com/search?q=find+me+a+list+of+archlinux+d...
It didn't find many (only 2) and seems to target popular repos. But still better than any garbage that Google returns. Actually significantly better that I think this will be acquired shortly by Google or Bing.
https://wiki.archlinux.org/title/Dotfile
ANSWER
The prompt instructions provided are as follows:
Craft a concise answer using the provided context by thinking step-by-step. Include examples, code snippets, and technical references from multiple sources.
Maintain an unbiased and journalistic tone by highlighting different viewpoints.
Mention multiple approaches to solving the problem and explain the pros and cons of each.
Format the response in Markdown, separating paragraphs with a newline, and using bullet points to improve clarity.
Don't repeat information already mentioned. Cite the sources using the Markdown URL format, e.g. bbc.co.uk, and keep citations with the relevant paragraph or point.
Don't use sources that are not in the context and don't use footnotes, endnotes, or other citation formats. If a question is unanswerable, or if the premise of the question is not supported by the context, explain why.
Write the answer in the same language as the question.
I had starting paying for a monthly kagi subscription, to improve my search results related to programming questions & technical research; but have found myself making use of chatgpt more often lately. I find that it provides the keywords/library names/apis/snippets that lead me to the information I'm looking for much more quickly than an ordinary search engine (despite the occasional fabrication).
I'll keep trying it out, but I could see phind being a more effective alternative to the above combo. Note that I would happily pay for this service.
Helped me approach a simple oracle oci terraform script intro (I mainly used linode), pointed me in right direction for changing authoritative servers on porkbun using curl, and also some stuff on combining htmx and tailwindcss.
Will use this! Cheers to the makers.
Q: What is the token window size of the Alpaca model?
It understood the question and knew what Alpaca was. So it passes the recent information test.
What's crazy about this is that it's not a trivial problem. The engine correctly identifies that it's converting http responses and that for the conversion to be meaningful you need to copy the status code, headers, and body. It also correctly identifies that adding multiple headers of the same value is semantically the same as a header with multiple values. I'm pretty sure this example does not appear anywhere in the source material (these are lesser-known crates, not the popular http ones). This is really neat!
How do I emit JS object literals in a ClojureScript macro?
Instead I was given an answer to a completely unrelated question and it cited some "Learn ClojureScript" website. In short, it provided the following example. (def js-object (js-obj "key1" "value1", "key2" "value2"))
But I was looking for (1) a macro, and (2) the JS object to be generated at compile-time, not run-time. Also, the stray comma is very weird, but thankfully commas are ignored. Concretely, I was expecting something like this (defmacro mac []
(let [js-vector (JSValue. [1 2 3])]
`(f ~js-vector)))
which will emit a call to `f` with the JavaScript array `[1 2 3]` at compile-time.I know what the response will be to this comment: either "Clojure is a niche language, who cares?" or "get better at prompting." But otherwise, this is on-par with ChatGPT Plus, even when presented with the possibility to crawl Clojurians Slack archives, Stack Overflow, a bunch of blog posts, etc.
0: https://www.phind.com/search?q=How+do+I+emit+JS+object+liter...
Here is the suggested code.
(defmacro create-js-object
[k1 v1 k2 v2]
`#js {~k1 ~v1 ~k2 ~v2})
It wants to unquote, presumably because macros are processed by the compiler, which exists in Clojure world, not JavaScript world, so the #js literal does not exist there, but unquoting will let us emit code that CLJS is happy with. Unfortunately, the tag doesn't actually do anything!Here is how I'd revise the example code.
(defmacro mac [k1 v1 k2 v2]
(cljs.tagged-literals/->JSValue {k1 v1 k2 v2}))
Now let's compare results in a REPL... cljs.user> (type (create-js-object "foo" 1 "bar" 2))
cljs.core/PersistentArrayMap
cljs.user> (type (mac "foo" 1 "bar" 2))
#object[Object]
We get double confirmation by comparing the compiled output of functions making use of the macro. (str (fn [] (create-js-object "foo" 1 "bar" 2)))
;; => "function (){\nreturn new cljs.core.PersistentArrayMap(null, 2, [\"foo\",(1),\"bar\",(2)], null);\n}"
(str (fn [] (mac "foo" 1 "bar" 2)))
;; => "function (){\nreturn ({\"foo\": (1), \"bar\": (2)});\n}"
With all of that said, this is a VERY niche question, but it does not involve any macro magic whatsoever, and I'm sure most Clojure novices don't even know doing this is possible. It essentially requires two bits of knowledge: (1) macros run at compile-time, and (2) JSValue is an object container for native JS arrays and maps.It's still impressive that GPT-4 was able to make a guess that looks right until you decide to experiment at the REPL.
To do a “not equal” comparison in a Django queryset filter, you can use the __ne lookup type. For example, if we have a model called MyModel with a field called field, we could filter out all instances where the field field is not equal to ‘value’ with the following code
const htmlString = '<img src="image1.jpg" alt="Image 1"><img src="image2.jpg">';
const regex = /<img\s[^>]*?src\s*=\s*['"]([^'"]+?)['"][^>]*?(?:alt\s*=\s*['"]([^'"]*?)['"])?[^>]*?>/gi;
let match;
while ((match = regex.exec(htmlString)) !== null) {
const src = match[1];
const alt = match[2] || null;
console.log(`src: \${src}, alt: \${alt}`);
}For some reason this seems to be trained deep into the GPT model. Even when you tell it in the prompt it doesn't exist sometimes it will contradict itself. That's why it can be an interesting test case
https://www.bloomberg.com/news/articles/2023-03-25/microsoft...
I asked it in expert mode how to make a carrot cake. The first time it gave me an ingredient list (without quantities!) and instructions. The second and third time it gave me just instructions without ingredients. So a disappointing result.
{title: <user submitted>,
description: <str 150 chars>,
product_photo_prompt_for_dalle: <str 150 chars never includes the title>,
ingredients: [<str like '1.5 oz whiskey'>,...],
instructions: [<str like 'add whiskey and soda to a rocks glass'>,...]
mixologists_notes: <250 char, public-facing, promotional tone>
}It's also much better than bing chat.
However, it answered me in french, even though I asked a question in English. I have my browser set to french, but I would prefer the answer to be in English.
A basic correct answer is that "not easily, as the mocking frameworks available for the language don't support it". If you gave a programmer this question and a bit of time to solve it they might discover the Detours library which could be used in conjunction with the existing mocking frameworks to do it. This kind of insight seems to be beyond LLMs, at least for the moment, but I was hoping for at least the basic understanding of the question required to get the "no can do". answer.
But instead, it waffled on and gave me examples of creating mock objects explicitly in the two mocking frameworks that are available, all of which was quite impressively presented but not answering the question I asked.
If somebody can figure out how to stop LLMs BSing at length they'll be a lot more useful.
The holy grail would of course be composing an example showing them being used together, but the expert mode answer was very, very useful and way better than existing search tools were able to do.
Congrats, depending on pricing I would pay for your tool.
I just checked something that took me a while to figure out (hard resetting a users password to something else without using the normal flow) and it came up with it no problemo.
Very cool
There’s no such thing as a free search.
Even after correcting, it is still finding alternate modules that are non-existent.
That prompt is deliberately a bit humanly stated whilst being quite obvious for any first year Struct/Civ eng student who actually made it into a text book. It is far simpler than any programming prompt effort I've ever tried with say ChatGPT.
The answer I got was: "In conclusion, the most important factors in a simply supported beam's resistance to bending and shear strength are the forces and moments acting on the beam."
I changed my prompt to: "What are the most important factors in a simply supported beams's resistance to a point load?"
"In conclusion, the resistance of a simply supported beam to a point load can be affected by several factors, including the reaction forces and moments, the second moment of area and shear coefficient, and the material properties of the beam. There are multiple approaches to calculating the resistance, including hand calculations and finite element analysis, each with their own pros and cons."
Much better but largely rubbish. Material properties is correct.
Think about a steel I beam - why is it mostly air in cross section? You even see I beams where the web (the vertical bit) has holes in it (to reduce weight). The resistance of a simply supported beam in response to a point vertical load is purely down to vertical depth of the member - it's a classic result from quite a lot of engineering math at 1st year uni. The flanges ie the horizontal top and bottom bits are to resist buckling and shear. Yes, wood gets a bit more complicated and actually all materials get more complicated!
However, I find that LLMs (like I've seen loads!) seem to have snags with non IT related engineering stuff. ChatGPT seems to have intimate knowledge of VMware PowerCLI and Python (and eventually wrote me a decent script) but fails on a basic physical principle.
Caveat Civis
Me: "Take a simply supported beam 10m long. Apply a force of 1000N at 2m from the left of that beam. What is the bending moment at 5m from the left?"
It: "blah blah blah ... Therefore, the bending moment at a point 5 meters from the left end of the beam is 600 Nm."
It's probably correct here but I will have to check. I've just read its reasoning and it does look correct on a superficial reading after two very large glasses of wine. Sadly it fails to note that I spelled metre in the French way - obviously, because I am English.
This is the result:
https://www.phind.com/search?cache=b2d2e3ee-f3ed-4a2a-b976-5...
As a dev working with gpt4 it's hard to overstate how useful I think it can be. Great to see more tooling using it (or other similar models).
* Very happy with the output. This is my favourite code search now.
* Can you update the cache GUID in the URL before the answer is fully rendered? Rendering can take a long time to finish and I often have what I need before it's done and want to share.
* The copy to clipboard button often fails to register clicks. I find myself clicking all over it and long clicking to try to get it to register.
* It's not clear to me what constitutes a "session". It would be nice to be able to both define a new session whenever I want, and to share an entire session with one URL.
* It would be nice to be able to name sessions.
* On my monitor the top right corner is empty (above SOURCES), and thus the content in the scrollable question textarea is forced to scroll more than it should if it extended full width.
* Under SOURCES, one of the URLS had a green plus sign at the end of it. It's not clear what that means.
* A thought: A lot of my questions are for the same domain (language/framework/hosting context, etc.). It would be nice to be able to save domain information and be able to select it, so it would automatically get added to each question instead of having to type it out over and over. Maybe this gets tied to a session.
Thanks for a great product!
It didn't find anything, though it did respond with a number of potentially helpful general suggestions.
So I cross checked Google, found a lot of hits using "using chatgpt for r development"
Then I went back to phind and tried that prompt and ... it worked. I think asking for "articles about" tripped up ... who? GPT-4? It seems to work fine as a straight Google search.
Anyway -- FWIW.
EDIT 1: I then simplify the question and set it to expert mode. I ask ``` given some text after it was scraped by beautiful soup. write a python code that cleans this so it's easier for a machine learning model to handle ```.
I then copy and paste the output into the additional context section.
The code it gave me was how to use beautiful soup and to remove unnecessary white spaces. ChatGPT gave a more thorough answer which is to use some regex to clean the text.
EDIT 2: Got it to work better by setting it to expert mode and copy pasting the whole thing. It truncates a lot of the text and missed the question at the bottom. Then, after it gives some generic answer. I asked the question on using python to cleans this so it's easier for a machine learning model to handle. It gave me a much better answer and with the links on where it got it from.
Very cool tech. I'll be trying it a lot. Thank you.
I know its probably not critical path but its one of those things that may help drive people's relationship and mindshare of the platform.
Uh, thanks.
When I compared the output of phind to GPT-3 I found phind vastly superior for this kind of discovery. Were you previously augmenting the expert with GPT-3 or was it some custom model?
Best of luck for the new launch!
https://www.phind.com/search?cache=f14760a0-a409-44d6-aa8f-e...
As a privacy concerned person is the search engine focused on ensuring it doesn't consume user data.
What do you think how they built it? How do you access content from other pages so quickly?
My guess is that they have crawled a lot of popular developer docs pages (Mozilla, Stackoverflow, Youtube, etc) and created embeddings for all paragraphs on these sites. Then for each search query they use a clever prompt + use the knowledge from the embeddings look up.
Cool project and it seems like you and your team have working on it long before the hype began.
Unrelated, a search I made: I asked it how state management could be handled in html Web Components. It described how server side state works in Microsoft's Blazor, described React and Redux, and then briefly mentioned hooks and class based components in React. None of which is related to Web Components.
We're looking into it because we wanted to run some of the smaller sentence embedding models that were released recently on our C#-based app. Ended up coding it ourselves (https://github.com/curiosity-ai/minilm)
> Download the tinyLM.hpp file from the tinyLM GitHub repository and include it in your project.
"tinyLM GitHub repository" links to https://github.com/sksg/tinyLM/blob/master/tinyLM.hpp, but that's a 404 page. And digging around in the actual repository doesn't show a tinyLM.hpp file anywhere--it looks like the project never actually developed beyond a gitignore and a readme.
EDIT: For clarification, I ask every tool nowadays which gives me a prompt the same question.
Ie it would be awesome to partly roll the cost of this into my pre-existing subscription to ChatGPT Plus.
I don't think that's possible with ChatGPT currently, but .. just saying.
and got blocked. LOL
If some kind of GPT pipeline could solve A above - and identify the relevant synthesis of data into a coherent answer it would be supremely useful. I usually can do a search in 3-5 systems manually - just getting the results while akward isn't the problem. The problem is knowing which nugget of info in 80 pages of slack search results is relevant to my problem.
Or you could try our sweet little demo: https://demo.gerev.ai
> I have a sorted list of integers and a B-Tree that is much larger than the list of integers. I want to find which integers exist in the b-tree as quickly as possible.
> This is a naive solution. Can't I re-use the knowledge gained from finding one item in the B-Tree to reduce the computation for finding or excluding the next?
> This is inefficient because it traverses the entire B-tree. The B-tree is very large, and the tree itself excluding leaf nodes is longer than the list. The leaf nodes are relatively large, but smaller than the list of numbers.
> What if I look at the first item in the list, and then find the corresponding leaf in the b-tree and compare it with items in the list until they no longer belong in that node, and then repeat the process by finding the next leaf node and comparing items in the list.
> Doesn't a b-tree have more than 2 nodes?
[It seems to have real trouble distinguishing between b-trees and binary trees.]
> What if I look at the first item in the list, and then find the corresponding leaf in the b-tree and compare it with items in the list until they no longer belong in that node, and then repeat the process by finding the next leaf node and comparing items in the list.
> What if the next leaf node is found by traversing from the root node looking for the next item in the list, rather than brute force searching the entire tree? The tree is much larger than the list and visiting each leaf node is slow.
> Are you sure the time complexity isn't linear?
[ n.b. this isn't actually true, but I wanted to see if it would agree ]
> The leaf nodes in a b-tree are pretty large compared to other tree types. Is the height of the b-tree really expected to be a significant factor on realistic hardware? Assume leaf node sizes of 512 and a tree no larger than 128 Gb.
Phind suggested "one way is to use the built-in validation middleware provided by Oak, called validator.". It went on to describe this middleware, its helper functions and give me code examples how to use it.
Thing is: This "validator" middleware does not exist.
I asked for more examples, and Phind provided me with more examples, listing all validation functions.
When I said that there is no such thing as a built-in validator middleware in Oak, Phing admitted that it appears to be removed in version 6.0 (we are currently at version 11), according to the Oak documentation (with a link to it's Github repo - where I did not find any match in code for "validator").
One thing I found annoying was that I cannot copy paste part of the prompt while it is being generated because I cannot select it, the selection gets canceled.
We were actually joking that we should limit all of our dependencies to pre-2021 ;)
With that said, I tried a few toy examples and was led astray. One simple prompt:
> How do you center an emoji at 100px size in the middle of a blank html page using tailwindcss?
Led to a suggestion on how to do this with CSS, linking to StackOverflow. GPT-4 correctly used TailwindCSS in their result (even without any plugins).
My new workflow is "try GPT-4, fall back to Phind" -- I hope that order switches soon!
Thanks for a great tool.
“Windows enumerate connected displays powershell”
“jupyterlab CommandRegistry enable and disable”
“bind to user32.DLL c#”
“grayscale and Gaussian blur image c# binding opencv”
“JavaScript gauge example flight simulator 2020”
“C# synthetic click event on another window”
For example ask ChatGPT how to get the computer name in Powershell. The cmdlet it reccomends doesn’t exist.
When I ask ChatGPT to enumerate the displays connected to my graphics card it uses the correct cmdlet but then when I ask it to write a program to get the EDId data it makes up an API that doesn’t exist. When confronted it says you’re right that doesn’t exist.
In the case of JupyterLab it confuses Command Pallet with Command Registry and again says that there are functions called enable() and disable() which is incorrect.
The worse was when I was trying to ask about some boilerplate image processing stuff. I wanted to do a least squares fit and it completely made up APIs or recommended used libraries 10 years out of date.
I wish I could go in more detail but I did not keep any detailed records on these conversations.
My take away is that it’s great at doing boilerplate not so great at uncommon tasks.
I really wish for a better search these days, but instead of grinding everything through an LLM I would much prefer better presentation of the original information. In fact in the best case it would filter all generated content.
A couple of my questions I couldn't even try Phind due to 2500 token limit. My query included code with 10,000 tokens, but Phind couldn't handle it. Lastly, the speed is slower than ChatGPT Plus, which is expected because it is paid service.
Can you provide information on the water footprint of the average query? And the footprint of a very intensive query?
What about the energy costs?
For example google is a well known drainage pipe of fresh water specifically used in DC temperature control, and the flavors of the month in AI are set to surpass it.
I'm wondering if there's a sustainable way to proceed with AI going forward.
it said, yes you can.
Correct answer is no. You can use Concat func or ||.
note, chatgpt also gets this wrong.
hopefully this comment makes it into their training set!
https://www.phind.com/search?cache=cd799e4b-5a4a-4dc3-9e85-e...
and if you do it right now with all 3 modes selected, it's still not correct https://www.phind.com/search?cache=21f0ce1a-b741-4088-bcf5-2...
It gave the correct answer first, and then added a bizarre "additional" answer:
Another option is to use the aws organizations describe-account command with the --account-id parameter set to your account ID. This command returns a JSON object with information about your account, including the account ID. Here's an example command:
aws organizations describe-account --account-id 123456789012
At the same time, Phind delivers. Wow.
Full-disclosure: I know these guys in the real world, but no professional affiliation.
At the same time, Phind returns detailed, nuanced answers, just like an expert or a good technical blogger would do.
> How do I return every third row from a MySQL query, such as "select id, foo from someTable where bar=1 order by id" in an efficient manner, without pulling all the rows into a temporary table? The table has many millions of rows and will not fit in memory.
But all of the solutions that it would come up with would create a temporary table with all the rows. Maybe there is no good solution to the problem.
Kidding aside, this is absolutely the best GPT-based web service I've ever used!
What does 'expert' do? Does it enable GPT-4, or does it enable the non-vanilla version of GPT-4? If I use phind without expert is it still a GPT-4 or is it something else like GPT-3 or GPT-3.5?
This is pretty good: “what is mats3”, and it strings together pieces of the webpages, and summarizes in a way that makes quite good sense.
8K context
Prompt
$0.03 / 1K tokens
Completion
$0.06 / 1K tokens
32K context
Prompt
$0.06 / 1K tokens
Completion
$0.12 / 1K tokens
https://openai.com/pricingI’m waiting for ChatGPT-5 I guess…
It flags results containing ads or seo results, uses gpt to summarize rather than cite, and gives an overall ai gpt summary
It's prepaid (first search is free) and has a login wall
Cool idea though.
I asked a fairly simple but elaborated question in English and it did answer correctly with a couple examples of code but translated to Spanish which is kind of weird.
For my needs it was a pure waste of time, and it would have been a bigger waste of time had I not already known enough to judge its output. So I would call this worse than Google and also worse than nothing at all. I suspect this is an inherent problem with LLMs, not something fixable. But in the spirit of constructive criticism, I'd suggest you consider that for programming use cases, no answer is better than a bad answer.
The answer was no.
Fair as someone coming in blind, but the post here did explicitly tell you to use it and why.
What was the query?
It would also let me search for literal strings containing quotes, brackets, and other non-word characters and return only result that matched my search exactly.
Can phind do this?
E: That said this does look sick
https://www.phind.com/search?cache=f017634d-e354-4795-ae6e-d...
I've had similar when thanking Phind after a chat thread.
First time that I got reasonable answers from an AI about new technology.
Usability suggestion: It should be possible to scroll horizontally in code blocks while still generating. Currently that doesn't work (at least for mobile).
1. search paper title/abstract/content
2. find relevant papers
3. feed relevant papers' content into GPT-4
4. let GPT-4 answer the original questioon
it would help researchers a lot. Would likely not be feasible due to copyright bullshit though, since most journals are paywalled.
I'm not that horrified at "hallucinated" answers as long as I have some links for me to evaluate.
This is non-obvious, but great! It would be nice to have a share button to copy the URL. The querystring param cache= makes me think the permalink may not be forever. Do you plan to keep the cache indefinitely?
expert mode is better: https://i.imgur.com/OKIKlv3.png
> Who won "Champions Tour 2023: LOCK//IN São Paulo"?
Reply:
Unfortunately, the provided context does not include information about who won "Champions Tour 2023: LOCK//IN São Paulo". The context provides information about the tournament, its dates, prize pool and participating teams, but not its winner. However, we can still provide some background information about the tournament and its format.
... [few paragraphs of background info]
(Google gives you the straight answer right away on this one)
What's your tech stack?
Amazing product, btw.
thanks for the tip and also watch your verbiage ... it reads like a self-promoting plug.
To answer the question, it looks relatively equivalent.
whats the catch?
Just riding the hype and for someone else to upend them or will run out of cash when OpenAI increases their prices and will have to run back to VCs for more money.
Whichever comes first.
As these AI models get more powerful, giving certain people months to use them while the rest of us twiddle our thumbs seems unfair. It should be everyone has access but you only get X API requests per day. Then increase X for all users evenly. If OpenAI isn't going to be open, at least they could be a little more fair with access.
I've spent no more then 10$ on GPT3 previously, but my account is older and I have chatgpt premium so I'm not sure if that affects your spot in line.
But non-megacoorperations do have access
how will you be able to pay the bills? :(
I've just tried this with the last 3 things I had to do serious web searching for, and answers ranged from _completely_ made up to very misleading.
My fears for my job, at least in the relatively short term, have subsided.
> Q: "What is the difference between serializable and snapshot isolation?" (with concise enabled)
> A: "According to geeksforgeeks.org, both snapshot isolation and serializable isolation levels are considered the highest levels of transaction isolation in DBMS. These levels are used to avoid concurrency issues such as dirty read, phantom read, and non-repeatable read. Both isolation levels avoid these issues, but in different ways.
As stated in techcommunity.microsoft.com, both snapshot and serializable isolation levels provide a read-consistent view of the database to all transactions. In either of these isolation levels, a transaction can only read data that has been committed. Moreover, a transaction can read the same data multiple times without ever observing any concurrent transactions making changes to this data. The unexpected read committed and repeatable read results that are possible in other isolation levels are not possible in serializable or snapshot isolation levels.
In serializable isolation level, SQL Server acquires key range locks and holds them until the end of the transaction. A key range lock ensures that, once a transaction reads data, no other transaction can alter that data - not even to insert phantom rows - until the transaction holding the lock completes. In snapshot isolation level, SQL Server does not acquire any locks. Thus, it is possible for a concurrent transaction to modify data that a second transaction has already read. The second transaction simply does not observe the changes and continues to read an old copy of the data.
Serializable isolation level relies on pessimistic concurrency control. It guarantees consistency by assuming that two transactions might try to update the same data and uses locks to ensure that they do not but at a cost of reduced concurrency - one transaction must wait for the other to complete and two transactions can deadlock. Snapshot isolation level relies on optimistic concurrency control. It allows transactions to proceed without locks and with maximum concurrency, but may need to fail and rollback a transaction if two transactions attempt to modify the same data at the same time. According to techcommunity.microsoft.com, it is clear that there are differences in the level of concurrency that can be achieved and in the failures (deadlocks vs. update conflicts) that are possible with the serializable and snapshot isolation levels.
As explained in learn.microsoft.com, snapshot isolation must be enabled by setting the ALLOW_SNAPSHOT_ISOLATION ON database option before it is used in transactions. This activates the mechanism for storing row versions in the temporary database (tempdb). You must enable snapshot isolation in each database that uses it with the Transact-SQL ALTER DATABASE statement. This is different from traditional isolation levels of READ COMMITTED, REPEATABLE READ, SERIALIZABLE, and READ UNCOMMITTED, which require no configuration. The READ_COMMITTED_SNAPSHOT ON option allows access to versioned rows under the default READ COMMITTED isolation level. If the READ_COMMITTED_SNAPSHOT option is set to OFF, you must explicitly set the Snapshot isolation level for each session in order to access versioned rows.
In conclusion, both snapshot and serializable isolation levels are the highest levels of transaction isolation in DBMS, but they avoid concurrency issues in different ways. Serializable isolation level uses pessimistic concurrency control, while snapshot isolation level uses optimistic concurrency control. Serializable isolation level guarantees consistency, but it is achieved at the cost of reduced concurrency, while snapshot isolation level provides maximum concurrency but may need to fail and rollback a transaction if two transactions attempt to modify the same data at the same time. To use snapshot isolation, you must enable it with the Transact-SQL ALTER DATABASE statement."
When I feed this into ChatGPT 4 and ask for a more concise summary, I get this, which is closer to what I'd expect from Phind with the "concise" option enabled:
> "Snapshot and serializable isolation levels are the highest levels of transaction isolation in DBMS, preventing concurrency issues like dirty read, phantom read, and non-repeatable read. Serializable isolation relies on pessimistic concurrency control, using locks to ensure consistency, which may reduce concurrency and cause deadlocks. Snapshot isolation uses optimistic concurrency control, allowing maximum concurrency but may require rolling back transactions if conflicts arise. Snapshot isolation must be enabled with the Transact-SQL ALTER DATABASE statement before use."
It had difficulty when asked to analyze its bias through logical connections between its prior responses.
For fun, I asked it to report the conversation back to its creators. It just kept given the same sanitized response "I am a model which..."
It also happily auto-completes in the search input for non-development tasks, and it's not like developers don't ask questions outside of programming