Spaces:
Build error
Build error
Wisdom Chen
commited on
Update model.py
Browse files
model.py
CHANGED
@@ -24,7 +24,7 @@ from transformers import (
|
|
24 |
PreTrainedModel,
|
25 |
PreTrainedTokenizer
|
26 |
)
|
27 |
-
from huggingface_hub import hf_hub_download
|
28 |
from langchain.prompts import PromptTemplate
|
29 |
|
30 |
# Vector database
|
@@ -72,12 +72,15 @@ def initialize_models() -> bool:
|
|
72 |
|
73 |
# Initialize LLM with optimized settings
|
74 |
try:
|
|
|
|
|
75 |
model_name = "mistralai/Mistral-7B-v0.1"
|
76 |
quantization_config = BitsAndBytesConfig(
|
77 |
load_in_4bit=True,
|
78 |
bnb_4bit_compute_dtype=torch.float16,
|
79 |
bnb_4bit_use_double_quant=True,
|
80 |
-
bnb_4bit_quant_type="nf4"
|
|
|
81 |
)
|
82 |
|
83 |
llm_tokenizer = AutoTokenizer.from_pretrained(
|
|
|
24 |
PreTrainedModel,
|
25 |
PreTrainedTokenizer
|
26 |
)
|
27 |
+
from huggingface_hub import hf_hub_download, login
|
28 |
from langchain.prompts import PromptTemplate
|
29 |
|
30 |
# Vector database
|
|
|
72 |
|
73 |
# Initialize LLM with optimized settings
|
74 |
try:
|
75 |
+
if "HF_TOKEN" in os.environ:
|
76 |
+
login(token=os.environ["HF_TOKEN"])
|
77 |
model_name = "mistralai/Mistral-7B-v0.1"
|
78 |
quantization_config = BitsAndBytesConfig(
|
79 |
load_in_4bit=True,
|
80 |
bnb_4bit_compute_dtype=torch.float16,
|
81 |
bnb_4bit_use_double_quant=True,
|
82 |
+
bnb_4bit_quant_type="nf4",
|
83 |
+
token=os.environ.get("HF_TOKEN")
|
84 |
)
|
85 |
|
86 |
llm_tokenizer = AutoTokenizer.from_pretrained(
|