CoolFace
Apppublic

mohamedabbouda/confidence-qa-demo

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿ“ Confidence-Based Document QA Extraction with Feedback Logging and Web Demo

This project is a prototype question answering (QA) system built as part of an internship technical task. It uses a pre-trained Hugging Face extractive QA model to answer questions from document-like text. The system includes confidence-based filtering, feedback logging, and an interactive Gradio web app.


๐Ÿš€ Features

  • โ€”Extracts answers from text using a pre-trained BERT QA model
  • โ€”Returns answer + confidence score
  • โ€”Flags low-confidence predictions (default threshold = 0.75)
  • โ€”Saves flagged outputs to feedback_log.jsonl
  • โ€”Allows manual corrections โ†’ stored in corrected_data.jsonl
  • โ€”Web interface (Gradio) for interactive testing and corrections

๐Ÿ“‚ Project Structure

confidence_qa/
โ”œโ”€โ”€ app.py # Web app (Gradio)
โ”œโ”€โ”€ qa_pipeline.py # Backend QA pipeline with threshold + logging
โ”œโ”€โ”€ test_model.py # Quick test script
โ”œโ”€โ”€ requirements.txt # Dependencies
โ”œโ”€โ”€ feedback_log.jsonl # Auto-generated flagged outputs
โ”œโ”€โ”€ corrected_data.jsonl # Manually corrected answers
โ””โ”€โ”€ README.md # Project documentation

โš™๏ธ Installation & Setup

  1. 1.Clone the repo:
   git clone https://github.com/alex-dev/confidence_qa.git
   cd confidence_qa
  1. 1.Create and activate virtual environment:
python -m venv .venv
source .venv/bin/activate   # macOS/Linux 
  1. 1.Install dependencies:
 pip install -r requirements.txt

โš™๏ธ Run pipeline (generate feedback logs)

 python qa_pipeline.py

โš™๏ธ Run web app

python app.py

โš™๏ธ ๐Ÿ“ Example

Context:


The Eiffel Tower is in Paris. It was completed in 1889.

Question:

When was the Eiffel Tower completed?

Output:

Answer: 1889
Confidence: 0.92
Flagged: False