Logo Lanfrica

RaniaKeghouche/nhsm-chatbot

Domaine:

natural language processing

Type de record:

software
Créateur:
Ran
Hôte:
RAG chatbot for the NHSM school. Node.js, Express and MongoDB, with Llama 3.1 via Groq. Answers in English, French and Algerian Darija. # NHSM Helper A chatbot for the NHSM school. Students ask questions in English, French, Arabic or Algerian Darija and get answers grounded in real school information. **Live demo:** nhsm-helper.netlify.app ## How it works Every question goes through a retrieval augmented generation (RAG) pipeline: | # | Stage | Where | What it does | |---|-------|-------|--------------| | 0 | **Greeting shortcut** | `chatController.isGreeting()` | "hi", "merci", "salam" → instant reply, no LLM and no database call | | 1 | **Conversational condensation** | `aiService.condenseConversationalQuery()` | "and for SESA?" becomes "What is the SESA specialty?" using the chat history | | 2 | **Query rewriting** | `aiService.rewriteQueryForSearch()` | Expands the question into English + French keywords for lexical search | | 3a | **Vector search** | `knowledgeBaseService._vectorSearch()` | In-memory cosine similarity over 324 embeddings and their paraphrases | | 3b | **Keyword search** | `knowledgeBaseService._keywordSearch()` | MongoDB regex with singular/plural variants | | 4 | **RRF fusion** | `_reciprocalRankFusion()` | Merges both rankings by *rank*, so the two score scales never have to be reconciled | | 5 | **Reranking** | `rerankService.rerank()` | Cohere cross-encoder; skipped when its top score is below 0.05, where it carries no signal | | 6 | **Generation** | `aiService.generateResponseStream()` | Groq, streamed, in the detected language | This keeps answers grounded in the school's actual information instead of whatever the model happens to guess. When retrieval comes back empty, the model is explicitly instructed to say so rather than fill the gap. ### Multi-query paraphrase indexing On top of its main embedding, every document stores **5 embedded paraphrases** (2 French, 2 English, 1 Darija) generated by Llama. At search time the score is the **maximum** similarity across those 6 vectors, so one answer becomes reachable through every way a student might phrase the …