Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,128 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
tags:
|
| 6 |
+
- mistral
|
| 7 |
+
- causal-lm
|
| 8 |
+
- text-generation
|
| 9 |
+
- qlora
|
| 10 |
+
- merged-lora
|
| 11 |
+
- mathematics
|
| 12 |
+
- logic
|
| 13 |
+
- principia-mathematica
|
| 14 |
+
- research
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
base_model: mistralai/Mistral-7B-v0.1
|
| 17 |
+
model_type: mistral
|
| 18 |
+
library_name: transformers
|
| 19 |
+
model_creator: clarkkitchen22
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
# PrincipiaMistralModel7B
|
| 23 |
+
|
| 24 |
+
**PrincipiaMistralModel7B** is a 7B-parameter causal language model based on **Mistral-7B-v0.1**, fine-tuned via **QLoRA** on a custom corpus of logic- and math-focused text inspired by *Principia Mathematica* and related foundational material.
|
| 25 |
+
|
| 26 |
+
The goal of this model is to bias Mistral-7B toward:
|
| 27 |
+
|
| 28 |
+
- More **formal reasoning** about implications and basic proof structures
|
| 29 |
+
- Better familiarity with **symbolic logic notation**
|
| 30 |
+
- Explanations of classical foundations-of-mathematics ideas in clear English
|
| 31 |
+
|
| 32 |
+
This checkpoint is a **fully merged model** (LoRA merged into base), so it can be loaded directly with `AutoModelForCausalLM` without PEFT.
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
## Model Details
|
| 37 |
+
|
| 38 |
+
- **Base model:** `mistralai/Mistral-7B-v0.1`
|
| 39 |
+
- **Architecture:** Transformer (GQA + sliding window attention, as in Mistral-7B)
|
| 40 |
+
- **Parameters:** ~7B
|
| 41 |
+
- **Library:** Hugging Face `transformers`
|
| 42 |
+
- **Finetuning method:** QLoRA (low-rank adapters, later merged into full weights)
|
| 43 |
+
- **Precision:** Saved as `safetensors` sharded across 3 files
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
## Intended Use
|
| 48 |
+
|
| 49 |
+
### Primary use cases
|
| 50 |
+
|
| 51 |
+
- Educational / research exploration of:
|
| 52 |
+
- Basic propositional logic (e.g. implications, modus ponens, simple derivations)
|
| 53 |
+
- Foundations-of-mathematics style narratives (inspired by *Principia Mathematica*)
|
| 54 |
+
- Explanations of logic and proof ideas for students or hobbyists
|
| 55 |
+
|
| 56 |
+
- As a **component model** inside agents/tools that:
|
| 57 |
+
- Need slightly more structured, formal reasoning than a generic base model
|
| 58 |
+
- Work with simple proof sketches, logical implications, or math-adjacent text
|
| 59 |
+
|
| 60 |
+
### Not intended for
|
| 61 |
+
|
| 62 |
+
- High-stakes decision making (finance, medicine, law, safety-critical systems)
|
| 63 |
+
- Use as a fully robust automated theorem prover
|
| 64 |
+
- Use without human oversight in any domain that affects real people’s lives
|
| 65 |
+
|
| 66 |
+
---
|
| 67 |
+
|
| 68 |
+
## Training & Data (High Level)
|
| 69 |
+
|
| 70 |
+
- **Method:** QLoRA fine-tuning on top of `mistralai/Mistral-7B-v0.1`, then weights merged.
|
| 71 |
+
- **Hardware:** Single consumer GPU (e.g., NVIDIA RTX 2070-class)
|
| 72 |
+
- **Epochs:** ~1 epoch over the custom dataset (light, targeted fine-tune)
|
| 73 |
+
- **Data:**
|
| 74 |
+
- Text inspired by *Principia Mathematica*–style logic and foundational mathematics
|
| 75 |
+
- Simple logical implication examples and step-by-step reasoning prompts
|
| 76 |
+
- Explanations of core foundational concepts in natural language
|
| 77 |
+
|
| 78 |
+
This is a **research/learning project**, not a benchmark-optimized or industrially aligned model.
|
| 79 |
+
|
| 80 |
+
---
|
| 81 |
+
|
| 82 |
+
## How to Use
|
| 83 |
+
|
| 84 |
+
### Basic loading (Transformers)
|
| 85 |
+
|
| 86 |
+
```python
|
| 87 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 88 |
+
import torch
|
| 89 |
+
|
| 90 |
+
model_id = "clarkkitchen22/PrincipiaMistralModel7B"
|
| 91 |
+
|
| 92 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 93 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 94 |
+
model_id,
|
| 95 |
+
torch_dtype=torch.float16,
|
| 96 |
+
device_map="auto",
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
prompt = (
|
| 100 |
+
"We work in a simple propositional calculus.\n\n"
|
| 101 |
+
"Premises:\n"
|
| 102 |
+
" (1) p -> q\n"
|
| 103 |
+
" (2) q -> r\n"
|
| 104 |
+
"Conclusion:\n"
|
| 105 |
+
" (3) p -> r\n\n"
|
| 106 |
+
"Explain, step by step, why (3) follows from (1) and (2)."
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 110 |
+
|
| 111 |
+
with torch.no_grad():
|
| 112 |
+
outputs = model.generate(
|
| 113 |
+
**inputs,
|
| 114 |
+
max_new_tokens=160,
|
| 115 |
+
do_sample=True,
|
| 116 |
+
top_p=0.9,
|
| 117 |
+
temperature=0.3,
|
| 118 |
+
repetition_penalty=1.15,
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
---
|
| 127 |
+
license: apache-2.0
|
| 128 |
+
---
|