mcq / additional files /HOW_TO_RUN.md
4deffo's picture
Upload folder using huggingface_hub
b96156b verified
|
Raw
History Blame Contribute Delete
3.3 kB

A newer version of the Gradio SDK is available: 6.22.0

Upgrade

How to Run: Tamil MCQ Generator

This guide explains the directory structure of the project and guides you through running the MCQ generator locally to test the model.

πŸ“‚ Directory Structure

Quiz_MCQ_model/
β”œβ”€β”€ data/                             # Raw corpus and text data files
β”œβ”€β”€ models/                           # Trained machine learning models (.bin fasttext model, Hugging Face models)
β”œβ”€β”€ nlp/                              # Core NLP tools
β”‚   β”œβ”€β”€ ner_tagger.py                 # Hugging Face Named Entity Recognition
β”‚   └── pos_tagger.py                 # Stanza POS Tagging
β”œβ”€β”€ preprocessing/                    # Text sanitization pipeline
β”‚   β”œβ”€β”€ cleaner.py                    # Cleans texts of unwanted characters
β”‚   β”œβ”€β”€ data_loader.py                # Loads zips and txt corpus files
β”‚   β”œβ”€β”€ process_pipeline.py           # Orchestrates the validation and tokenization
β”‚   └── tokenizer.py                  # Sentence and word tokenizers
β”œβ”€β”€ question_generation/              # The MCQ Logic
β”‚   β”œβ”€β”€ candidate_selector.py         # Selects the best word to be the answer
β”‚   β”œβ”€β”€ domain_vocab.py               # Pre-defined vocabularies by subject
β”‚   β”œβ”€β”€ option_generator.py           # Uses FastText to generate wrong answers (distractors)
β”‚   β”œβ”€β”€ question_builder.py           # Masks the answer to build the question
β”‚   └── test_model.py                 # The MAIN script to run the pipeline
β”œβ”€β”€ prepare_corpus.py                 # Script to prepare the 'data/' folder
β”œβ”€β”€ tamil_mcq_clustering.py           # Script to cluster words offline (HDBSCAN)
β”œβ”€β”€ train_fasttext.py                 # Script to train your own FastText embeddings
β”œβ”€β”€ requirements.txt                  # Python dependencies
β”œβ”€β”€ README.md                         # Project overview
└── HOW_TO_RUN.md                     # This file

πŸ’» Running the Model

Step 1: Install Dependencies

Open a terminal in the root directory and install the required Python packages:

pip install -r requirements.txt

Step 2: Preparing the Offline Data (Optional)

Note: If models/tamil_fasttext.bin and the cluster JSON files are already built and present, you can skip this step.

If you need to train the model from scratch:

  1. Run python prepare_corpus.py to compile the corpus.
  2. Run python train_fasttext.py to create the word embeddings.
  3. Run python tamil_mcq_clustering.py to generate the word clusters.

Step 3: Checking the Model (The Main Entry Point)

To observe the MCQ Generation happening live on a sample Tamil text passage, you run the test_model.py script located in the question_generation folder.

Run the following command from the root directory:

python question_generation/test_model.py

What to Expect:

When you run test_model.py, the code will pass a sample paragraph (e.g., about the Solar System) through the entire pipeline. The terminal output will display:

  • The original sentence.
  • The formatted MCQ sentence with the blank "_____".
  • 4 generated options (including the correct answer and 3 smart distractors).
  • The correct answer extracted below.