Show HN: I replaced vector databases with Git for AI memory (PoC)

81 alexmrv 28 8/21/2025, 6:20:11 AM github.com ↗
Hey HN! I built a proof-of-concept for AI memory using Git instead of vector databases.

The insight: Git already solved versioned document management. Why are we building complex vector stores when we could just use markdown files with Git's built-in diff/blame/history?

How it works:

Memories stored as markdown files in a Git repo Each conversation = one commit git diff shows how understanding evolves over time BM25 for search (no embeddings needed) LLMs generate search queries from conversation context Example: Ask "how has my project evolved?" and it uses git diff to show actual changes in understanding, not just similarity scores.

This is very much a PoC - rough edges everywhere, not production ready. But it's been working surprisingly well for personal use. The entire index for a year of conversations fits in ~100MB RAM with sub-second retrieval.

The cool part: You can git checkout to any point in time and see exactly what the AI knew then. Perfect reproducibility, human-readable storage, and you can manually edit memories if needed.

GitHub: https://github.com/Growth-Kinetics/DiffMem

Stack: Python, GitPython, rank-bm25, OpenRouter for LLM orchestration. MIT licensed.

Would love feedback on the approach. Is this crazy or clever? What am I missing that will bite me later?

Comments (28)

lsb · 26m ago
Interesting! Text files in git can work for small sizes, like your 100MB.

That is what's known in FAISS as a "flat" index, just one thing after another. And obviously you can query by primary key to the key-value store that is git, and do atomic updates as you'd expect. In SQL land this is an unindexed column, you can do primary key lookups on the table, or you can look through every row in order to find what you want.

If you don't need fast query times, this could work great! You could also use SQL (maybe an AWS Aurora Postgres/MySQL table?) and stuff the fact and its embedding into a table, and get declarative relational queries (find me the closest 10 statements users A-J have made to embedding [0.1, 0.2, -0.1, ...] within the past day). Lots of SQL databases are getting embedding search (Postgres, sqlite, and more) so that will allow your embedding search to happen in a few milliseconds instead of a few seconds.

