Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import pipeline, BitsAndBytesConfig
|
| 3 |
import PyPDF2
|
| 4 |
import io
|
| 5 |
import re
|
|
@@ -21,15 +21,24 @@ quant_config = BitsAndBytesConfig(
|
|
| 21 |
bnb_4bit_quant_type="nf4"
|
| 22 |
)
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
device_map="auto",
|
| 29 |
quantization_config=quant_config,
|
| 30 |
torch_dtype=torch.float16
|
| 31 |
)
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Skills set for faster lookups
|
| 34 |
GENERAL_SKILLS = {
|
| 35 |
'communication', 'problem solving', 'project management',
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline, BitsAndBytesConfig, AutoModelForCausalLM, AutoTokenizer
|
| 3 |
import PyPDF2
|
| 4 |
import io
|
| 5 |
import re
|
|
|
|
| 21 |
bnb_4bit_quant_type="nf4"
|
| 22 |
)
|
| 23 |
|
| 24 |
+
# Load tokenizer and model with quantization
|
| 25 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.3")
|
| 26 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 27 |
+
"mistralai/Mistral-7B-Instruct-v0.3",
|
| 28 |
device_map="auto",
|
| 29 |
quantization_config=quant_config,
|
| 30 |
torch_dtype=torch.float16
|
| 31 |
)
|
| 32 |
|
| 33 |
+
# Initialize pipeline with preloaded model and tokenizer
|
| 34 |
+
analyzer = pipeline(
|
| 35 |
+
"text-generation",
|
| 36 |
+
model=model,
|
| 37 |
+
tokenizer=tokenizer,
|
| 38 |
+
device_map="auto", # Still respected from model
|
| 39 |
+
torch_dtype=torch.float16
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
# Skills set for faster lookups
|
| 43 |
GENERAL_SKILLS = {
|
| 44 |
'communication', 'problem solving', 'project management',
|