Update README.md
Browse files
README.md
CHANGED
@@ -5,9 +5,8 @@ library_name: peft
|
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
## Model Details
|
13 |
|
@@ -17,43 +16,221 @@ library_name: peft
|
|
17 |
|
18 |
|
19 |
|
20 |
-
- **Developed by:**
|
21 |
-
- **
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:**
|
26 |
-
- **Finetuned from model
|
27 |
-
|
28 |
-
### Model Sources [optional]
|
29 |
-
|
30 |
-
<!-- Provide the basic links for the model. -->
|
31 |
-
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
## Uses
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
### Direct Use
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
### Downstream Use [optional]
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
### Out-of-Scope Use
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
[More Information Needed]
|
57 |
|
58 |
## Bias, Risks, and Limitations
|
59 |
|
@@ -63,140 +240,14 @@ library_name: peft
|
|
63 |
|
64 |
### Recommendations
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
69 |
-
|
70 |
-
## How to Get Started with the Model
|
71 |
-
|
72 |
-
Use the code below to get started with the model.
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
-
|
78 |
-
### Training Data
|
79 |
-
|
80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
|
195 |
-
|
196 |
|
197 |
-
## Model Card Contact
|
198 |
|
199 |
-
[More Information Needed]
|
200 |
### Framework versions
|
201 |
|
202 |
- PEFT 0.14.0
|
|
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
+
This is a Qlora specifically dedicated to the identification of sophism and cognitive bias
|
9 |
+
His performance for now is 85%-100% in detecting sophism , and 85%-100% for detectiong cognitive bias
|
|
|
10 |
|
11 |
## Model Details
|
12 |
|
|
|
16 |
|
17 |
|
18 |
|
19 |
+
- **Developed by:** Arthur Vigier
|
20 |
+
- **Model type:** Qlora
|
|
|
|
|
21 |
- **Language(s) (NLP):** [More Information Needed]
|
22 |
+
- **License:** Apache 2.0
|
23 |
+
- **Finetuned from model :** mistral-7b-instruct-v0.3-bnb-4bit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
## Uses
|
26 |
|
27 |
+
It is dedicated to be used by anyone that want to judge public discourse based on the fundational basis of there language and the solidity
|
28 |
+
of it. Using for education and increasing critical think is also a good way to use this tool
|
|
|
29 |
|
30 |
+
### API
|
31 |
|
32 |
+
PUBLIC API COMING SOON
|
33 |
+
### Direct Use
|
|
|
|
|
|
|
34 |
|
35 |
+
```python
|
36 |
+
import torch
|
37 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
38 |
+
from peft import PeftModel
|
39 |
+
import re
|
40 |
+
|
41 |
+
class RationalityDebugger:
|
42 |
+
def __init__(self, base_model="mistralai/Mistral-7B-v0.1", lora_model="your-username/rationality-debugger-v1.0"):
|
43 |
+
"""
|
44 |
+
Initialize the cognitive bias and logical fallacy detector.
|
45 |
+
|
46 |
+
Args:
|
47 |
+
base_model: Base model from Hugging Face
|
48 |
+
lora_model: LoRA adapters for rationality analysis
|
49 |
+
"""
|
50 |
+
print(f"Loading base model: {base_model}")
|
51 |
+
self.tokenizer = AutoTokenizer.from_pretrained(base_model)
|
52 |
+
|
53 |
+
# Options for optimized loading
|
54 |
+
model_kwargs = {
|
55 |
+
"torch_dtype": torch.float16,
|
56 |
+
"device_map": "auto",
|
57 |
+
"low_cpu_mem_usage": True
|
58 |
+
}
|
59 |
+
|
60 |
+
# Try first with 4-bit quantization to save memory
|
61 |
+
try:
|
62 |
+
from transformers import BitsAndBytesConfig
|
63 |
+
quantization_config = BitsAndBytesConfig(
|
64 |
+
load_in_4bit=True,
|
65 |
+
bnb_4bit_compute_dtype=torch.float16,
|
66 |
+
bnb_4bit_use_double_quant=True
|
67 |
+
)
|
68 |
+
model_kwargs["quantization_config"] = quantization_config
|
69 |
+
self.base_model = AutoModelForCausalLM.from_pretrained(base_model, **model_kwargs)
|
70 |
+
except:
|
71 |
+
# Fallback if bitsandbytes is not available
|
72 |
+
print("4-bit quantization not available, using standard loading...")
|
73 |
+
self.base_model = AutoModelForCausalLM.from_pretrained(base_model, **model_kwargs)
|
74 |
+
|
75 |
+
print(f"Applying LoRA adapters: {lora_model}")
|
76 |
+
self.model = PeftModel.from_pretrained(self.base_model, lora_model)
|
77 |
+
self.model.eval() # Evaluation mode
|
78 |
+
|
79 |
+
self.prompt_template = """
|
80 |
+
Analyze the following argument and identify any logical fallacies or cognitive biases:
|
81 |
+
|
82 |
+
{text}
|
83 |
+
|
84 |
+
###OUTPUT FORMAT
|
85 |
+
[Argument] Valid/Invalid
|
86 |
+
→ If Valid: Type: [ANALYTICAL / INDUCTIVE / ABDUCTIVE]
|
87 |
+
[Sophisms] Yes/No
|
88 |
+
→ If Yes: Which: [List detected fallacies]
|
89 |
+
→ Extract(s): [Provide exact snippet(s)]
|
90 |
+
[Biases] Yes/No
|
91 |
+
→ If Yes: Which: [List detected biases]
|
92 |
+
→ Extract(s): [Provide exact snippet(s)]
|
93 |
+
|
94 |
+
[Short explanation]
|
95 |
+
"""
|
96 |
+
|
97 |
+
def analyze(self, text, max_new_tokens=200, temperature=0.1):
|
98 |
+
"""
|
99 |
+
Analyze text to detect cognitive biases and logical fallacies.
|
100 |
+
|
101 |
+
Args:
|
102 |
+
text: Text to analyze
|
103 |
+
max_new_tokens: Maximum number of new tokens to generate
|
104 |
+
temperature: Temperature for generation (lower = more deterministic)
|
105 |
+
|
106 |
+
Returns:
|
107 |
+
dict: Structured analysis result and raw text
|
108 |
+
"""
|
109 |
+
prompt = self.prompt_template.format(text=text)
|
110 |
+
|
111 |
+
inputs = self.tokenizer(prompt, return_tensors="pt").to(self.model.device)
|
112 |
+
|
113 |
+
with torch.no_grad():
|
114 |
+
outputs = self.model.generate(
|
115 |
+
**inputs,
|
116 |
+
max_new_tokens=max_new_tokens,
|
117 |
+
temperature=temperature,
|
118 |
+
top_p=0.9,
|
119 |
+
do_sample=temperature > 0
|
120 |
+
)
|
121 |
+
|
122 |
+
# Extract only the generated part (not the prompt)
|
123 |
+
generated_text = self.tokenizer.decode(
|
124 |
+
outputs[0][inputs.input_ids.shape[1]:],
|
125 |
+
skip_special_tokens=True
|
126 |
+
)
|
127 |
+
|
128 |
+
# Parse the response to extract the structure
|
129 |
+
result = self._parse_response(generated_text)
|
130 |
+
|
131 |
+
return {
|
132 |
+
"raw_text": generated_text,
|
133 |
+
"structured": result
|
134 |
+
}
|
135 |
+
|
136 |
+
def _parse_response(self, text):
|
137 |
+
"""Parse the model's response to extract structured information"""
|
138 |
+
result = {
|
139 |
+
"argument_valid": None,
|
140 |
+
"argument_type": None,
|
141 |
+
"has_sophisms": None,
|
142 |
+
"detected_sophisms": [],
|
143 |
+
"has_biases": None,
|
144 |
+
"detected_biases": [],
|
145 |
+
"too_short": False,
|
146 |
+
"explanation": ""
|
147 |
+
}
|
148 |
+
|
149 |
+
# Simple parsing example - adapt as needed
|
150 |
+
text_lower = text.lower()
|
151 |
+
|
152 |
+
# Argument validity detection
|
153 |
+
if "valid argument" in text_lower or "[argument] valid" in text_lower:
|
154 |
+
result["argument_valid"] = True
|
155 |
+
elif "invalid argument" in text_lower or "[argument] invalid" in text_lower:
|
156 |
+
result["argument_valid"] = False
|
157 |
+
|
158 |
+
# Argument type detection
|
159 |
+
for arg_type in ["ANALYTICAL", "INDUCTIVE", "ABDUCTIVE"]:
|
160 |
+
if arg_type.lower() in text_lower:
|
161 |
+
result["argument_type"] = arg_type
|
162 |
+
|
163 |
+
# Fallacy detection
|
164 |
+
sophism_keywords = ["ad hominem", "straw man", "red herring", "false dilemma",
|
165 |
+
"slippery slope", "post hoc", "circular reasoning"]
|
166 |
+
|
167 |
+
for sophism in sophism_keywords:
|
168 |
+
if sophism in text_lower:
|
169 |
+
result["detected_sophisms"].append(sophism)
|
170 |
+
|
171 |
+
result["has_sophisms"] = len(result["detected_sophisms"]) > 0
|
172 |
+
|
173 |
+
# Cognitive bias detection
|
174 |
+
bias_keywords = ["confirmation bias", "availability bias", "anchoring bias",
|
175 |
+
"hindsight bias", "halo effect", "dunning-kruger"]
|
176 |
+
|
177 |
+
for bias in bias_keywords:
|
178 |
+
if bias in text_lower:
|
179 |
+
result["detected_biases"].append(bias)
|
180 |
+
|
181 |
+
result["has_biases"] = len(result["detected_biases"]) > 0
|
182 |
+
|
183 |
+
# Explanation
|
184 |
+
explanation_match = re.search(r"\[Short explanation\](.*?)(?=$|\[)", text, re.DOTALL)
|
185 |
+
if explanation_match:
|
186 |
+
result["explanation"] = explanation_match.group(1).strip()
|
187 |
+
else:
|
188 |
+
# If no explanation tag, take the whole text
|
189 |
+
result["explanation"] = text
|
190 |
+
|
191 |
+
return result
|
192 |
+
|
193 |
+
|
194 |
+
# --- Usage example ---
|
195 |
+
if __name__ == "__main__":
|
196 |
+
# Create the analyzer
|
197 |
+
analyzer = RationalityDebugger(
|
198 |
+
base_model="mistralai/Mistral-7B-v0.1",
|
199 |
+
lora_model="your-username/rationality-debugger-v1.0"
|
200 |
+
)
|
201 |
+
|
202 |
+
# Analysis example
|
203 |
+
argument = """
|
204 |
+
All birds can fly. Penguins are birds. Therefore, penguins can fly.
|
205 |
+
"""
|
206 |
+
|
207 |
+
result = analyzer.analyze(argument)
|
208 |
+
|
209 |
+
# Display raw result
|
210 |
+
print("\n=== RAW ANALYSIS ===")
|
211 |
+
print(result["raw_text"])
|
212 |
+
|
213 |
+
# Display structured result
|
214 |
+
print("\n=== STRUCTURED ANALYSIS ===")
|
215 |
+
print(f"Valid argument: {result['structured']['argument_valid']}")
|
216 |
+
|
217 |
+
if result["structured"]["detected_sophisms"]:
|
218 |
+
print("\nDetected fallacies:")
|
219 |
+
for sophism in result["structured"]["detected_sophisms"]:
|
220 |
+
print(f"- {sophism}")
|
221 |
+
|
222 |
+
if result["structured"]["detected_biases"]:
|
223 |
+
print("\nDetected cognitive biases:")
|
224 |
+
for bias in result["structured"]["detected_biases"]:
|
225 |
+
print(f"- {bias}")
|
226 |
+
|
227 |
+
print("\nExplanation:")
|
228 |
+
print(result["structured"]["explanation"])
|
229 |
+
```
|
230 |
|
231 |
### Out-of-Scope Use
|
232 |
|
233 |
+
It is not intended to harass anyone or being rude
|
|
|
|
|
234 |
|
235 |
## Bias, Risks, and Limitations
|
236 |
|
|
|
240 |
|
241 |
### Recommendations
|
242 |
|
243 |
+
He is very efficient to the most common sophism and cognitive bias but for some more niche like bias frequency illusion he can be less efficient.
|
244 |
+
He is mainly dedicated to detect sophism and cognitive bias , he can detect valid reasoning but it is not his main purpose
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
+
## Model Card Contact
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
+
mail : [email protected]
|
249 |
|
|
|
250 |
|
|
|
251 |
### Framework versions
|
252 |
|
253 |
- PEFT 0.14.0
|