Already in August, I implemented a new AI chat feature in Gramps Web but it took me a while to sort out a few outstanding things and write documentation, now I can finally start advertising it. Gramps Web will soon be the first open source genealogy system with an AI assistant!
When will it be released?
Gramps Web API v2.5.0 will be released in the next few days, followed directly Gramps Web (frontend) v24.10.0.
How does it work?
The chat assistant is based on retrieval augmented generation, a.k.a. RAG. You can check the Wikipedia article if you are interested in details, but the principle is fairly simple:
- Every Gramps Web object is converted to a textual string
- Every object string is encoded into a numerical vector using an embedding model
- A chat prompt is converted to a numerical vector using the same embedding model
- A vector search index finds the Gramps objects that are most semantically similar to the prompt, using cosine similarity
- The retrieved Gramps objects are sent to a large language model (LLM), which produces an answer to the prompt given the provided information.
What this means is that no model training is needed on Gramps data. Steps 1.-4. always happen fully locally. Only step 5 is where information is potentially sent to a third party like OpenAI’s API, but this is totally up to the person managing the Gramps Web instance. The implementation fully supports running an open source LLM locally, provided sufficient computing power is available.
The vector search engine is provided by Sifts that I had written originally to replace whoosh in Gramps Web.
What can it do?
At the moment, the assistant only retrieves a limited number of Gramps objects based on the question. That means its good at retrieval of information about individuals, events, or places. How good it is depends a lot on what you have in your database. Please play around and share your findings!
What can’t it do?
A lot of things! Since the system is currently only retrieving Gramps objects by semantic similarity, it will fail to answer even simple genealogical questions like “which of John Doe’s great grandparents were born in Southern Europe?”, unless the answer is contained in a textual note, since it cannot connect people across Gramps objects (children/parents work because they are part of the same family object).
Can it speak my language?
Yes, most likely! It depends on the embedding model and LLM you use, but many of them support a large number of languages.
How can I use it?
The new Gramps Web version will be released soon, you can already use it in the development version now. The documentation for setting it up is here:
How can I help?
Please share things that work and that don’t work - both for configuration (different models) and usage (different prompts, different databases).
If you want to help developing the chatbot, you can have a look at the relevant Python module.
Will it get better in the future?
Most likely yes.
One obvious way to improve the assistant (contributions welcome!) is to include tool calling. This would allow the assistant to tap into Gramps’ powerful genealogical and filtering capabilities, e.g. executing a relationship calculation.
I want to know more.
I am planning a series of blog posts to delve into the details of implementation & usage, I will share the links here.
Do we really need this?
I don’t know, but it was instructive & fun implementing it.
EDIT: By the way, chat & semantic search are disabled by default in Gramps Web. Once enabled, access to the chat feature can be limited to specific user groups (e.g., only owners). Of course, the LLM will never see information that a particular user cannot see, e.g. users with guest permissions will not get answers containing information on private records.