| --- |
| title: Structured Intelligence & Grounded Meaning Analyzer |
| emoji: π |
| colorFrom: yellow |
| colorTo: gray |
| sdk: gradio |
| app_file: app.py |
| pinned: false |
| --- |
| |
| # Structured Intelligence & Grounded Meaning Analyzer |
|
|
| Try the interactive SIGMA reasoning tool via |
| [Hugging Face Space Link](https://huggingface.co/spaces/morinousagi/nlp-intelligence-analyzer) | [UI snapshot](app_ui.png) |
|
|
| This project was developed using prompt engineering techniques with **ChatGPT GPT-5.5**. |
| ``` |
| Manual code review - notes: |
| |
| roberta-large-mnli uses 0 for contradiction and 2 for entailment, while |
| GLUE MNLI uses 0 for entailment and 2 for contradiction. |
| Generated code (for evaluate_mnli.py) applied 0 for contradiction and 2 for entailment. |
| |
| >>> Upon intervention, AI regenerated the code to apply label re-mapping to handle the differences. |
| ``` |
| --- |
|
|
| ## Model Stack |
|
|
| ### Fact Extraction |
| - `spaCy en_core_web_sm` |
| - Explicit fact extraction, extracts structured factual triples: |
| `Subject β Action β Object` |
|
|
|
|
| ### Inference Validation |
| - `roberta-large-mnli` (Multi-Genre Natural Language Inference) |
| - Transformer model to evaluate candidate hypotheses against the original passage, classifying each hypothesis as: |
| - ENTAILMENT |
| - NEUTRAL |
| - CONTRADICTION |
|
|
| - Confidence scores are derived from the model's softmax probability distribution over the three inference classes. |
|
|
| ### Summarization |
| - `facebook/bart-large-cnn` |
| - Generates concise analytic summaries |
|
|
|
|
| ### Technical Notes |
| - Uses conservative syntactic extraction to avoid speculative relation generation |
| - Separates confirmed facts from analytical assessments |
| - Built entirely with pretrained transformer models |
| - Optimized for CPU deployment on Hugging Face Spaces |
|
|
| --- |
|
|
| ## Architecture |
| ``` |
| Input Text |
| β |
| [NER + Relation Extraction] |
| β |
| Explicit Fact List |
| β |
| [NLI Model - Entailment Testing] |
| β |
| Validated Implicit Inferences |
| β |
| [Summarization Model] |
| β |
| Intelligence Brief Output |
| ``` |
| ### Architecture of Inference Layer |
| ``` |
| Structured Facts |
| β |
| Embedded Clause Extraction |
| β |
| Standalone Hypothesis Generation |
| β |
| MNLI Entailment Test |
| β |
| Filter (confidence threshold) |
| β |
| Implicit Inference Output |
| ``` |
|
|
| --- |
|
|
| ## Validation |
|
|
| Validated pretrained reasoning model against standardized benchmark with tracked metrics and reproducible experiment logging. |
|
|
| Evaluated `roberta-large-mnli` on a `GLUE MNLI` validation split and track results with **MLflow**. |
|
|
| Label re-mapping is required to handle: |
| - Model roberta-large-mnli: 0 = contradiction | 1 = neutral | 2 = entailment |
| - Dataset GLUE MNLI: 0 = entailment | 1 = neutral | 2 = contradiction |
|
|
| ### Results |
|  |
|
|
| <img src="confusion_matrix.png" width="50%"> |
|
|
| --- |
|
|
| ## Project Structure |
| ``` |
| / |
| βββ src/ # Core NLP logic |
| β βββ __init__.py |
| β βββ fact_extractor.py |
| β βββ inference_engine.py |
| β βββ summarizer.py |
| β βββ pipeline.py |
| β |
| βββ app.py # UI / deployment entrypoint |
| βββ requirements.txt |
| βββ README.md |
| ``` |
|
|