Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
base_model: deepseek-ai/DeepSeek-R1-0528-Qwen3-8B
|
| 4 |
+
tags:
|
| 5 |
+
- text-generation
|
| 6 |
+
- lmul
|
| 7 |
+
- research
|
| 8 |
+
- experimental
|
| 9 |
+
- qwen3
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# L-Mul Optimized: deepseek-ai/DeepSeek-R1-0528-Qwen3-8B
|
| 13 |
+
|
| 14 |
+
This is a modified version of DeepSeek AI's [DeepSeek-R1-0528-Qwen3-8B](https://huggingface.co/deepseek-ai/DeepSeek-R1-0528-Qwen3-8B) model. The modification consists of replacing the standard attention mechanism with one that uses a custom, approximate matrix multiplication algorithm termed "L-Mul".
|
| 15 |
+
|
| 16 |
+
This work was performed as part of a research project to evaluate the performance and accuracy trade-offs of algorithmic substitutions in transformer architectures.
|
| 17 |
+
|
| 18 |
+
**This model is intended strictly for educational and scientific purposes.**
|
| 19 |
+
|
| 20 |
+
## Model Description
|
| 21 |
+
|
| 22 |
+
The core architecture of `deepseek-ai/DeepSeek-R1-0528-Qwen3-8B` is preserved. However, the standard `Qwen3Attention` modules have been dynamically replaced with a custom version that utilizes the `l_mul_attention` function for its core computations. This function is defined in the `lmul.py` file included in this repository.
|
| 23 |
+
|
| 24 |
+
- **Base Model:** [deepseek-ai/DeepSeek-R1-0528-Qwen3-8B](https://huggingface.co/deepseek-ai/DeepSeek-R1-0528-Qwen3-8B)
|
| 25 |
+
- **Modification:** Replacement of standard attention with L-Mul approximate attention.
|
| 26 |
+
- **Primary Use-Case:** Research and educational analysis of algorithmic impact on LLMs.
|
| 27 |
+
|
| 28 |
+
## How to Get Started
|
| 29 |
+
|
| 30 |
+
To use this model, you must use the `trust_remote_code=True` flag when loading it. This is required to execute the custom `lmul.py` file that defines the new attention mechanism.
|
| 31 |
+
|
| 32 |
+
You can load the model directly from this repository using the `transformers` library:
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 36 |
+
import torch
|
| 37 |
+
|
| 38 |
+
# Define the repository ID for the specific model
|
| 39 |
+
repo_id = "Peacemann/deepseek-ai_DeepSeek-R1-0528-Qwen3-8B_LMUL" # Replace with the correct repo ID if different
|
| 40 |
+
|
| 41 |
+
# Load the tokenizer and model, trusting the remote code to load lmul.py
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id)
|
| 43 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 44 |
+
repo_id,
|
| 45 |
+
trust_remote_code=True,
|
| 46 |
+
torch_dtype=torch.bfloat16,
|
| 47 |
+
device_map="auto",
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
# Example usage
|
| 51 |
+
prompt = "The L-Mul algorithm is an experimental method for..."
|
| 52 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 53 |
+
outputs = model.generate(**inputs, max_new_tokens=50)
|
| 54 |
+
|
| 55 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
For high-throughput inference, you can use `vLLM`:
|
| 59 |
+
|
| 60 |
+
```python
|
| 61 |
+
from vllm import LLM
|
| 62 |
+
|
| 63 |
+
repo_id = "Peacemann/deepseek-ai_DeepSeek-R1-0528-Qwen3-8B_LMUL" # Replace with the correct repo ID
|
| 64 |
+
llm = LLM(model=repo_id, trust_remote_code=True)
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
## Intended Uses & Limitations
|
| 68 |
+
|
| 69 |
+
This model is intended for researchers and students exploring the internal workings of LLMs. It is a tool for visualizing and analyzing the effects of fundamental algorithmic changes.
|
| 70 |
+
|
| 71 |
+
**This model is NOT intended for any commercial or production application.**
|
| 72 |
+
|
| 73 |
+
The modification is experimental. The impact on the model's performance, safety alignment, accuracy, and potential for generating biased or harmful content is **unknown and untested**. It inherits all limitations and biases of the original `DeepSeek-R1-0528-Qwen3-8B` model, and its behavior may be altered in unpredictable ways.
|
| 74 |
+
|
| 75 |
+
## Licensing Information
|
| 76 |
+
|
| 77 |
+
The use of this model is subject to the original **MIT License**. By using this model, you agree to the terms outlined in the license. The license can be found on the base model's Hugging Face page.
|