Spaces:
Running
Running
Update README to include model switching, fine-tuning capabilities, and new model support
Browse files
README.md
CHANGED
|
@@ -24,6 +24,9 @@ Status Law Assistant is a smart chatbot that answers user questions about Status
|
|
| 24 |
- Context-aware response generation
|
| 25 |
- Multi-language query support (responds in the language of the question)
|
| 26 |
- Customizable text generation parameters (temperature, token count, etc.)
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
## π Technologies
|
| 29 |
|
|
@@ -32,6 +35,8 @@ Status Law Assistant is a smart chatbot that answers user questions about Status
|
|
| 32 |
- **FAISS**: For efficient vector search
|
| 33 |
- **Gradio**: For user interface creation
|
| 34 |
- **BeautifulSoup**: For web page information extraction
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## ποΈ Project Structure
|
| 37 |
|
|
@@ -40,7 +45,7 @@ status-law-gbot/
|
|
| 40 |
βββ app.py # Main application file with interface and request handling logic
|
| 41 |
βββ requirements.txt # Project dependencies
|
| 42 |
βββ config/ # Configuration files
|
| 43 |
-
β βββ settings.py # Application settings
|
| 44 |
β βββ constants.py # Constants and default values
|
| 45 |
βββ src/ # Source code
|
| 46 |
β βββ analytics/ # Analytics module
|
|
@@ -49,9 +54,10 @@ status-law-gbot/
|
|
| 49 |
β β βββ loader.py
|
| 50 |
β β βββ vector_store.py
|
| 51 |
β βββ training/ # Model training module
|
| 52 |
-
β β βββ fine_tuner.py
|
| 53 |
-
β β βββ model_manager.py
|
| 54 |
-
β βββ models/ # Model
|
|
|
|
| 55 |
βββ web/ # Web interface components
|
| 56 |
β βββ training_interface.py
|
| 57 |
βββ data/ # Data storage
|
|
@@ -71,6 +77,10 @@ status-law-gbot/
|
|
| 71 |
### Chat History
|
| 72 |
- `data/chat_history/logs.json`: JSON file containing chat history and metadata
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
## π Usage
|
| 75 |
|
| 76 |
The Status Law Assistant chatbot uses this structure to:
|
|
@@ -78,6 +88,8 @@ The Status Law Assistant chatbot uses this structure to:
|
|
| 78 |
2. Maintain chat history for conversation continuity
|
| 79 |
3. Track user interactions and improve response quality
|
| 80 |
4. Fine-tune models based on conversation history
|
|
|
|
|
|
|
| 81 |
|
| 82 |
## π οΈ Setup
|
| 83 |
|
|
@@ -95,7 +107,7 @@ pip install -r requirements.txt
|
|
| 95 |
3. Set up environment variables:
|
| 96 |
```bash
|
| 97 |
cp .env.example .env
|
| 98 |
-
# Edit .env with your configuration
|
| 99 |
```
|
| 100 |
|
| 101 |
4. Run the application:
|
|
@@ -103,6 +115,35 @@ cp .env.example .env
|
|
| 103 |
python app.py
|
| 104 |
```
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
## π Related Links
|
| 107 |
|
| 108 |
- [Status Law Website](https://status.law)
|
|
|
|
| 24 |
- Context-aware response generation
|
| 25 |
- Multi-language query support (responds in the language of the question)
|
| 26 |
- Customizable text generation parameters (temperature, token count, etc.)
|
| 27 |
+
- Model switching with fallback mechanism
|
| 28 |
+
- Fine-tuning capabilities based on chat history
|
| 29 |
+
- Multiple model support (Llama 2, Zephyr)
|
| 30 |
|
| 31 |
## π Technologies
|
| 32 |
|
|
|
|
| 35 |
- **FAISS**: For efficient vector search
|
| 36 |
- **Gradio**: For user interface creation
|
| 37 |
- **BeautifulSoup**: For web page information extraction
|
| 38 |
+
- **PEFT**: For efficient fine-tuning using LoRA
|
| 39 |
+
- **SentencePiece**: For tokenization
|
| 40 |
|
| 41 |
## ποΈ Project Structure
|
| 42 |
|
|
|
|
| 45 |
βββ app.py # Main application file with interface and request handling logic
|
| 46 |
βββ requirements.txt # Project dependencies
|
| 47 |
βββ config/ # Configuration files
|
| 48 |
+
β βββ settings.py # Application settings and model configurations
|
| 49 |
β βββ constants.py # Constants and default values
|
| 50 |
βββ src/ # Source code
|
| 51 |
β βββ analytics/ # Analytics module
|
|
|
|
| 54 |
β β βββ loader.py
|
| 55 |
β β βββ vector_store.py
|
| 56 |
β βββ training/ # Model training module
|
| 57 |
+
β β βββ fine_tuner.py # LoRA fine-tuning implementation
|
| 58 |
+
β β βββ model_manager.py # Model switching and management
|
| 59 |
+
β βββ models/ # Model storage
|
| 60 |
+
β βββ fine_tuned/ # Fine-tuned model storage
|
| 61 |
βββ web/ # Web interface components
|
| 62 |
β βββ training_interface.py
|
| 63 |
βββ data/ # Data storage
|
|
|
|
| 77 |
### Chat History
|
| 78 |
- `data/chat_history/logs.json`: JSON file containing chat history and metadata
|
| 79 |
|
| 80 |
+
### Models
|
| 81 |
+
- `src/models/fine_tuned/`: Directory for storing fine-tuned models
|
| 82 |
+
- `src/models/registry.json`: Model registry and configuration
|
| 83 |
+
|
| 84 |
## π Usage
|
| 85 |
|
| 86 |
The Status Law Assistant chatbot uses this structure to:
|
|
|
|
| 88 |
2. Maintain chat history for conversation continuity
|
| 89 |
3. Track user interactions and improve response quality
|
| 90 |
4. Fine-tune models based on conversation history
|
| 91 |
+
5. Provide automatic model fallback in case of API errors
|
| 92 |
+
6. Support multiple language models with easy switching
|
| 93 |
|
| 94 |
## π οΈ Setup
|
| 95 |
|
|
|
|
| 107 |
3. Set up environment variables:
|
| 108 |
```bash
|
| 109 |
cp .env.example .env
|
| 110 |
+
# Edit .env with your configuration, including HUGGINGFACE_TOKEN
|
| 111 |
```
|
| 112 |
|
| 113 |
4. Run the application:
|
|
|
|
| 115 |
python app.py
|
| 116 |
```
|
| 117 |
|
| 118 |
+
## π§ Model Fine-tuning
|
| 119 |
+
|
| 120 |
+
To fine-tune the model on your chat history:
|
| 121 |
+
|
| 122 |
+
```python
|
| 123 |
+
from src.training.fine_tuner import finetune_from_chat_history
|
| 124 |
+
|
| 125 |
+
success, message = finetune_from_chat_history(epochs=3)
|
| 126 |
+
print(message)
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
The fine-tuning process uses LoRA (Low-Rank Adaptation) for efficient training with minimal resource requirements.
|
| 130 |
+
|
| 131 |
+
## π Model Switching
|
| 132 |
+
|
| 133 |
+
The application supports multiple models with automatic fallback:
|
| 134 |
+
|
| 135 |
+
- Llama 2 7B Chat (default)
|
| 136 |
+
- Zephyr 7B
|
| 137 |
+
- Custom fine-tuned versions
|
| 138 |
+
|
| 139 |
+
Models can be switched dynamically through the interface or programmatically:
|
| 140 |
+
|
| 141 |
+
```python
|
| 142 |
+
from src.training.model_manager import switch_to_model
|
| 143 |
+
|
| 144 |
+
switch_to_model("llama-7b") # or "zephyr-7b"
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
## π Related Links
|
| 148 |
|
| 149 |
- [Status Law Website](https://status.law)
|