Launch HN: Greptile (YC W24) - RAG on codebases that actually works
We are far from the first people to try "RAG on your codebase". We focus on full codebase comprehension: using LLMs to accurately answer difficult questions with full context of large, complex, and even multi-repo codebases.
Simple RAG alone is not sufficient for this task. Codebases aren’t like most PDFs, docs, or other similar data types. They are graphs—complex puzzles where each piece is interlinked. So Greptile does a few things past simple RAG:
(1) Instead of directly embedding code, we parse the AST of the codebase, recursively generate docstrings for each node in the tree, and then embed the docstrings.
(2) Alongside vector similarity search and keyword search, we do “agentic search” where an agent reviews the relevance of the search results, and scans the source code to follow references that might lead to something important. Then it returns the relevant sources.
For example, here are a couple questions that this system is able to answer in our test repo that simple RAG couldn’t (in our experience):
“Where are the auth providers configured?” (They are in an array inside of an options.ts file, where looking at the file it’s not obvious it’s an auth related file. However, because that array is imported into the auth/route.ts file, Greptile’s agent traces and find it)
“How would I add a postgres connector?” (The best way to answer this is to see how the Redis connector is set up and mirror it. Simple RAG sometimes retrieves some of the code for the Redis connector, but Greptile’s agent follows the connections to retrieve all the code that the redis connector touches, and uses that to write instructions.)
Developers (including at Stripe and Microsoft) are using Greptile for things like:
Debugging—you can paste in an error message and it does a pretty good job of diagnosing the root cause and suggesting fixes.
Grokking OSS repos—for example, if you're forking a repo, modifying it for your usecase, or just integrating it, Greptile lets you add multiple repos and dependencies in the same chat session so it has full context.
Parsing legacy code at work—especially if original engineers have left the company.
Since we're accessing your private code, we're very careful with security. We don't store any code on our servers after initial processing, and just pull snippets as needed from the GitHub API.
Quick note: when you sign in with GH, it might ask for permission to "act on your behalf". This is a quirk of GitHub's wording—our permissions are read-only and the only thing we do "on your behalf" is read code, so we can index the repo.
We came up with this idea while working at AWS—the codebase was super complicated, the docs were sparse and out of date, and our team was remote so it was slow to get answers to questions. We picked "greptile" because of "grep" and also we just wanted a somewhat silly name.
Try it out! It's a work in progress, so any feedback is appreciated. Here are the links again: for popular open source repos see https://app.greptile.com/repo, and to get it working on your own repo, start at https://app.greptile.com.
If you have experience working with a complex...
172 comments
[ 1.3 ms ] story [ 205 ms ] thread"When using "as_json" in a controller to return the JSON of a model, how are BigDecimal's encoded?"
Answer: "When using as_json in a controller to return the JSON of a model, BigDecimal values are encoded as strings. This behavior is defined in the active_support/core_ext/object/json.rb file, specifically in the BigDecimal class extension for JSON encoding. The rationale behind this approach is that most..." which is exactly the case as I learnt through various PR's, Issues and code review.
This would have saved me about 30mins of work. I wonder if it takes into account the metadata, such as authors, related comments, issues and PRs?
Excited to try it out
Does it integrate with Visual Studio, does it provide code suggestions?
Been doing a lot of back and forth iteration with ChatGPT to build a python project from scratch
It’s been a really good experience although frustratingly slow at times (from going back and forth between the browser and code and having to wait for gpt’s answers)
Can more documentation be automatically added? For example, it might be useful in a rails project to be able to get answers about the ruby and rails documentations
Docs is a good idea but we haven't found a reliable enough scraper to add docs from a website. We were thinking it would be cool if you could drop in like "docs.stripe.com" and it automatically adds stripe docs to the context.
This looks great - I just tried to generate sample code in the react repo and was pleasantly surprised. Do you have a sense of whether this works well to generate code in general, i.e. generate an API route to return X data that works similar to the other API routes.
We haven't built it for code gen in particular, but a lot of our users seem to be using it for that. We want to really nail down people getting to understand what is going on in the codebase itself.
https://app.greptile.com/share/4953cbff-13ec-4427-b0af-02889...
Thanks for pointing that out!
I can only think of two serious competitors, neither of which is open source. And I don't think anyone serious at either of those companies would claim that they have the definitive solution.
1. Haven’t figured out what should trigger updates. Every commit sounds crazy, every save would be perfect but too intensive also.
2. LLMs will not be self hosted. We haven’t been able to get the same results with any smaller LLMs
To answer your questions we definitely want to make this available for local repos and ideally self hosted, on a technical level that’s probably several month away.
You can also email me at daksh [at] greptile.com and I’ll set a reminder to let you know when it’s out
What triggers updates when it is not local?
That said, I think you're right and we might be overestimating the lift there. Will look into it more.
I've given it a fairly serious shot and my conclusion is that building IDE hooks is seriously depressing. IntelliJ deprecates APIs constantly and the docs don't really keep up.
And then there's the total dumpster fire that is trying to support GPU acceleration on multiple platforms.
Unfortunately it's easily 10x the work to do this kind of thing local only.
> Oops
> We couldn't access this repo.
> You may need to log in to view this repository, or it might not exist.
https://app.greptile.com/chat/github/porter-dev/porter
It also appears that the vote buttons do nothing if one is not logged in, so I'd recommend eliding them unless logged in since it's just frustrating to wonder if some JS error ate the vote or what
I shudder to think how much you must be spending on compute asking for that /api/poll/batch once a second, each one saying it is a Miss from cloudfront. It's especially mysterious since there's nothing on the UI that the user would see about the .filesProcessed increasing that justifies DDoSing yourself like that, IMHO
This is important because I'm not deeply familiar with public projects, so I can't accurately assess if the tool is worthwhile. Whereas with one of my repos, I'd be able to tell quality pretty quickly.
HACKERNEWS100
The latter is typically the realm of requirements, design documentation, and possibly test plans.
Generating such documentation from code seems quite impossible, or at least wrong.
It is unfortunate that most open source software is lacking in such documentation, giving off bad signals to junior developers.
Edit: not to take away from the product being discussed here, which seems very useful! I am merely supporting the parent here.
You forgot one of the biggest spots for "why" documentation... git commit messages, where the point is to say why you made this change. Maybe taking into account the commit messages around the code in question would help.
Still a great idea, though. Ingesting all data from JIRA may be beneficial as well.
Edit: chatting with processed repos should be working again now
It's a terrible choice of acronym if you ask me.
nice
Edit: Some of the repos that were processing at the time might have failed to process. Reach out to us on Discord if you're seeing errors.
"Link Your Code Hosting Providers Connect your accounts for seamless integration, and to access private repositories."
What does this mean?
Are you storing the embedding vectors you've calculated from the code? If so, those are likely quite easily reversible - so I would still consider that source code stored on your servers from the point of view of a security audit.
As a result, I might actually prefer to have copies of my code stored on your servers if it resulted in faster performance.
I don't think embeddings are generally reversible... you're usually projecting onto a lower dimensional space, and therefore losing information.
In theory if you know the model being used you could reverse them.
> We train our model to decode text embeddings from two state-of-the-art embedding models, and also show that our model can recover important personal information (full names) from a dataset of clinical notes.
https://arxiv.org/pdf/2310.06816.pdf
There's certainly information loss, but there is also a lot of information still present.
“a multi-step method that iteratively corrects and re-embeds text is able to recover 92% of 32-token text inputs exactly”.