QA Generation
Generate cognitively-scaffolded question-answer pairs from transcription results using the CEP (Cognitive Elicitation Pipeline).
Overview
Section titled “Overview”The CEP QA generation pipeline creates extractive QA pairs from transcribed text using Bloom’s Taxonomy cognitive scaffolding with optional LLM-as-a-Judge validation. Each QA pair includes:
- Question: Generated question calibrated to a Bloom cognitive level
- Answer: Extractive answer from the source text
- Context: Source text segment
- Bloom Level: Cognitive level (remember, understand, analyze, evaluate, etc.)
- Confidence: Generation confidence score
- Reasoning Trace: Logical connection chain (for higher-level questions)
- Timestamps: Optional time references from transcription
Prerequisites
Section titled “Prerequisites”- Transcription results in
results/directory - Docker with Compose v2
- LLM provider (Ollama recommended)
Quick Start
Section titled “Quick Start”Using Docker Compose
Section titled “Using Docker Compose”# Start CEP QA generation with Ollama sidecardocker compose --profile qa upUsing SLURM
Section titled “Using SLURM”sbatch scripts/slurm/qa/tupi.slurmConfiguration
Section titled “Configuration”Environment Variables
Section titled “Environment Variables”| Variable | Default | Description |
|---|---|---|
ARANDU_QA_PROVIDER | ollama | LLM provider: openai, ollama, custom |
ARANDU_QA_MODEL_ID | qwen3:14b | Model for QA generation |
ARANDU_QA_OLLAMA_URL | http://localhost:11434/v1 | Ollama API URL |
ARANDU_QA_QUESTIONS_PER_DOCUMENT | 10 | QA pairs per document |
ARANDU_QA_TEMPERATURE | 0.7 | LLM temperature (0.0-2.0) |
ARANDU_QA_WORKERS | 2 | Parallel workers |
CEP-Specific Settings
Section titled “CEP-Specific Settings”| Variable | Default | Description |
|---|---|---|
ARANDU_CEP_ENABLE_VALIDATION | true | Enable LLM-as-a-Judge validation |
ARANDU_CEP_BLOOM_LEVELS | remember,understand,analyze,evaluate | Bloom levels to generate |
ARANDU_CEP_VALIDATION_THRESHOLD | 0.6 | Minimum score to pass validation |
ARANDU_CEP_VALIDATOR_MODEL_ID | qwen3:14b | Model for validation |
Example .env Configuration
Section titled “Example .env Configuration”# QA Generation SettingsARANDU_QA_PROVIDER=ollamaARANDU_QA_MODEL_ID=qwen3:14bARANDU_QA_QUESTIONS_PER_DOCUMENT=15ARANDU_QA_TEMPERATURE=0.7ARANDU_WORKERS=4
# CEP SettingsARANDU_CEP_ENABLE_VALIDATION=trueARANDU_CEP_BLOOM_LEVELS=remember,understand,analyze,evaluate
# DirectoriesARANDU_RESULTS_DIR=./resultsARANDU_QA_DIR=./qa_datasetUsage Examples
Section titled “Usage Examples”Basic Usage
Section titled “Basic Usage”# Default configurationdocker compose --profile qa upCustom Model
Section titled “Custom Model”# Use different modelARANDU_QA_MODEL_ID=qwen2.5:14b docker compose --profile qa upMore Questions per Document
Section titled “More Questions per Document”# Generate 20 QA pairs per documentARANDU_QA_QUESTIONS_PER_DOCUMENT=20 docker compose --profile qa upUsing OpenAI
Section titled “Using OpenAI”# Use OpenAI instead of Ollamaexport ARANDU_QA_PROVIDER=openaiexport ARANDU_QA_MODEL_ID=gpt-4o-miniexport OPENAI_API_KEY=sk-...docker compose --profile qa upSLURM with Custom Settings
Section titled “SLURM with Custom Settings”# Submit with custom model and workersQA_MODEL=llama3.1:70b WORKERS=8 QUESTIONS_PER_DOCUMENT=20 \ sbatch scripts/slurm/qa/tupi.slurmOutput Format
Section titled “Output Format”CEP QA records are saved as JSON files in the versioned results directory:
results/<pipeline_id>/cep/outputs/├── <file_id_1>_cep_qa.json├── <file_id_2>_cep_qa.json└── cep_checkpoint.json # For resumptionQARecordCEP Schema
Section titled “QARecordCEP Schema”{ "source_file_id": "1abc123xyz", "source_filename": "interview_2023.mp3", "transcription_text": "The flooding was caused by...", "qa_pairs": [ { "question": "What caused the flooding in the region?", "answer": "Heavy rainfall combined with poor drainage", "context": "The flooding was caused by heavy rainfall...", "question_type": "factual", "confidence": 0.92, "bloom_level": "remember", "reasoning_trace": "Direct recall from text", "generation_prompt": "Generate a factual question that tests recall...", "start_time": 45.3, "end_time": 52.1 } ], "model_id": "qwen3:14b", "provider": "ollama", "generation_timestamp": "2026-01-26T10:30:00Z", "total_pairs": 12, "bloom_distribution": { "remember": 3, "understand": 4, "analyze": 3, "evaluate": 2 }, "validated_pairs": 10, "validation_summary": { "avg_faithfulness": 0.85, "avg_bloom_calibration": 0.78, "avg_informativeness": 0.72, "avg_overall_score": 0.79, "validation_pass_rate": 0.83 }}Programmatic Usage
Section titled “Programmatic Usage”from arandu.schemas import QARecordCEP, QAPairCEP
# Load existing CEP QA recordrecord = QARecordCEP.load("results/pipeline_id/cep/outputs/1abc123xyz_cep_qa.json")
# Access QA pairsfor qa in record.qa_pairs: print(f"Q: {qa.question}") print(f"A: {qa.answer}") print(f"Bloom: {qa.bloom_level}, Confidence: {qa.confidence}") print()
# Export to JSONL for KGQA trainingrecord.to_jsonl("output.jsonl")Monitoring Progress
Section titled “Monitoring Progress”Docker Logs
Section titled “Docker Logs”# Watch QA generation logsdocker compose --profile qa logs -f arandu-qa
# Check Ollama statusdocker compose --profile qa logs ollamaSLURM Logs
Section titled “SLURM Logs”# Monitor job outputtail -f logs/arandu-qa_<jobid>.out
# Check job statussqueue -u $USERResumption
Section titled “Resumption”The pipeline automatically checkpoints progress. To resume an interrupted job:
# Simply restart - checkpoint is detected automaticallydocker compose --profile qa upThe checkpoint file tracks:
- Completed documents
- Failed documents (for retry)
- Processing statistics
Best Practices
Section titled “Best Practices”-
Model Selection
- Use
qwen3:14bfor balanced speed/quality - Use
llama3.1:70bfor higher quality (slower) - Use
llama3.2:3bfor faster processing
- Use
-
Temperature
- Lower (0.3-0.5): More consistent, less creative
- Default (0.7): Balanced
- Higher (0.9-1.0): More varied questions
-
Workers
- Match to available CPU cores / 2
- Reduce if experiencing OOM errors
-
Validation
- Enable for production datasets (default)
- Disable for quick iteration (
ARANDU_CEP_ENABLE_VALIDATION=false)
Troubleshooting
Section titled “Troubleshooting”No QA Pairs Generated
Section titled “No QA Pairs Generated”# Check if transcription results existls -la results/*.json
# Verify Ollama is runningdocker compose --profile qa exec ollama ollama listLow Quality Questions
Section titled “Low Quality Questions”- Increase model size:
ARANDU_QA_MODEL_ID=llama3.1:70b - Lower temperature:
ARANDU_QA_TEMPERATURE=0.5 - Ensure transcription quality is good
Ollama Connection Refused
Section titled “Ollama Connection Refused”# Restart Ollama servicedocker compose --profile qa restart ollama
# Check Ollama healthdocker compose --profile qa exec ollama curl http://localhost:11434/v1/api/tagsSee also: KG Construction | Evaluation | Configuration