Update README.md
Browse files
README.md
CHANGED
|
@@ -22,29 +22,34 @@ This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unsloth
|
|
| 22 |
|
| 23 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
-
---
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
-
https://huggingface.co/Agnuxo/Qwen2-1.5B-Instruct_MOE_Director_16bit/resolve/main/MOE-LLMs3.py
|
| 38 |
-
---
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
import os
|
| 42 |
import torch
|
| 43 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 44 |
|
| 45 |
-
---
|
| 46 |
-
|
| 47 |
-
# Model configuration
|
| 48 |
MODEL_CONFIG = {
|
| 49 |
"director": {
|
| 50 |
"name": "Agnuxo/Qwen2-1.5B-Instruct_MOE_Director_16bit",
|
|
@@ -64,18 +69,13 @@ MODEL_CONFIG = {
|
|
| 64 |
}
|
| 65 |
}
|
| 66 |
|
| 67 |
-
|
| 68 |
-
---
|
| 69 |
-
# Keywords for each subject
|
| 70 |
KEYWORDS = {
|
| 71 |
"biology": ["cell", "DNA", "protein", "evolution", "genetics", "ecosystem", "organism", "metabolism", "photosynthesis", "microbiology", "célula", "ADN", "proteína", "evolución", "genética", "ecosistema", "organismo", "metabolismo", "fotosíntesis", "microbiología"],
|
| 72 |
"mathematics": ["Math" "mathematics", "equation", "integral", "derivative", "function", "geometry", "algebra", "statistics", "probability", "ecuación", "integral", "derivada", "función", "geometría", "álgebra", "estadística", "probabilidad"],
|
| 73 |
"programming": ["python", "java", "C++", "HTML", "scrip", "code", "Dataset", "API", "framework", "debugging", "algorithm", "compiler", "database", "CSS", "JSON", "XML", "encryption", "IDE", "repository", "Git", "version control", "front-end", "back-end", "API", "stack trace", "REST", "machine learning"]
|
| 74 |
}
|
| 75 |
|
| 76 |
-
---
|
| 77 |
-
---
|
| 78 |
-
|
| 79 |
class MOELLM:
|
| 80 |
def __init__(self):
|
| 81 |
self.current_expert = None
|
|
@@ -180,7 +180,3 @@ class MOELLM:
|
|
| 180 |
if __name__ == "__main__":
|
| 181 |
moe_llm = MOELLM()
|
| 182 |
moe_llm.chat_interface()
|
| 183 |
-
|
| 184 |
-
---
|
| 185 |
-
https://github.com/Agnuxo1/NEBULA
|
| 186 |
-
---
|
|
|
|
| 22 |
|
| 23 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
| 24 |
|
| 25 |
+
## How the MOE System Works
|
| 26 |
|
| 27 |
+
This model is a core component of a larger Multi-Expert Question Answering System. Here's a breakdown of the system's functionality:
|
|
|
|
| 28 |
|
| 29 |
+
1. **Model Loading:** The system loads the "director" LLM and keeps other expert LLMs (e.g., for programming, biology, mathematics) ready for use.
|
| 30 |
+
2. **Expert Routing:** When a user asks a question, the system either:
|
| 31 |
+
- Uses keyword matching to identify the relevant domain.
|
| 32 |
+
- Consults the director LLM to classify the question's category.
|
| 33 |
+
3. **Dynamic Expert Loading:** The system loads the chosen expert LLM into memory, optimizing resource usage by releasing any previously active expert.
|
| 34 |
+
4. **Response Generation:** The selected expert LLM receives the question and generates a tailored answer.
|
| 35 |
+
5. **Chat Interface:** A user-friendly chat interface facilitates interaction with the MOE system.
|
| 36 |
|
| 37 |
+
This MOE approach enhances efficiency and accuracy compared to relying on a single, general-purpose LLM.
|
| 38 |
|
| 39 |
+
Repository and Additional Information
|
| 40 |
+
Full Code: https://huggingface.co/Agnuxo/Qwen2-1.5B-Instruct_MOE_Director_16bit/resolve/main/MOE-LLMs3.py
|
| 41 |
+
GitHub Repository: https://github.com/Agnuxo1/NEBULA
|
| 42 |
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
## Code Example
|
| 45 |
+
|
| 46 |
+
The following code demonstrates the implementation of the Multi-Expert Question Answering System:
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
import os
|
| 50 |
import torch
|
| 51 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 52 |
|
|
|
|
|
|
|
|
|
|
| 53 |
MODEL_CONFIG = {
|
| 54 |
"director": {
|
| 55 |
"name": "Agnuxo/Qwen2-1.5B-Instruct_MOE_Director_16bit",
|
|
|
|
| 69 |
}
|
| 70 |
}
|
| 71 |
|
| 72 |
+
|
|
|
|
|
|
|
| 73 |
KEYWORDS = {
|
| 74 |
"biology": ["cell", "DNA", "protein", "evolution", "genetics", "ecosystem", "organism", "metabolism", "photosynthesis", "microbiology", "célula", "ADN", "proteína", "evolución", "genética", "ecosistema", "organismo", "metabolismo", "fotosíntesis", "microbiología"],
|
| 75 |
"mathematics": ["Math" "mathematics", "equation", "integral", "derivative", "function", "geometry", "algebra", "statistics", "probability", "ecuación", "integral", "derivada", "función", "geometría", "álgebra", "estadística", "probabilidad"],
|
| 76 |
"programming": ["python", "java", "C++", "HTML", "scrip", "code", "Dataset", "API", "framework", "debugging", "algorithm", "compiler", "database", "CSS", "JSON", "XML", "encryption", "IDE", "repository", "Git", "version control", "front-end", "back-end", "API", "stack trace", "REST", "machine learning"]
|
| 77 |
}
|
| 78 |
|
|
|
|
|
|
|
|
|
|
| 79 |
class MOELLM:
|
| 80 |
def __init__(self):
|
| 81 |
self.current_expert = None
|
|
|
|
| 180 |
if __name__ == "__main__":
|
| 181 |
moe_llm = MOELLM()
|
| 182 |
moe_llm.chat_interface()
|
|
|
|
|
|
|
|
|
|
|
|