Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,46 +25,19 @@ import transformers
|
|
25 |
model_name='mistralai/Mistral-7B-Instruct-v0.1'
|
26 |
from huggingface_hub import login
|
27 |
login(token=st.secrets["HF_TOKEN"])
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
#
|
40 |
-
|
41 |
-
|
42 |
-
# Compute dtype for 4-bit base models
|
43 |
-
bnb_4bit_compute_dtype = "float16"
|
44 |
-
|
45 |
-
# Quantization type (fp4 or nf4)
|
46 |
-
bnb_4bit_quant_type = "nf4"
|
47 |
-
|
48 |
-
# Activate nested quantization for 4-bit base models (double quantization)
|
49 |
-
use_nested_quant = False
|
50 |
-
#################################################################
|
51 |
-
# Set up quantization config
|
52 |
-
#################################################################
|
53 |
-
compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
|
54 |
-
|
55 |
-
bnb_config = BitsAndBytesConfig(
|
56 |
-
load_in_4bit=use_4bit,
|
57 |
-
bnb_4bit_quant_type=bnb_4bit_quant_type,
|
58 |
-
bnb_4bit_compute_dtype=compute_dtype,
|
59 |
-
bnb_4bit_use_double_quant=use_nested_quant,
|
60 |
-
)
|
61 |
-
|
62 |
-
#############################################################
|
63 |
-
# Load pre-trained config
|
64 |
-
#################################################################
|
65 |
-
model = AutoModelForCausalLM.from_pretrained(
|
66 |
-
"mistralai/Mistral-7B-Instruct-v0.1",quantization_config=bnb_config,
|
67 |
-
)
|
68 |
dataset= load_dataset("mery22/testub/test-1.pdf")
|
69 |
loader = PyPDFLoader(dataset)
|
70 |
data = loader.load()
|
|
|
25 |
model_name='mistralai/Mistral-7B-Instruct-v0.1'
|
26 |
from huggingface_hub import login
|
27 |
login(token=st.secrets["HF_TOKEN"])
|
28 |
+
from ctransformers import AutoModelForCausalLM, AutoTokenizer
|
29 |
+
|
30 |
+
# model loading.
|
31 |
+
model = AutoModelForCausalLM.from_pretrained("TheBloke/Mistral-7B-Instruct-v0.1-GGUF",
|
32 |
+
model_file="mistral-7b-instruct-v0.1.Q5_K_M.gguf",
|
33 |
+
model_type="mistral",
|
34 |
+
max_new_tokens=1048,
|
35 |
+
temperature=0.00,
|
36 |
+
hf=True
|
37 |
+
)
|
38 |
+
|
39 |
+
#initializes a tokenizer for the specified LLM model.
|
40 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
dataset= load_dataset("mery22/testub/test-1.pdf")
|
42 |
loader = PyPDFLoader(dataset)
|
43 |
data = loader.load()
|