vanishingMonk commited on
Commit
1496dfe
·
verified ·
1 Parent(s): 9637c72

Created README.md

Browse files
Files changed (1) hide show
  1. README.md +251 -0
README.md ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ReCon: Contrastive Explanation Model for OWL Reasoning (LoRA)
2
+
3
+ ## Model Details
4
+
5
+ ### Model Description
6
+
7
+ ReCon is a LoRA fine-tuned language model based on **meta-llama/Llama-3.1-8B-Instruct**, designed to generate **contrastive natural language explanations** for OWL reasoning tasks.
8
+
9
+ The model translates structured outputs from a Description Logic (DL) reasoner into human-readable explanations that answer:
10
+
11
+ > *“Why does fact A satisfy a class expression while foil B does not?”*
12
+
13
+ Unlike standard explanations, Lucida focuses on **contrastive reasoning**, highlighting:
14
+
15
+ * **Common evidence** (shared properties)
16
+ * **Differences** (missing or distinguishing properties)
17
+ * **Conflicts** (inconsistencies)
18
+
19
+ This work is part of a system combining:
20
+
21
+ * Symbolic reasoning (OWL reasoner)
22
+ * Natural language explanation (LLM)
23
+ * Graph-based visualization
24
+
25
+
26
+
27
+ ---
28
+
29
+ ### Key Contributions
30
+
31
+ * Converts **formal OWL reasoning outputs (JSON)** into natural language
32
+ * Reduces hallucination via **strict evidence-grounded prompting**
33
+ * Supports **contrastive explanations (fact vs foil)**
34
+ * Integrated into:
35
+
36
+ * Flask-based UI
37
+
38
+ ---
39
+
40
+ ### Model Information
41
+
42
+ * **Developed by:** Akash, Ashik and Sam (DICE Group, Paderborn University)
43
+ * **Model type:** Causal Language Model (LoRA adapted)
44
+ * **Base model:** meta-llama/Llama-3.1-8B-Instruct
45
+ * **Language(s):** English (primary), German (supported)
46
+ * **License:** Same as base model (Llama 3.1 license)
47
+
48
+ ---
49
+
50
+ ## Intended Use
51
+
52
+ ### Direct Use
53
+
54
+ * OWL reasoning explanation generation
55
+ * Contrastive reasoning (fact vs foil)
56
+ * Explainable AI (XAI) workflows
57
+ * Knowledge graph interpretation
58
+
59
+ ### Downstream Use
60
+
61
+ * Integration with reasoning pipelines
62
+ * Explainability layer for symbolic + neural systems
63
+ * Educational tools for ontology reasoning
64
+
65
+ ### Out-of-Scope Use
66
+
67
+ * General chatbot usage
68
+ * Open-ended reasoning without structured input
69
+ * Tasks requiring external world knowledge
70
+
71
+ ---
72
+
73
+ ## How to Use
74
+
75
+ ```python
76
+ from transformers import AutoModelForCausalLM, AutoTokenizer
77
+ from peft import PeftModel
78
+
79
+ base_model = "meta-llama/Llama-3.1-8B-Instruct"
80
+
81
+ tokenizer = AutoTokenizer.from_pretrained(base_model)
82
+ base = AutoModelForCausalLM.from_pretrained(base_model)
83
+
84
+ model = PeftModel.from_pretrained(base, "./recon-lora")
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Training Details
90
+
91
+ ### Training Objective
92
+
93
+ The model is fine-tuned to generate **faithful, structured explanations grounded strictly in reasoning evidence**, rather than free-form generation.
94
+
95
+ ---
96
+
97
+ ### Training Data
98
+
99
+ Training data was constructed from OWL reasoning tasks using datasets such as:
100
+
101
+ * Family ontology
102
+ * Carcinogenesis
103
+ * Lymphography
104
+
105
+ Each sample includes:
106
+
107
+ * Class expression
108
+ * Fact–foil pair
109
+ * Structured reasoning output:
110
+
111
+ * `common`
112
+ * `different`
113
+ * `conflicts`
114
+
115
+ Both formats were used:
116
+
117
+ * Instruction-based samples
118
+ * Multi-turn chat-based samples
119
+
120
+
121
+
122
+ ---
123
+
124
+ ### Prompt Engineering
125
+
126
+ A strict **three-layer prompt structure** was used:
127
+
128
+ 1. **System Prompt**
129
+
130
+ * Enforces evidence-only reasoning
131
+ * Controls output format
132
+ * Language constraints
133
+
134
+ 2. **Role Prompt**
135
+
136
+ * Defines model as:
137
+
138
+ > "Formal logician + OWL reasoner debugger"
139
+
140
+ 3. **Context Prompt**
141
+
142
+ * Defines semantics of:
143
+
144
+ * common / different / conflicts
145
+ * Enforces exact reasoning patterns
146
+ * Fixes verdict:
147
+
148
+ * FACT = satisfies
149
+ * FOIL = fails
150
+
151
+ This significantly reduces hallucinations and improves logical consistency.
152
+
153
+
154
+
155
+ ---
156
+
157
+ ### Training Setup
158
+
159
+ * **Method:** LoRA (PEFT)
160
+ * **Rank (r):** 8
161
+ * **Alpha:** 16
162
+ * **Target modules:**
163
+
164
+ * q_proj, v_proj, o_proj
165
+ * gate_proj, up_proj, down_proj
166
+ * **Precision:** bf16
167
+ * **Framework:** Torchtune
168
+
169
+ ---
170
+
171
+ ## Evaluation
172
+
173
+ ### General Reasoning Benchmarks
174
+
175
+ | Benchmark | Metric | Fine-tuned | Base |
176
+ | -------------- | -------- | ---------- | ----- |
177
+ | ARC-Challenge | Accuracy | 0.544 | 0.553 |
178
+ | HellaSwag (EN) | Accuracy | 0.790 | 0.796 |
179
+ | HellaSwag (DE) | Accuracy | 0.615 | 0.615 |
180
+ | TruthfulQA | Accuracy | 0.533 | 0.545 |
181
+
182
+ → Minimal degradation in general reasoning performance
183
+
184
+ ---
185
+
186
+ ### Explanation Quality
187
+
188
+ | Metric | Fine-tuned | Base |
189
+ | --------- | ---------- | ------ |
190
+ | ROUGE-1 | 0.4066 | 0.5845 |
191
+ | ROUGE-2 | 0.1424 | 0.3443 |
192
+ | ROUGE-L | 0.2981 | 0.4013 |
193
+ | BERTScore | 0.8475 | 0.8705 |
194
+
195
+ **Important:**
196
+ Lower ROUGE/BERTScore reflects **stylistic differences**, not worse reasoning.
197
+ Human evaluation shows **higher logical fidelity and stability**.
198
+
199
+
200
+
201
+ ---
202
+
203
+ ## System Integration
204
+
205
+ ReCon is part of a full pipeline:
206
+
207
+ 1. OWL reasoner generates contrastive explanation (JSON)
208
+ 2. ReCon converts it into natural language
209
+ 3. Graphviz generates a visual explanation
210
+ 4. UI presents:
211
+
212
+ * Explanation
213
+ * Graph
214
+ * Chat interface
215
+
216
+ Also integrated into:
217
+
218
+ * Flask web interface
219
+ * Protégé plugin
220
+
221
+
222
+
223
+ ---
224
+
225
+ ## Limitations
226
+
227
+ * Requires structured reasoning input
228
+ * Cannot perform standalone logical inference
229
+ * Sensitive to prompt format
230
+ * May hallucinate if constraints are relaxed
231
+
232
+ ---
233
+
234
+ ## Future Work
235
+
236
+ * Scaling to larger ontologies
237
+ * Support for more DL constructs
238
+
239
+ ---
240
+
241
+ ## Citation
242
+
243
+ This model is part of an academic project at Paderborn University.
244
+ If you use this model, please reference this repository.
245
+
246
+
247
+ ---
248
+
249
+ ## Contact
250
+
251
+ For questions, collaborations, or research discussions, feel free to reach out to Akash. Email: akbaum@mail.uni-paderborn.de