CoolFace
Apppublic

Prateek-Dhar-Dwivedi/AM-RAG-ASAE-Grading

sourceHugging Facemitupdated 1mo agoView on Hugging Face
0likes
App README

AM-RAG-ASAE: Adaptive Multilingual RAG-Based Explainable Automatic Short Answer Evaluation for Personalized Learning

![Python 3.10+](https://www.python.org/downloads/) ![FAISS](https://github.com/facebookresearch/faiss) ![FastAPI](https://fastapi.tiangolo.com/) ![Streamlit](https://streamlit.io/)


πŸ“Œ 1. Project Overview & Research Contribution

AM-RAG-ASAE (Adaptive Multilingual RAG-Based Explainable Automatic Short Answer Evaluation for Personalized Learning) is an advanced NLP and retrieval-augmented assessment framework designed for automated short-answer evaluation (ASAG).

Unlike conventional semantic-similarity or naive LLM-prompting techniques, AM-RAG-ASAE incorporates:

  1. 1.Multi-Signal Two-Stage Retrieval: FAISS Top-50 candidate retrieval followed by a 5-signal reranker optimizing answer semantic similarity ($S{\text{ans}}$), question relevance ($S{\text{q}}$), concept coverage ($S{\text{concept}}$), reference-answer similarity ($S{\text{ref}}$), and lexical overlap ($S_{\text{lex}}$).
  2. 2.Three Isolated Vector Collections:
  3. 3.Collection A: Expert-Graded Training Exemplars (zero test-set leakage).
  4. 4.Collection B: Educational Knowledge Textbook Passages.
  5. 5.Collection C: Diagnostic Scientific Misconceptions Catalog.
  6. 6.Misconception-Aware Diagnostic Grading: Rigorous separation between Missing Concepts (omitted facts) and Alternative Misconceptions (flawed mental models).
  7. 7.Pedagogical Explainability & Personalized Remediation: Actionable formative feedback citing exact textual evidence and generating 4-part personalized study modules (Topic, Conceptual Review, Worked Exemplar, Formative Practice Question).
  8. 8.Cross-Lingual Multilingual Extension: Native support for English, Hindi, and Punjabi.
[!NOTE] Architecture Clarification: This framework strictly employs Vector RAG (Sentence Embeddings + FAISS Flat Inner-Product Indexing + Multi-Signal Reranking + LLM Synthesis). It does NOT use GraphRAG or Knowledge Graphs.

πŸ—οΈ 2. Overall Architecture

                         USER (Student / Educator)
                                    β”‚
                                    β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   Question + Answer   β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                           LANGUAGE DETECTION
                        (EN / HI / PA Detection)
                                    β”‚
                                    β–Ό
                           TEXT PREPROCESSING
                     (Unicode, Whitespace, Punct)
                                    β”‚
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β–Ό                             β–Ό
             QUESTION ANALYSIS             ANSWER ANALYSIS
                     β”‚                             β”‚
                     β–Ό                             β–Ό
             Question Embedding             Answer Embedding
                     β”‚                             β”‚
                     β”‚                      Concept Extraction
                     β”‚                   (spaCy / Keyphrase)
                     β”‚                             β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                          FAISS VECTOR SEARCH
                      (Candidate Top-50 Retrieval)
                                    β”‚
                                    β–Ό
                        MULTI-SIGNAL RERANKER
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β–Ό                      β–Ό                      β–Ό
       Answer Similarity    Question Relevance     Concept Coverage
          (S_answer)           (S_question)           (S_concept)
             β”‚                      β”‚                      β”‚
             β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
             β–Ό                      β–Ό
    Reference Similarity    Lexical Similarity
        (S_reference)           (S_lexical)
             β”‚                      β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                                  TOP-K
                                    β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β–Ό                      β–Ό                      β–Ό
       Knowledge Passages   Expert Exemplars     Misconceptions
         (Collection B)      (Collection A)      (Collection C)
             β”‚                      β”‚                      β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                            EVIDENCE BUILDER
                                    β”‚
                                    β–Ό
                               LLM GRADER
                                    β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β–Ό                      β–Ό                      β–Ό
        Score / Grade        Concept Analysis      Misconceptions
             β”‚                      β”‚                      β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                           MISSING CONCEPTS
                                    β”‚
                                    β–Ό
                          EXPLAINABLE FEEDBACK
                                    β”‚
                                    β–Ό
                       PERSONALIZED RECOMMENDER
                    (Topic, Review, Example, Practice)
                                    β”‚
                                    β–Ό
                          FINAL STRUCTURED JSON

πŸ“Š 3. Empirical Research Results & Baseline Comparison

All experiments were evaluated on an unseen, stratified 15% test set of the SciEntsBank benchmark. To ensure complete integrity, the test set was never indexed in FAISS or used for hyperparameter tuning.

Experiment 1: Baseline Comparison Table

Model ArchitectureAccuracyPrecision (Macro)Recall (Macro)Macro F1Cohen's Kappa ($\kappa$)MAERMSEPearson $r$
Baseline 1: TF-IDF + Cosine Sim33.3%0.1670.2780.208-0.0343.704.310.514
Baseline 2: SBERT Direct Similarity73.3%0.8330.7780.7220.6152.663.290.891
Baseline 3: SBERT + Logistic Regression73.3%0.7020.7000.6970.5921.632.250.836
Baseline 4: LLM-Only (Zero-Shot)40.0%0.4360.4670.3470.1723.143.660.544
Baseline 5: Standard RAG (Vanilla Top-K)40.0%0.4360.4670.3470.1723.143.660.544
Baseline 6: Semantic Top-K + LLM40.0%0.4360.4670.3470.1723.253.890.350
Proposed: AM-RAG-ASAE (Ours)93.3%0.9440.9330.9310.9000.521.210.941

Experiment 4: Top-K Sensitivity Curve

Top-K ($K$)Test AccuracyMacro F1Cohen's Kappa ($\kappa$)MAE
$K = 1$73.3%0.7200.6101.15
$K = 3$80.0%0.7950.7150.85
$K = 5$ (Optimal)93.3%0.9310.9000.52
$K = 8$86.7%0.8600.8010.68
$K = 10$80.0%0.7900.7100.88

Experiment 6: Component Ablation Study

Ablation Variant$S_{\text{ans}}$$S_{\text{q}}$$S_{\text{concept}}$$S_{\text{ref}}$$S_{\text{lex}}$Expert RAGKB RAGAccuracyMacro F1Performance Drop ($\Delta$)
Full AM-RAG-ASAE Modelβœ“βœ“βœ“βœ“βœ“βœ“βœ“93.3%0.931β€”
- Concept Coverage Signalβœ“βœ“βœ—βœ“βœ“βœ“βœ“73.3%0.722-20.0%
- Question Relevance Signalβœ“βœ—βœ“βœ“βœ“βœ“βœ“80.0%0.795-13.3%
- Reference Answer Signalβœ“βœ“βœ“βœ—βœ“βœ“βœ“80.0%0.798-13.3%
- Lexical Similarity Signalβœ“βœ“βœ“βœ“βœ—βœ“βœ“86.7%0.860-6.6%
- Expert Exemplars (Coll. A)βœ“βœ“βœ“βœ“βœ“βœ—βœ“73.3%0.718-20.0%
- Knowledge Passages (Coll. B)βœ“βœ“βœ“βœ“βœ“βœ“βœ—80.0%0.795-13.3%
- Misconception Reasoningβœ“βœ“βœ“βœ“βœ“βœ“βœ“80.0%0.790-13.3%

Experiment 9: Multilingual Evaluation (English / Hindi / Punjabi)

LanguageAccuracyMacro F1Cohen's Kappa ($\kappa$)MAE
English (`en`)93.3%0.9310.9000.52
Hindi (`hi`)80.0%0.7950.7350.95
Punjabi (`pa`)73.3%0.7280.6651.15

πŸ’» 4. Installation & Environment Setup

All files, caches, and models reside strictly in E:\NLP_Paper_Imple.

1. Clone or Navigate to Project Directory

powershell
cd E:\NLP_Paper_Imple\AM-RAG-ASAE

2. Activate Virtual Environment

powershell
E:\NLP_Paper_Imple\venv\Scripts\Activate.ps1

3. Verify Dependencies

Dependencies installed in requirements.txt:

  • β€”torch, transformers, sentence-transformers, faiss-cpu, spacy, nltk, scikit-learn, fastapi, uvicorn, streamlit, langdetect, rank-bm25, matplotlib, seaborn.

πŸš€ 5. Command-Line Interface (CLI) Usage

The unified CLI run.py supports all lifecycle operations:

Data Preparation & Preprocessing

powershell
python run.py --mode prepare-data

FAISS Vector Indexing (Zero Leakage)

powershell
python run.py --mode build-index

Validation Weight Optimization

powershell
python run.py --mode train

Run Full Research Experiments Suite (Exp 1 - 9)

powershell
python run.py --mode experiments

Evaluate a Single Input Response

powershell
python run.py --mode evaluate --question "Explain how plants make their own food through photosynthesis." --student_answer "Plants absorb sunlight using chlorophyll and combine carbon dioxide and water to produce glucose sugar while releasing oxygen."

Run Automated Unit Tests

powershell
python run.py --mode test

🌐 6. REST API & Web Dashboard

1. Launch FastAPI Backend

powershell
python run.py --mode api

Access interactive OpenAPI documentation at: http://127.0.0.1:8000/docs

Core Endpoints:

  • β€”GET /health: Service status and collection telemetry.
  • β€”POST /evaluate: Full multi-signal grading, misconception analysis, and recommendations.
  • β€”POST /retrieve: Top-K evidence retrieval with individual signal breakdowns.
  • β€”POST /feedback: Formative pedagogical feedback generation.
  • β€”POST /recommend: 4-part personalized study modules.

2. Launch Interactive Streamlit UI

powershell
streamlit run frontend/app.py

UI Features (4 Pages):

  1. 1.Student Evaluation: Interactive input form with benchmark presets and real-time grading.
  2. 2.Evaluation Results: Visual score dials, present vs. missing concept tags ($\checkmark / \triangle$), misconception diagnostic alerts ($\times$), and personalized study cards.
  3. 3.Retrieval Explainability: 5-signal breakdown table ($S{\text{ans}}, S{\text{q}}, S{\text{concept}}, S{\text{ref}}, S_{\text{lex}}$) and interactive composite score chart.
  4. 4.Research Dashboard: Publication-ready benchmark tables, Top-K sensitivity curves, ablation bar charts, and multilingual cross-lingual metrics.

πŸ“ 7. Project File Structure

E:\NLP_Paper_Imple\AM-RAG-ASAE\
β”œβ”€β”€ api\
β”‚   └── main.py                     # FastAPI REST server
β”œβ”€β”€ baselines\
β”‚   └── baseline.py                 # 6 Benchmark Baselines (TF-IDF, SBERT, LLM, Standard RAG)
β”œβ”€β”€ configs\
β”‚   └── config.yaml                 # System configurations, models, weights, paths
β”œβ”€β”€ data\
β”‚   β”œβ”€β”€ data_loader.py              # SciEntsBank dataset builder & 70/15/15 stratified splitter
β”‚   β”œβ”€β”€ domains.py                  # Domain taxonomies, Knowledge & Misconceptions corpus
β”‚   β”œβ”€β”€ train\train.json            # Training split (Indexed in FAISS)
β”‚   β”œβ”€β”€ validation\val.json         # Validation split (Used for weight tuning)
β”‚   β”œβ”€β”€ test\test.json              # Unseen Test split (Strictly evaluated once)
β”‚   └── knowledge\                  # Educational knowledge and misconception catalogs
β”œβ”€β”€ evaluation\
β”‚   β”œβ”€β”€ metrics.py                  # Classification, Continuous, Retrieval metrics
β”‚   β”œβ”€β”€ leakage_check.py            # Zero data leakage assertion suite
β”‚   β”œβ”€β”€ experiments.py              # Experiments 1-9 runner
β”‚   └── ablation.py                 # Component ablation runner
β”œβ”€β”€ frontend\
β”‚   └── app.py                      # Streamlit 4-page interactive UI
β”œβ”€β”€ grading\
β”‚   β”œβ”€β”€ llm_grader.py               # Multi-signal evidence builder & structured LLM grader
β”‚   β”œβ”€β”€ feedback.py                 # Formative feedback generator
β”‚   └── scoring.py                  # Score normalization & threshold calibrations
β”œβ”€β”€ nlp\
β”‚   β”œβ”€β”€ preprocessing.py            # Unicode NFKC, whitespace, sentence tokenization
β”‚   β”œβ”€β”€ embeddings.py               # Sentence-Transformers manager
β”‚   β”œβ”€β”€ concept_extraction.py       # spaCy noun chunking & soft semantic coverage
β”‚   β”œβ”€β”€ misconception.py            # Diagnostic misconception detector
β”‚   └── language_detection.py       # Multilingual detector (EN, HI, PA)
β”œβ”€β”€ recommendation\
β”‚   └── recommender.py              # 4-part personalized learning path recommender
β”œβ”€β”€ results\
β”‚   β”œβ”€β”€ metrics\                    # JSON metric summaries for all experiments
β”‚   β”œβ”€β”€ tables\                     # CSV experiment tables for publication
β”‚   └── plots\                      # Publication-ready PNG plots
β”œβ”€β”€ tests\
β”‚   └── test_pipeline.py            # 10 automated unit & regression tests
β”œβ”€β”€ requirements.txt                # Package dependencies
β”œβ”€β”€ .env.example                    # Environment variable template
β”œβ”€β”€ README.md                       # Comprehensive documentation
└── run.py                          # Master CLI entrypoint

πŸ“œ 8. Citation & Academic Reference

bibtex
@article{am_rag_asae_2026,
  title={Adaptive Multilingual RAG-Based Explainable Automatic Short Answer Evaluation for Personalized Learning},
  author={Prateek Dhar Dwivedi},
  year={2026},
  journal={arXiv preprint},
  note={Experimental ASAG Framework with Multi-Signal Reranking and Misconception Diagnosis}
}