Inspiration
We found out that most students often turn to AI chatbots when homework is due, but those chatbots don't know their textbook especially if it is local books, Mongolian textbooks in our case. The answers are often too general, partly in English, or simply different from what the official grade 10–11 textbooks teach, and teachers notice. Worse, students have no way to check whether an answer is right. We wanted an AI tutor that is fast like a chatbot but trustworthy like the textbook itself. We were a tiny bit lazy at doing our homework too:)
What it does
Сурах Бичиг AI is an AI tutor that answers students' questions only from the official Mongolian school textbooks.
Students pick their grade and subject, then ask a question in Mongolian, typed in Cyrillic or a transliteration of Cyrillic to English (e.g. "nomnii 54r huudsiig tailbarla", "Номны 54-р хуудсыг тайлбарла", "Explain the 54th page of the book"). The AI finds the most relevant textbook pages and explains the topic in Mongolian. Every answer shows source chips with page numbers, and the Эх сурвалж (Source) panel shows the exact textbook passage, so students can check every answer. If the answer isn't in the selected textbook, it says so instead of guessing. An EN/МН interface toggle and two answer modes: Сурах бичиг (textbook only) and Ерөнхий (general).
How we built it
INGESTION: Firstly, we extracted the 12books from official sites using requests, BeautifulSoup libraries to extract text , ,images and other metadata from Medle's GraphQL API saving the metadata in JSON format. Secondly, we used wtpsplit's SaT model to split the text into sentences, after that a Gemini model was used to split or group the sentences into chunks and associated page images. The chunks are then turned into text embeddings with Gemini Embedding 2 which is stored in a ChromaDB. RAG: At question time, the backend embeds the question with the same model and searches the selected book’s text chunks. then FastAPI/Uvicorn backend sends the retrieved text, related images and the question the LLM. Finally the answer from the LLM is sent to the web along with the citations/sources. Which is later streamed to the React/Vite frontend. This is text-based retrieval, not image-vector search.
Challenges we ran into
- Originally we extracted the pages from econtent.mn in jpg format because it had simpler framework and was easier to scrape. But after scraping all the books we realised that storing them as jpg would raise unnecessary challanges such as extracting them and seperating the graphs from the text. In the end we decided to ditch everything we had previously extracted and scrape from medle.mn because it stores the books in text format and jpg/jpeg format for the graphs and pictures.
- Another thing to mention is the legal side of using the official textbooks. We first asked our social studies teacher who told us to check the law. And after checking it we ran into a problem because the law says that the copyright law can be overruled if the contents are used with the purpose of educating the public and not for the purpose of financial gain. We didn't know what to do so we decided to contact a real lawyer and asked him. The answer was that we cannot use the book in its entirety so we deleted out all of the questions from our database and only kept the rest.
Accomplishments that we're proud of
- We all had no experience on how to actually build such web designs as it was the first hackathon for most of us. We are so proud of the quality of the AI and the web features specially because this web and AI is a thing that WE built, not copied, not stole, but built. We tested the quality and the tests came out as such:
- 50 out of 50 page retrieval
- 48 out of 48 citations
- 22 out 25 unrelated questions returned"not in the textbook", the one other asked for more context. Only 3 outputted errors
- Median response time of 2.8 seconds (2.304–4.298 seconds) The fact that the answers are traceable to the the textbook The web working and adapting on mobile devices are all accomplishments we are proud of
What we learned
- How to build a RAG system end to end, from PDF processing to retrieval, prompting and citations.
- How to split work and ship as a team of six under a deadline.
- That testing with real numbers matters. Our evaluation showed us both what works and what to fix
- The thrill of making something from scratch and seeing it work
- That AI when used or set up correctly is a really powerful thing
- How to use python libraries such as re, requests, beautifulsoup etc... ## What's next for Сурах бичиг AI / Textbook AI
- Fix server errors
- Fix the cold start of the server
- Widen the database by collaborating with writers to include their books
- Build on the idea of RAG web based on textbooks and include books in other languages
Built With
- artificial-intelligence
- chromadb
- education
- embeddings
- fastapi
- google-gemini
- javascript
- languages
- machine-learning
- mongolian
- python
- rag
- react
- render
- server-sent-events
- text-extraction
- vite