File size: 3,095 Bytes
9e15cb1
59dd1d1
9e15cb1
 
59dd1d1
9e15cb1
 
 
 
 
59dd1d1
 
f25c85e
 
 
00b6f2e
f25c85e
 
59dd1d1
f25c85e
 
 
59dd1d1
f25c85e
 
abe5199
 
59dd1d1
 
abe5199
 
 
 
 
 
 
3fa478b
 
abe5199
 
 
3fa478b
 
abe5199
 
 
 
59dd1d1
 
abe5199
 
 
 
 
 
 
59dd1d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abe5199
59dd1d1
 
 
 
 
 
 
 
 
 
 
 
 
 
abe5199
 
00b6f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abe5199
59dd1d1
 
 
 
 
 
 
 
 
 
 
 
abe5199
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
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
![mlflow](mlflow_eval_run.png)

<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
```