The Validation Module is the semantic checking engine of the AI-Based Viva System (SN Bose Summer Internship, NIT Silchar). It receives a student's transcribed spoken answer, verifies it is a genuine attempt (not silence, stuttering, ASR noise, or gibberish), and scores it against the examiner's reference answer using transformer embeddings, zero-shot NLI classification, and fuzzy concept matching.
It has no database — it is a stateless API service. Every request contains everything it needs, and nothing is stored. (The small built-in "RAG knowledge base" is an in-memory Python list used only as a fallback when no reference answer is sent.)
Question Bank Module ──(question + expected answer)──┐
▼
Speech Module ──(student's transcribed answer)──► VALIDATION MODULE ──► Evaluation Module ──► Result Storage
(this repository)
question and expected_answer (its GET /questions/set/{id}/answers endpoint returns exactly the answer map this module needs).student_answer (plus optional speech_metadata such as ASR confidence).ValidationResponse: valid/invalid, relevance, semantic similarity, completeness, confidence, remarks.No database, no API keys, and no .env file are required to run it.
Open the Terminal app and run these commands one at a time:
# 1. Go into the project folder
cd path/to/Validation-Module_AI-Viva-main
# 2. Create a virtual environment (a private box for this project's packages)
python3.12 -m venv .venv
# 3. Activate it (your prompt will show ".venv" when active)
source .venv/bin/activate
# 4. Install all dependencies (takes a few minutes — PyTorch is large)
pip install -r requirements.txt
# 5. (Recommended for laptops) use small, fast models:
cp .env.example .env
# 6. Start the server
uvicorn app.main:app --reload --port 8000
Open PowerShell and run:
# 1. Go into the project folder
cd path\to\Validation-Module_AI-Viva-main
# 2. Create a virtual environment
py -3.12 -m venv .venv
# 3. Activate it
.venv\Scripts\Activate.ps1
# If you get a "running scripts is disabled" error, first run:
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# 4. Install all dependencies
pip install -r requirements.txt
# 5. (Recommended for laptops) use small, fast models:
copy .env.example .env
# 6. Start the server
uvicorn app.main:app --reload --port 8000
| Command | Meaning |
|---|---|
cd ... | Change directory — moves your terminal into the project folder |
python3.12 -m venv .venv | Creates an isolated Python environment in a folder named .venv, so this project's packages don't clash with other projects |
source .venv/bin/activate / .venv\Scripts\Activate.ps1 | Switches your terminal to use that environment |
pip install -r requirements.txt | Downloads and installs every library listed in requirements.txt |
cp / copy .env.example .env | Creates your local settings file from the template |
uvicorn app.main:app --reload --port 8000 | Starts the web server: app.main:app = the app object inside app/main.py; --reload restarts automatically when you edit code; --port 8000 = which port to listen on |
The server runs at http://127.0.0.1:8000 — Swagger docs at http://127.0.0.1:8000/docs, ReDoc at /redoc. Stop it with Ctrl+C. Reactivate the venv in any new terminal before running again.
⏳ The first
/validaterequest is slow — the server downloads the NLP models on first use (with the.env.examplesettings: ~180 MB; with the built-in defaults: ~2.9 GB). This happens once; models are cached in~/.cache/huggingfaceafterward. Later requests take well under a second.
.env — optional)Every setting has a working default in app/config/config.py; the .env file only overrides them. See .env.example for the full list. The important ones:
| Variable | Default | Notes |
|---|---|---|
MODEL_NAME | nvidia/llama-nemotron-embed-1b-v2 | English embedding model (~2.3 GB). For laptops use sentence-transformers/all-MiniLM-L6-v2 (~90 MB, verified working) |
MULTILINGUAL_MODEL_NAME | paraphrase-multilingual-MiniLM-L12-v2 | Used for Hindi/Bengali/Tamil (~470 MB) |
CLASSIFICATION_MODEL_NAME | MoritzLaurer/mDeBERTa-v3-base-xnli... | Zero-shot NLI validity check (~560 MB); small alternative: cross-encoder/nli-MiniLM2-L6-H768 |
QA_MODEL_NAME / FEEDBACK_MODEL_NAME / TRANSLATION_MODEL_NAME | 8 GB / 30 GB / 1 GB models | Only loaded if a request explicitly asks via speech_metadata flags (use_local_llm, generate_feedback, translate_input). Do not enable on a laptop. |
GEMINI_API_KEY | empty | Only needed if a request sends "use_llm": true |
PORT / HOST / DEBUG / APP_ENV | 8000 / 0.0.0.0 / True / dev | Server basics |
GET / — service infoReturns app name, environment, and docs URL. Quick "is it up?" check.
GET /health — health checkReturns status, the configured embedding model, and score thresholds.
POST /api/v1/validate — the main endpointRequest body:
{
"question": "What is an operating system and what does it do?",
"expected_answer": "An operating system is software that acts as an interface between computer hardware and the user. It manages files, memory, processes, and input and output devices.",
"student_answer": "An operating system is system software that manages hardware and software resources and acts as a bridge between the user and the hardware.",
"language": "English",
"speech_metadata": {}
}
question (required, ≥5 chars) — the viva question.expected_answer (optional) — the reference answer from the Question Bank Module. If omitted, the module retrieves the closest match from its built-in RAG knowledge base.student_answer (required) — the transcript from the Speech Module.language (default "English") — selects the embedding model (English vs multilingual).speech_metadata (optional) — flags: use_llm (Gemini), use_local_llm (local 8B QA model), generate_feedback (local 30B feedback model), translate_input (Indic→English translation), plus any ASR metadata.Verified real response:
{
"validation_status": "Valid",
"relevance_score": 0.93,
"semantic_similarity": 0.95,
"completeness": "Complete",
"confidence": 0.92,
"remarks": "Answer is relevant and semantically correct. Concept coverage: 66%."
}
And for a gibberish/stutter transcript ("uh um zzzzzz aaaa"):
{
"validation_status": "Invalid",
"relevance_score": 0.0,
"semantic_similarity": 0.0,
"completeness": "Irrelevant",
"confidence": 0.1,
"remarks": "Invalid response attempt. Gibberish or repeating characters detected in word: 'zzzzzz'"
}
Open http://127.0.0.1:8000/docs → expand POST /api/v1/validate → Try it out → edit the example JSON → Execute.
curl -X POST http://127.0.0.1:8000/api/v1/validate \
-H "Content-Type: application/json" \
-d '{"question":"What is RAM?","expected_answer":"Random Access Memory","student_answer":"RAM stands for random access memory","language":"English"}'
(Windows PowerShell: use curl.exe instead of curl, or use Postman — POST to the URL with the JSON as Body → raw → JSON.)
python -m pytest tests/test_text_processor.py tests/test_api.py tests/test_validation_service.py -v
⚠️ Do not run the full suite (
pytest) blindly:tests/test_model_features.pyexercises the optional QA, feedback, and translation models, which will try to download tens of gigabytes. Run the three files above instead.
Validation-Module_AI-Viva-main/
├── app/
│ ├── main.py # FastAPI app, CORS, global error handlers, / and /health
│ ├── api/v1/validation.py # POST /api/v1/validate route
│ ├── schemas/validation.py # Request/response models (ValidationRequest/Response)
│ ├── services/
│ │ ├── validation_service.py # Core engine: model loading, embeddings, NLI, scoring
│ │ └── rag_service.py # In-memory fallback knowledge base of reference answers
│ ├── utils/
│ │ ├── text_processor.py # Cleaning, filler removal, concept extraction, quality gate
│ │ └── exceptions.py # Domain exceptions → clean JSON error responses
│ └── config/config.py # Settings (.env) + logging
├── tests/ # pytest suite
├── requirements.txt
├── .env.example
└── README.md
The complete path from a fresh clone to a tested API, assuming the Question Bank Module already runs on PostgreSQL at port 8000.
Step 1 — Get the code and enter the folder
git clone <your-repo-url>
cd Validation-Module_AI-Viva-main
Step 2 — Create and activate a virtual environment
# macOS: # Windows PowerShell:
python3.12 -m venv .venv # py -3.12 -m venv .venv
source .venv/bin/activate # .venv\Scripts\Activate.ps1
You know it worked when (.venv) appears at the start of your prompt.
Step 3 — Install dependencies (a few minutes; PyTorch is big)
pip install -r requirements.txt
Step 4 — Create your settings file
cp .env.example .env # Windows: copy .env.example .env
No database settings are needed — this module has no database.
Step 5 — Start the server on port 8001 (8000 is taken by the Question Bank Module)
uvicorn app.main:app --reload --port 8001
Leave this terminal open; the server stops if you close it (or press Ctrl+C).
Step 6 — Smoke-test in a browser
Open http://127.0.0.1:8001/health — you should see "status": "healthy".
Step 7 — Test a real validation in Swagger
Open http://127.0.0.1:8001/docs → POST /api/v1/validate → Try it out → Execute with the example body. The first call downloads the NLP models (one time, be patient); after that responses are fast.
Step 8 — Test the full pipeline with the Question Bank Module
In a second terminal, log in to the Question Bank API, fetch a question set's answers (GET /questions/set/{id}/answers on port 8000), then send one question + answer_text + a made-up student answer to POST /api/v1/validate on port 8001. A relevant student answer should come back Valid.
ModuleNotFoundError: requests / rapidfuzz — you have an old requirements.txt; the current one includes them. Run pip install -r requirements.txt again..env from .env.example to use the small verified models.--port 8001.zsh: command not found: uvicorn — the venv isn't activated; run the activate command first.1 commits
1 commits
Python
100.0%
The Validation Module is the semantic checking engine of the AI-Based Viva System (SN Bose Summer Internship, NIT Silchar). It receives a student's transcribed spoken answer, verifies it is a genuine attempt (not silence, stuttering, ASR noise, or gibberish), and scores it against the examiner's reference answer using transformer embeddings, zero-shot NLI classification, and fuzzy concept matching.
It has no database — it is a stateless API service. Every request contains everything it needs, and nothing is stored. (The small built-in "RAG knowledge base" is an in-memory Python list used only as a fallback when no reference answer is sent.)
Question Bank Module ──(question + expected answer)──┐
▼
Speech Module ──(student's transcribed answer)──► VALIDATION MODULE ──► Evaluation Module ──► Result Storage
(this repository)
question and expected_answer (its GET /questions/set/{id}/answers endpoint returns exactly the answer map this module needs).student_answer (plus optional speech_metadata such as ASR confidence).ValidationResponse: valid/invalid, relevance, semantic similarity, completeness, confidence, remarks.No database, no API keys, and no .env file are required to run it.
Open the Terminal app and run these commands one at a time:
# 1. Go into the project folder
cd path/to/Validation-Module_AI-Viva-main
# 2. Create a virtual environment (a private box for this project's packages)
python3.12 -m venv .venv
# 3. Activate it (your prompt will show ".venv" when active)
source .venv/bin/activate
# 4. Install all dependencies (takes a few minutes — PyTorch is large)
pip install -r requirements.txt
# 5. (Recommended for laptops) use small, fast models:
cp .env.example .env
# 6. Start the server
uvicorn app.main:app --reload --port 8000
Open PowerShell and run:
# 1. Go into the project folder
cd path\to\Validation-Module_AI-Viva-main
# 2. Create a virtual environment
py -3.12 -m venv .venv
# 3. Activate it
.venv\Scripts\Activate.ps1
# If you get a "running scripts is disabled" error, first run:
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# 4. Install all dependencies
pip install -r requirements.txt
# 5. (Recommended for laptops) use small, fast models:
copy .env.example .env
# 6. Start the server
uvicorn app.main:app --reload --port 8000
| Command | Meaning |
|---|---|
cd ... | Change directory — moves your terminal into the project folder |
python3.12 -m venv .venv | Creates an isolated Python environment in a folder named .venv, so this project's packages don't clash with other projects |
source .venv/bin/activate / .venv\Scripts\Activate.ps1 | Switches your terminal to use that environment |
pip install -r requirements.txt | Downloads and installs every library listed in requirements.txt |
cp / copy .env.example .env | Creates your local settings file from the template |
uvicorn app.main:app --reload --port 8000 | Starts the web server: app.main:app = the app object inside app/main.py; --reload restarts automatically when you edit code; --port 8000 = which port to listen on |
The server runs at http://127.0.0.1:8000 — Swagger docs at http://127.0.0.1:8000/docs, ReDoc at /redoc. Stop it with Ctrl+C. Reactivate the venv in any new terminal before running again.
⏳ The first
/validaterequest is slow — the server downloads the NLP models on first use (with the.env.examplesettings: ~180 MB; with the built-in defaults: ~2.9 GB). This happens once; models are cached in~/.cache/huggingfaceafterward. Later requests take well under a second.
.env — optional)Every setting has a working default in app/config/config.py; the .env file only overrides them. See .env.example for the full list. The important ones:
| Variable | Default | Notes |
|---|---|---|
MODEL_NAME | nvidia/llama-nemotron-embed-1b-v2 | English embedding model (~2.3 GB). For laptops use sentence-transformers/all-MiniLM-L6-v2 (~90 MB, verified working) |
MULTILINGUAL_MODEL_NAME | paraphrase-multilingual-MiniLM-L12-v2 | Used for Hindi/Bengali/Tamil (~470 MB) |
CLASSIFICATION_MODEL_NAME | MoritzLaurer/mDeBERTa-v3-base-xnli... | Zero-shot NLI validity check (~560 MB); small alternative: cross-encoder/nli-MiniLM2-L6-H768 |
QA_MODEL_NAME / FEEDBACK_MODEL_NAME / TRANSLATION_MODEL_NAME | 8 GB / 30 GB / 1 GB models | Only loaded if a request explicitly asks via speech_metadata flags (use_local_llm, generate_feedback, translate_input). Do not enable on a laptop. |
GEMINI_API_KEY | empty | Only needed if a request sends "use_llm": true |
PORT / HOST / DEBUG / APP_ENV | 8000 / 0.0.0.0 / True / dev | Server basics |
GET / — service infoReturns app name, environment, and docs URL. Quick "is it up?" check.
GET /health — health checkReturns status, the configured embedding model, and score thresholds.
POST /api/v1/validate — the main endpointRequest body:
{
"question": "What is an operating system and what does it do?",
"expected_answer": "An operating system is software that acts as an interface between computer hardware and the user. It manages files, memory, processes, and input and output devices.",
"student_answer": "An operating system is system software that manages hardware and software resources and acts as a bridge between the user and the hardware.",
"language": "English",
"speech_metadata": {}
}
question (required, ≥5 chars) — the viva question.expected_answer (optional) — the reference answer from the Question Bank Module. If omitted, the module retrieves the closest match from its built-in RAG knowledge base.student_answer (required) — the transcript from the Speech Module.language (default "English") — selects the embedding model (English vs multilingual).speech_metadata (optional) — flags: use_llm (Gemini), use_local_llm (local 8B QA model), generate_feedback (local 30B feedback model), translate_input (Indic→English translation), plus any ASR metadata.Verified real response:
{
"validation_status": "Valid",
"relevance_score": 0.93,
"semantic_similarity": 0.95,
"completeness": "Complete",
"confidence": 0.92,
"remarks": "Answer is relevant and semantically correct. Concept coverage: 66%."
}
And for a gibberish/stutter transcript ("uh um zzzzzz aaaa"):
{
"validation_status": "Invalid",
"relevance_score": 0.0,
"semantic_similarity": 0.0,
"completeness": "Irrelevant",
"confidence": 0.1,
"remarks": "Invalid response attempt. Gibberish or repeating characters detected in word: 'zzzzzz'"
}
Open http://127.0.0.1:8000/docs → expand POST /api/v1/validate → Try it out → edit the example JSON → Execute.
curl -X POST http://127.0.0.1:8000/api/v1/validate \
-H "Content-Type: application/json" \
-d '{"question":"What is RAM?","expected_answer":"Random Access Memory","student_answer":"RAM stands for random access memory","language":"English"}'
(Windows PowerShell: use curl.exe instead of curl, or use Postman — POST to the URL with the JSON as Body → raw → JSON.)
python -m pytest tests/test_text_processor.py tests/test_api.py tests/test_validation_service.py -v
⚠️ Do not run the full suite (
pytest) blindly:tests/test_model_features.pyexercises the optional QA, feedback, and translation models, which will try to download tens of gigabytes. Run the three files above instead.
Validation-Module_AI-Viva-main/
├── app/
│ ├── main.py # FastAPI app, CORS, global error handlers, / and /health
│ ├── api/v1/validation.py # POST /api/v1/validate route
│ ├── schemas/validation.py # Request/response models (ValidationRequest/Response)
│ ├── services/
│ │ ├── validation_service.py # Core engine: model loading, embeddings, NLI, scoring
│ │ └── rag_service.py # In-memory fallback knowledge base of reference answers
│ ├── utils/
│ │ ├── text_processor.py # Cleaning, filler removal, concept extraction, quality gate
│ │ └── exceptions.py # Domain exceptions → clean JSON error responses
│ └── config/config.py # Settings (.env) + logging
├── tests/ # pytest suite
├── requirements.txt
├── .env.example
└── README.md
The complete path from a fresh clone to a tested API, assuming the Question Bank Module already runs on PostgreSQL at port 8000.
Step 1 — Get the code and enter the folder
git clone <your-repo-url>
cd Validation-Module_AI-Viva-main
Step 2 — Create and activate a virtual environment
# macOS: # Windows PowerShell:
python3.12 -m venv .venv # py -3.12 -m venv .venv
source .venv/bin/activate # .venv\Scripts\Activate.ps1
You know it worked when (.venv) appears at the start of your prompt.
Step 3 — Install dependencies (a few minutes; PyTorch is big)
pip install -r requirements.txt
Step 4 — Create your settings file
cp .env.example .env # Windows: copy .env.example .env
No database settings are needed — this module has no database.
Step 5 — Start the server on port 8001 (8000 is taken by the Question Bank Module)
uvicorn app.main:app --reload --port 8001
Leave this terminal open; the server stops if you close it (or press Ctrl+C).
Step 6 — Smoke-test in a browser
Open http://127.0.0.1:8001/health — you should see "status": "healthy".
Step 7 — Test a real validation in Swagger
Open http://127.0.0.1:8001/docs → POST /api/v1/validate → Try it out → Execute with the example body. The first call downloads the NLP models (one time, be patient); after that responses are fast.
Step 8 — Test the full pipeline with the Question Bank Module
In a second terminal, log in to the Question Bank API, fetch a question set's answers (GET /questions/set/{id}/answers on port 8000), then send one question + answer_text + a made-up student answer to POST /api/v1/validate on port 8001. A relevant student answer should come back Valid.
ModuleNotFoundError: requests / rapidfuzz — you have an old requirements.txt; the current one includes them. Run pip install -r requirements.txt again..env from .env.example to use the small verified models.--port 8001.zsh: command not found: uvicorn — the venv isn't activated; run the activate command first.1 commits
1 commits
Python
100.0%