Deva1211 commited on
Commit
c422049
·
1 Parent(s): b8dd0f7

Switched to resolving issues

Browse files
alternative_requirements.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===== OPTION 1: For Hugging Face Spaces (Recommended) =====
2
+ # Use this in your main requirements.txt file
3
+ torch>=2.0.0,<2.2.0
4
+ transformers>=4.35.0,<4.40.0
5
+ accelerate>=0.20.0
6
+ gradio>=3.50.0,<4.0.0
7
+ bitsandbytes>=0.41.0
8
+
9
+ # ===== OPTION 2: For Local Development with AutoAWQ =====
10
+ # If you want to try AutoAWQ locally, use this setup:
11
+ # Step 1: Install core dependencies first
12
+ # pip install torch>=2.0.0,<2.2.0 transformers>=4.35.0,<4.40.0 accelerate>=0.20.0
13
+ # Step 2: Install AutoAWQ
14
+ # pip install autoawq>=0.1.8
15
+ # Step 3: Install Gradio
16
+ # pip install gradio>=3.50.0,<4.0.0
17
+
18
+ # ===== OPTION 3: For CPU-only deployment =====
19
+ # torch>=2.0.0,<2.2.0 --index-url https://download.pytorch.org/whl/cpu
20
+ # transformers>=4.35.0,<4.40.0
21
+ # gradio>=3.50.0,<4.0.0
22
+
23
+ # ===== OPTION 4: Alternative with different quantization =====
24
+ # torch>=2.0.0,<2.2.0
25
+ # transformers>=4.35.0,<4.40.0
26
+ # optimum>=1.16.0
27
+ # auto-gptq>=0.6.0
28
+ # gradio>=3.50.0,<4.0.0
app.py CHANGED
@@ -5,13 +5,28 @@ import re
5
 
6
  # Load model and tokenizer
7
  print("Loading Mistral-7B-Instruct AWQ...")
