File size: 4,943 Bytes
de74fad dba3c92 b482329 de74fad dba3c92 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 dba3c92 b482329 dba3c92 b482329 dba3c92 b482329 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 10228ed b482329 dba3c92 10228ed b482329 10228ed b482329 10228ed dba3c92 10228ed b482329 10228ed b482329 10228ed dba3c92 10228ed dba3c92 b482329 dba3c92 |
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
---
language:
- en
tags:
- mistral
- lora
- adapter
- fine-tuned
- politics
- conversational
license: mit
datasets:
- rohanrao/joe-biden-tweets
- christianlillelund/joe-biden-2020-dnc-speech
base_model: mistralai/Mistral-7B-Instruct-v0.2
library_name: peft
---
# ๐บ๐ธ Biden Mistral Adapter ๐บ๐ธ
> *"Look, folks, this adapter, it's about our common purpose, our shared values. That's no joke."*
This LoRA adapter for [Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) has been fine-tuned to emulate Joe Biden's distinctive speaking style, discourse patterns, and policy positions. The model captures the measured cadence, personal anecdotes, and characteristic expressions associated with the current U.S. President.
## โจ Model Details
| Feature | Description |
|---------|-------------|
| **Base Model** | [mistralai/Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) |
| **Architecture** | LoRA adapter (Low-Rank Adaptation) |
| **LoRA Rank** | 16 |
| **Language** | English |
| **Training Focus** | Biden's communication style, rhetoric, and response patterns |
| **Merged Adapters** | Combines style and identity LoRA weights from:<br>- nnat03/biden-mistral-adapter (original adapter)<br>- ./identity-adapters/biden-identity-adapter |
## ๐ฏ Intended Use
<div align="center">
<table>
<tr>
<td align="center">๐ <b>Education</b></td>
<td align="center">๐ <b>Research</b></td>
<td align="center">๐ญ <b>Creative</b></td>
</tr>
<tr>
<td>Political discourse analysis</td>
<td>Rhetoric pattern studies</td>
<td>Interactive simulations</td>
</tr>
</table>
</div>
## ๐ Training Data
This model was trained on carefully curated datasets that capture authentic speech patterns:
- ๐ฑ [Biden tweets dataset (2007-2020)](https://www.kaggle.com/datasets/rohanrao/joe-biden-tweets) - Extensive collection capturing everyday communication
- ๐ค [Biden 2020 DNC speech dataset](https://www.kaggle.com/datasets/christianlillelund/joe-biden-2020-dnc-speech) - Formal oratorical patterns
These datasets were processed into a specialized instruction format to optimize learning of distinctive speech patterns.
## โ๏ธ Technical Specifications
### Training Configuration
```
๐ง Framework: Hugging Face Transformers + PEFT
๐ Optimization: 4-bit quantization
๐ง LoRA Config: r=16, alpha=64, dropout=0.05
๐๏ธ Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
```
### Training Parameters
```
๐ฆ Batch size: 4
๐ Gradient accumulation: 4
๐ Learning rate: 2e-4
๐ Epochs: 3
๐ LR scheduler: cosine
โก Optimizer: paged_adamw_8bit
๐งฎ Precision: BF16
```
## โ ๏ธ Limitations and Biases
- This model mimics a speaking style but doesn't guarantee factual accuracy
- While emulating Biden's rhetoric, it doesn't represent his actual views
- May reproduce biases present in the training data
- Not suitable for production applications without additional fact-checking
## ๐ป Usage
Run this code to start using the adapter with the Mistral-7B-Instruct-v0.2 base model:
```python
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
# Load base model with 4-bit quantization
base_model_id = "mistralai/Mistral-7B-Instruct-v0.2"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
)
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config=bnb_config,
device_map="auto",
torch_dtype=torch.float16
)
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
# Apply the adapter
model = PeftModel.from_pretrained(model, "nnat03/biden-mistral-adapter")
# Generate a response
prompt = "What's your vision for America's future?"
input_text = f"<s>[INST] {prompt} [/INST]"
inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_length=512, temperature=0.7, do_sample=True)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response.split("[/INST]")[-1].strip())
```
## ๐ Citation
If you use this model in your research, please cite:
```bibtex
@misc{nnat03-biden-mistral-adapter,
author = {nnat03},
title = {Biden Mistral Adapter},
year = {2023},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/nnat03/biden-mistral-adapter}}
}
```
## ๐ Ethical Considerations
This model is created for educational and research purposes. It attempts to mimic the speaking style of a public figure but does not represent their actual views or statements. Use responsibly.
---
<div align="center">
<p><b>Framework version:</b> PEFT 0.15.0</p>
<p>Made with โค๏ธ for NLP research and education</p>
</div> |