It could be worth sketching out how to use SQLite for your application, instead of using files on disk: SQLite was designed to be a better alternative to opening a file (what happens if power goes out while you are writing a file? what happens if you want to update two people's records, and not get caught mid-update by another web app process?) and is very well supported by many language ecosystems

BenoitP · 2h ago
I'm failing to grasp how it solves/replaces what vector db were created for in the first place (high-dimensional neighborhood searching, where the space to be searched grows by distance^dimension)
aszen · 2h ago
It doesn't replace vector db, it's more for storing agentic memory, think of information which you would like agents to remember across conversations with users just like humans
alexmrv · 2h ago
Super simplistic example, but say i mention my Daughter, who is 9.

Then mention she is 10,

a few years later she is 12 but now i call her by her name.

I have struggled to get any of the RAG approaches to handle this effectively. It is also 3 entries, but 2 of them are no longer useful, they are nothing but noise in the system.

PeterStuer · 50m ago
That is because basic RAG is not very useful as a long-term knowledge base. You have to actively annotate and transform data for it to become useful knowledge. I have the same problem in the regulation domain, which also constantly evolves.

In your case, you do not want to store the age as fact without context. Better is e.g. to transform the relative fact (age) into an absolute fact (year of birth), or contextualize it enough to transform it into more absolutes (age 10 in 2025.

No comments yet

visarga · 1h ago
> I have struggled to get any of the RAG approaches to handle this effectively.

You need to annotate your text chunks. For example you can use a LLM to look over the chunks and their dates and generate metadata like summary or entities. When you run embedding the combination data+metadata will work better than data alone.

The problem with RAG is that it only sees the surface level, for example "10+10" will not embed close to "20" because RAG does not execute the meaning of the text, it only represents the surface form. Thus using LLM to extract that meaning prior to embedding is a good move.

Make the implicit explicit. Circulate information across chunks prior to embedding. Treat text like code, embed <text inputs + LLM outputs> not text alone. The LLM is how you "execute" text to get its implicit meaning.

OutOfHere · 46m ago
When the RAG sees retrieved facts, it should see the timestamp for each. It will easily then use the latest fact if there aren't too many conflicting ones. I am assuming that the relevance ordering of the retrieved facts won't help.

Separating a RAG from a memory system, it is important for a memory system to be able to consolidate facts. Any decent memory system will have this feature. In our brain we even have an eight hour sleep window where memory consolidation can happen based on simulated queries via dreams.

johnisgood · 1h ago
I do not necessarily think it is noise, similar to how not all history is noise.
jaktet · 6m ago
That’s a pretty good analogy though, noise is just information that isn’t immediately useful for the current task

If I need to know the current age I don’t need to know the past ages of someone

OutOfHere · 27m ago
The submission and the readme fail to explain the important thing, which is how BM25 is run. If it creates bags of words for every document for every query, that would be ineffective. If it reuses the BM25 index, it is not clear when it is constricted, updated, and how it is stored.

Because BM25 ostensibly relies on word matching, there is no way it will extend to concept matching.

petesergeant · 2h ago
Exactly. If you're not using embeddings, why would you need a vector db?

> Why are we building complex vector stores

Because we want to use embeddings.

cc_ashby · 6m ago
Hey Alex, we actually had a very similar idea this morning! I could not find your contact anywhere, would love to chat. This is really cool.
meander_water · 25m ago
You could use BM25S [0] instead of rank-bm25 for a nice speedup.

Also, there are tradeoffs associated with using BM25 instead of embedding similarity. You're essentially trading semantic understanding for computational speed and keyword matching.

[0] https://github.com/xhluca/bm25s

cc_ashby · 19m ago
Maybe you can use Mercurial for this? You don’t need the complexity of Git for memory.
bob1029 · 1h ago
I think BM25 is the right path for most use cases. I'd reach for a single lucene index here, making the commit hash one of the document's indexed fields. This would make FTS across history nearly instant. I'd store it in an ignored folder right next to .git.

For code search only, BM25 might be a bit overkill and not exactly what you want. FM indexes would be a simpler and faster way to implement pure substring search.

Maybe having both kinds of search at the same time could work better than either in isolation. You could frame them as "semantic" and "exact" search from the perspective of the LLM tool calls. The prompt could then say things like "for searching the codebase use FunctionA, for searching requirements or issues, use FunctionB."

mingtianzhang · 1h ago
Very interesting idea! I also replaced vector databases with "Table of Content" for retrieval: https://colab.research.google.com/github/VectifyAI/PageIndex...
rekttrader · 2h ago
Using a vector db that’s created as a post commithook is probably a reasonable improvement. With context lengths getting bigger natural language is getting easier to work with but your leaving a bunch of gains on the floor without them.

No shade on your project, this is an emerging space and we can all use novel approaches.

Keep it up!

alexmrv · 2h ago
ooo nice post-commit creation of the db for the "now" state and links to the files for diff/historical? best of both worlds.
nunodonato · 1h ago
I was working on memory consolidation and memory pruning 3 years ago (with GPT3 Davinci). Glad to see more people are working towards this.
simplecto · 1h ago
Just had a look at the repo -- I'm curious to know where this goes when you add vectors for semantic / hybrid search.

The use of commit-hooks is also very clever (mentioned here in the replies)

aszen · 2h ago
Interesting idea, I like the fact that it doesn't use embeddings, and going into historical memory is an extra step that doesn't impact the speed of resolving the current information
alexmrv · 2h ago
exactly!

And you can _choose_ to explore the history, which in the most common case is not even needed.

jmtulloss · 2h ago
Seems really interesting! It would be great to see some evals to understand how well this works when stacked up against different approaches and use cases.
alexmrv · 2h ago
Keen to do this as well! But couldn't find a good reliable eval for memory creation and retrieval, if you have one you could recommend i'd give it a go asap.
namrog84 · 2h ago
I'm no ai expert so consider my opinion having little value besides casual user. But I really like this. It seems clever and easy for me to grasp some pros for this approach.

I could envision a bunch of use cases about this workikg well. Ive personally encounter scenadios where sometimes the ai gets hung up on irrelevant outdated fact. But could still look up if specifically needed.

I could see even an automated short summary of all history that is outdated being updated in the vector db from this too. So not all context is lost.

Keep up the great work!

_pdp_ · 1h ago
I mean these are two completely different approaches for completely different purposes. So saying that git replaces vector database is like saying that that a filing cabinet replaces a search engines.
thecopy · 2h ago
This is cool! Do you have any plans on releasing it as an MCP server? Would love to add this to my mcp gateway service https://mcp-boss.com/ (shameless plug)
alexmrv · 2h ago
Would have to be productionized, the current repo is a PoC, but if there is enough interest we could def commit some resources to hardening this and adding things like MCP.