8
- tokenizer = AutoTokenizer.from_pretrained("TheBloke/Mistral-7B-Instruct-v0.2-AWQ", trust_remote_code=True)
9
- model = AutoModelForCausalLM.from_pretrained(
10
- "TheBloke/Mistral-7B-Instruct-v0.2-AWQ",
11
- device_map="auto",
12
- trust_remote_code=True,
13
- torch_dtype=torch.float16
14
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  # Add pad token if it doesn't exist
17
  if tokenizer.pad_token is None:
 
5
 
6
  # Load model and tokenizer
7
  print("Loading Mistral-7B-Instruct AWQ...")
8
+
9
+ # Try AWQ model first, fallback to regular model if needed
10
+ try:
11
+ tokenizer = AutoTokenizer.from_pretrained("TheBloke/Mistral-7B-Instruct-v0.2-AWQ")
12
+ model = AutoModelForCausalLM.from_pretrained(
13
+ "TheBloke/Mistral-7B-Instruct-v0.2-AWQ",
14
+ device_map="auto",
15
+ torch_dtype=torch.float16,
16
+ low_cpu_mem_usage=True
17
+ )
18
+ print("✅ AWQ model loaded successfully!")
19
+ except Exception as e:
20
+ print(f"⚠️ AWQ model failed to load: {e}")
21
+ print("📦 Falling back to regular Mistral-7B-Instruct-v0.2...")
22
+ tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
23
+ model = AutoModelForCausalLM.from_pretrained(
24
+ "mistralai/Mistral-7B-Instruct-v0.2",
25
+ device_map="auto",
26
+ torch_dtype=torch.float16,
27
+ low_cpu_mem_usage=True
28
+ )
29
+ print("✅ Regular model loaded successfully!")
30
 
31
  # Add pad token if it doesn't exist
32
  if tokenizer.pad_token is None:
install_local.bat ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ echo ============================================
3
+ echo Installing Mistral AWQ Chatbot Dependencies
4
+ echo ============================================
5
+
6
+ echo.
7
+ echo Step 1: Installing core dependencies...
8
+ pip install torch>=2.0.0,<2.2.0 transformers>=4.35.0,<4.40.0 accelerate>=0.20.0
9
+
10
+ echo.
11
+ echo Step 2: Installing AutoAWQ...
12
+ pip install autoawq>=0.1.8
13
+
14
+ echo.
15
+ echo Step 3: Installing Gradio...
16
+ pip install gradio>=3.50.0,<4.0.0
17
+
18
+ echo.
19
+ echo ============================================
20
+ echo Installation Complete!
21
+ echo ============================================
22
+ echo.
23
+ echo To test the installation, run:
24
+ echo python test_model.py
25
+ echo.
26
+ echo To start the chatbot, run:
27
+ echo python app.py
28
+ pause
install_local.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ echo "============================================"
4
+ echo "Installing Mistral AWQ Chatbot Dependencies"
5
+ echo "============================================"
6
+
7
+ echo ""
8
+ echo "Step 1: Installing core dependencies..."
9
+ pip install "torch>=2.0.0,<2.2.0" "transformers>=4.35.0,<4.40.0" "accelerate>=0.20.0"
10
+
11
+ echo ""
12
+ echo "Step 2: Installing AutoAWQ..."
13
+ pip install "autoawq>=0.1.8"
14
+
15
+ echo ""
16
+ echo "Step 3: Installing Gradio..."
17
+ pip install "gradio>=3.50.0,<4.0.0"
18
+
19
+ echo ""
20
+ echo "============================================"
21
+ echo "Installation Complete!"
22
+ echo "============================================"
23
+ echo ""
24
+ echo "To test the installation, run:"
25
+ echo "python test_model.py"
26
+ echo ""
27
+ echo "To start the chatbot, run:"
28
+ echo "python app.py"
requirements.txt CHANGED
@@ -1,5 +1,6 @@
1
  torch>=2.0.0,<2.2.0
2
  transformers>=4.35.0,<4.40.0
3
- autoawq>=0.1.8
4
  accelerate>=0.20.0
5
  gradio>=3.50.0,<4.0.0
 
 
 
1
  torch>=2.0.0,<2.2.0
2
  transformers>=4.35.0,<4.40.0
 
3
  accelerate>=0.20.0
4
  gradio>=3.50.0,<4.0.0
5
+ # Use bitsandbytes for quantization support - more compatible with HF Spaces
6
+ bitsandbytes>=0.41.0
test_model.py CHANGED
@@ -9,14 +9,27 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
9
  def test_model():
10
  print("Loading Mistral-7B-Instruct AWQ for testing...")
11
 
12
- # Load model and tokenizer
13
- tokenizer = AutoTokenizer.from_pretrained("TheBloke/Mistral-7B-Instruct-v0.2-AWQ", trust_remote_code=True)
14
- model = AutoModelForCausalLM.from_pretrained(
15
- "TheBloke/Mistral-7B-Instruct-v0.2-AWQ",
16
- device_map="auto",
17
- trust_remote_code=True,
18
- torch_dtype=torch.float16
19
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  if tokenizer.pad_token is None:
22
  tokenizer.pad_token = tokenizer.eos_token
 
9
  def test_model():
10
  print("Loading Mistral-7B-Instruct AWQ for testing...")
11
 
12
+ # Try AWQ model first, fallback to regular model if needed
13
+ try:
14
+ tokenizer = AutoTokenizer.from_pretrained("TheBloke/Mistral-7B-Instruct-v0.2-AWQ")
15
+ model = AutoModelForCausalLM.from_pretrained(
16
+ "TheBloke/Mistral-7B-Instruct-v0.2-AWQ",
17
+ device_map="auto",
18
+ torch_dtype=torch.float16,
19
+ low_cpu_mem_usage=True
20
+ )
21
+ print("✅ AWQ model loaded successfully!")
22
+ except Exception as e:
23
+ print(f"⚠️ AWQ model failed to load: {e}")
24
+ print("📦 Falling back to regular Mistral-7B-Instruct-v0.2...")
25
+ tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
26
+ model = AutoModelForCausalLM.from_pretrained(
27
+ "mistralai/Mistral-7B-Instruct-v0.2",
28
+ device_map="auto",
29
+ torch_dtype=torch.float16,
30
+ low_cpu_mem_usage=True
31
+ )
32
+ print("✅ Regular model loaded successfully!")
33
 
34
  if tokenizer.pad_token is None:
35
  tokenizer.pad_token = tokenizer.eos_token