Rulga commited on
Commit
a442043
Β·
1 Parent(s): b733726

Update README to include model switching, fine-tuning capabilities, and new model support

Browse files
Files changed (1) hide show
  1. README.md +46 -5
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-related code
 
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)