Download README.md from Estarcode/campusdesk-ai: direct link, hf CLI and curl.
- Browser
- Download file 9.76 kB
-
https://huggingface.co/Estarcode/campusdesk-ai/resolve/main/README.md
- Command line
-
hf download hf://Estarcode/campusdesk-ai/README.md
-
curl -L -o README.md https://huggingface.co/Estarcode/campusdesk-ai/resolve/main/README.md
language:
- en
- pcm
license: mit
tags:
- rag
- retrieval-augmented-generation
- intent-classification
- nigerian-pidgin
- multilingual
- gradio
- bursary
- afro-xlmr
CampusDesk AI β Bilingual & Voice Campus Bursary Helpdesk (ZIT)
CampusDesk AI is an end-to-end bilingual (English & Nigerian Pidgin), voice-enabled Retrieval-Augmented Generation (RAG) assistant built for the fictional Zaria Institute of Technology (ZIT) Student Bursary & Welfare Office. It combines intent classification (TF-IDF + LogisticRegression vs. fine-tuned Davlan/afro-xlmr-small), hybrid dense + lexical passage retrieval with sub-query fusion, deterministic amendment resolution (N02 -> N01, N04 -> N03), citation validation, and local Whisper speech transcription in a Gradio web application.
Architecture Overview
User Query (Text or Voice Audio via Whisper ASR -> Editable Transcript Box)
β
βΌ
[1. Query Planner] src/pipeline/query_planner.py
β ββ Bilingual cue detection (English / Nigerian Pidgin)
β ββ Multi-part clause splitter (full query + sub-queries)
βΌ
[2. Intent Classifier] src/classification/classifier.py
β ββ Baseline: TF-IDF (char_wb, C=2.0) + LogisticRegression
β ββ Encoder: Fine-tuned Davlan/afro-xlmr-small (4 intents)
βΌ
[3. Hybrid Retriever] src/retrieval/retriever.py
β ββ Dense: intfloat/multilingual-e5-small (cosine over passage_embeddings.npz)
β ββ Lexical: BM25Okapi (bm25_corpus.json)
β ββ Rerank: 0.62*dense + 0.38*BM25 + 0.08*intent_bonus (max-pooled sub-queries, top-3)
βΌ
[4. Amendment Resolver] src/amendments/resolver.py
β ββ Isolates latest dated amendments (N02->N01 deadline, N04->N03 CGPA) without clobbering unamended rules
βΌ
[5. Grounded Generator] src/generation/answer_generator.py
β ββ Qwen2.5-1.5B-Instruct (CPU) / Qwen2.5-3B-Instruct (CUDA) -> JSON {answer, next_steps, missing_information, cited_passage_ids}
βΌ
[6. Citation Validator] src/grounding/citation_validator.py
ββ Strips hallucinated passage IDs, syncs inline [PASSAGE_ID] tags, suppresses ungrounded next_steps
Directory Structure
capstone/
βββ data/
β βββ raw/pdf/ # 8 synthetic ZIT bursary PDF notices (N01βN08)
β βββ raw/csv/ # bursary_fees_and_tiers.csv (N09)
β βββ processed/passages.jsonl # 17 deterministic section/row passages (N01-P01 .. N09-R06)
β βββ manifests/source_manifest.csv
β βββ intent_dataset.csv # 136 bilingual requests across 64 families (88 train / 24 val / 24 test)
βββ notebooks/ # Reproducible experiment notebooks (run 01 -> 04)
β βββ 01_dataset_preparation.ipynb
β βββ 02_baseline_training.ipynb
β βββ 03_encoder_finetuning.ipynb
β βββ 04_model_evaluation.ipynb
βββ artifacts/
β βββ baseline/tfidf_baseline.joblib
β βββ fine_tuned/ # Saved Davlan/afro-xlmr-small checkpoint + tokenizer
β βββ label_map.json
β βββ classifier_comparison.json
βββ indexes/
β βββ passage_embeddings.npz # Multilingual-E5 embeddings
β βββ bm25_corpus.json # BM25 tokenized index
βββ src/
β βββ config.py # Central paths & pinned model IDs
β βββ schemas.py # Pydantic contracts across pipeline stages
β βββ classification/ # classifier.py, model_loader.py
β βββ document_processing/ # extractors.py, chunker.py, index_builder.py
β βββ retrieval/ # bm25.py, semantic.py, reranker.py, retriever.py
β βββ amendments/ # resolver.py
β βββ generation/ # answer_generator.py
β βββ speech/ # transcription.py (Whisper ASR + silence/error fallback)
β βββ grounding/ # citation_validator.py
β βββ pipeline/ # query_planner.py, orchestrator.py
β βββ evaluation/ # metrics.py
βββ evaluation/
β βββ gold_answers.json # 12 held-out bilingual evaluation pairs (24 prompts)
β βββ test_scenarios.csv
β βββ actual_outputs/e2e_results.jsonl
β βββ retest_outputs/retest_results.jsonl
β βββ voice_records/ # 4 synthetic spoken Nigerian-accented WAVs + voice_4_records.json
β βββ failure_traces.md
β βββ recompute_metrics.py
βββ tests/ # Unit & integration tests (pytest)
βββ scripts/ # Corpus, dataset, training, index, voice, and eval CLI runners
βββ report/technical_report.pdf # 2β4 page technical report
βββ app.py # Gradio web UI
βββ requirements.txt
Quick Start
1. Environment Setup (Windows PowerShell)
python -m venv .venv
.venv\Scripts\pip.exe install -r requirements.txt
Copy-Item .env.example .env
2. Full Pipeline Rebuild (Corpus -> Classifiers -> Index -> App)
.venv\Scripts\python.exe -m scripts.build_corpus
.venv\Scripts\python.exe -m scripts.build_intent_dataset
.venv\Scripts\python.exe -m scripts.train_classifiers
.venv\Scripts\python.exe -m scripts.build_index
.venv\Scripts\python.exe app.py
Open the local Gradio URL shown in the terminal (typically http://127.0.0.1:7860).
3. Rebuilding Indexes After Corpus Edits
.venv\Scripts\python.exe -m scripts.build_index
This regenerates indexes/passage_embeddings.npz and indexes/bm25_corpus.json from data/processed/passages.jsonl.
4. Notebook Execution Order
Run the notebooks sequentially inside notebooks/:
01_dataset_preparation.ipynbβ corpus hygiene, family-grouped split verification, dataset audit02_baseline_training.ipynbβ TF-IDF + LogisticRegression tuning on validation set03_encoder_finetuning.ipynbβDavlan/afro-xlmr-smallfine-tuning & checkpoint reload verification04_model_evaluation.ipynbβ held-out bilingual test metrics & failure inspection
5. Loading the Saved Fine-Tuned Checkpoint Programmatically
from src.classification.classifier import EncoderIntentClassifier
clf = EncoderIntentClassifier() # loads artifacts/fine_tuned/ and artifacts/label_map.json
pred = clf.predict("I fit still apply on 12 June 2026? Which papers I need carry?")
print(pred.label, pred.confidence, pred.probabilities)
Evaluation & Tests
Intent Classification Results (artifacts/classifier_comparison.json)
Dataset: 136 requests across 64 families (88 train / 24 val / 24 test, zero family overlap across splits, balanced 4 intents x 6 test examples).
| Model | Settings | Val Macro-F1 | Test Macro-F1 | Latency / Query | Confused Test Cases |
|---|---|---|---|---|---|
| TF-IDF + LogisticRegression (Baseline) | char_wb, C=2.0 |
0.8325 |
0.9143 |
0.096 ms |
2 (REQ-031, REQ-032) |
Fine-Tuned Davlan/afro-xlmr-small |
lr=5e-5, 8 epochs, seed=42 |
1.0000 |
1.0000 |
55.436 ms |
0 |
End-to-End Bilingual Evaluation (24 Held-Out Prompts)
| Run (Artifact Path) | Evidence Recall@3 | Non-Empty Citations | Supported Answers | Handling Unknowns | Cross-Language Consistency |
|---|---|---|---|---|---|
Baseline (Qwen2.5-0.5B-Instruct) (evaluation/actual_outputs/e2e_results.jsonl) |
1.0000 (20/20) |
7/24 (29.2%) |
4/20 (20.0%) |
1/8 (12.5%) |
1/12 (8.3%) |
Post-Fix Retest (Qwen2.5-1.5B-Instruct) (evaluation/retest_outputs/retest_results.jsonl) |
1.0000 (20/20) |
20/24 (83.3%) |
8/20 (40.0%) |
1/8 (12.5%) |
3/12 (25.0%) |
Running Tests, Recomputing Metrics & Rebuilding Report
.venv\Scripts\pytest.exe -v
.venv\Scripts\python.exe -m evaluation.recompute_metrics --input evaluation\actual_outputs\e2e_results.jsonl
.venv\Scripts\python.exe -m evaluation.recompute_metrics --input evaluation\retest_outputs\retest_results.jsonl
.venv\Scripts\python.exe -m scripts.build_report
Sample Bilingual Test Queries
- English (Two-Source + Amendment):
"Can I still apply on 12 June 2026, and which documents must every standard applicant attach?" - Nigerian Pidgin (Two-Source + Amendment):
"I fit still apply on 12 June 2026? Which papers every normal applicant gats attach?" - English (Eligibility Amendment):
"I am a full-time 300-level Engineering student with a 2.35 CGPA and no external scholarship. Am I eligible to apply?" - Nigerian Pidgin (Fee + Document Cross-Format):
"If my ZIT Student ID card don loss before I apply, wetin I go do and how much I go pay for replacement, and which other compulsory papers I need?"
Privacy & Safe-Testing Policy
- Voice Audio Privacy (
delete_after=True): Uploaded or recorded voice audio is transcribed locally viaopenai/whisper-smallinto an editable text box (so students can verify dates, numbers, and Pidgin negation before retrieval) and the temporary audio file is deleted immediately after transcription (src/speech/transcription.py, verified bytest_speech_privacy_deletes_temp_audio_and_handles_silence). - No Disk Persistence of Live Queries: Live user queries and transcripts stay strictly in memory during the active Gradio session.
- Zero Real PII: All notices, fee schedules, and voice fixtures (
evaluation/voice_records/, generated via Nigerian-accented neural TTS) use fictional Zaria Institute of Technology (ZIT) data.