My Muhaddith

Precise Hadith search using vector similarity search.



Next.JS v14 Chroma Turso GitHub last commit

Introduction

My Muhaddith is a Hadith search engine that uses vector similarity search to find the most semantically similar Hadith to the user's query.

Why?

Traditional search engines use keyword matching to find relevant Hadiths. This approach is limited because it does not consider the meaning of the query or the Hadith. Vector similarity search, on the other hand, uses embeddings to represent the meaning of the Hadiths and queries. This allows the search engine to find Hadiths that are semantically similar to the query, even if they do not share any keywords.

How?

My Muhaddith uses Voyage AI to generate embeddings for the Hadiths and queries. These embeddings are stored in Chroma, a vector store and search engine. When a user enters a query, My Muhaddith sends the query embeddings to Chroma, which returns the IDs of the most semantically similar Hadiths using vector similarity search. My Muhaddith then retrieves these Hadiths by ID from LibSQL and displays them to the user on the frontend.

Example

Query:

Manners of eating

Results:

Rank Distance Hadith Link
1 0.392 'A tailor invited Allah's Messenger (ﷺ) to a meal which he had prepared. I went along with Allah's Messenger (ﷺ) and saw him seeking to eat the pieces of gourd from the various sides of the dish. Since that day I have liked to eat gourd. `Umar bin Abi Salama said: The Prophet, said to me, "Eat with your right hand."' Sahih al-Bukhari 5379
2 0.406 'While I was with the Prophet (ﷺ) he said to a man who was with him, "I do not take my meals while leaning."' Sahih al-Bukhari 5399
3 0.410 'The Prophet (ﷺ) said, "When your servant brings your meals to you then if he does not let him sit and share the meals, then he should at least give him a mouthful or two mouthfuls of that meal or a meal or two meals, as he has prepared it."' Sahih al-Bukhari 2557
4 0.416 'I was a boy under the care of Allah's Messenger (ﷺ) and my hand used to go around the dish while I was eating. So Allah's Messenger (ﷺ) said to me, 'O boy! Mention the Name of Allah and eat with your right hand, and eat of the dish what is nearer to you." Since then I have applied those instructions when eating.' Sahih al-Bukhari 5376
5 0.422 'Allah's Messenger (ﷺ) said, "I do not take my meals while leaning (against something).' Sahih al-Bukhari 5398
note: The lower the distance, the more semantically similar the Hadith is to the query.

Disclaimer

This project is an early prototype. Currently, only Sahih al-Bukhari Hadiths are available in the search engine. The search results are based on the embeddings generated by Voyage AI and may miss some relevant Hadiths or include irrelevant ones. The search engine is a work in progress, and we are continuously improving it.

Tech Stack

  • Next.js for the full-stack application.
  • Voyage AI to generate embeddings for Hadiths and queries.
  • Chroma to store and search for embeddings.
  • LibSQL to store the Hadiths.

Feature Roadmap

  • Vector search functionality
  • Sahih al-Bukhari Hadiths
  • Advanced search filters
  • More Hadith collections
  • Fatwas, Tafsirs, and other Islamic texts