Spaces:
Runtime error
Runtime error
changed decorator to prepare_model
Browse files- sotopia_generate.py +4 -3
sotopia_generate.py
CHANGED
|
@@ -82,6 +82,7 @@ def generate_action(
|
|
| 82 |
# return AgentAction(action_type="none", argument="")
|
| 83 |
|
| 84 |
@cache
|
|
|
|
| 85 |
def prepare_model(model_name):
|
| 86 |
compute_type = torch.float16
|
| 87 |
|
|
@@ -90,7 +91,7 @@ def prepare_model(model_name):
|
|
| 90 |
model = AutoModelForCausalLM.from_pretrained(
|
| 91 |
"mistralai/Mistral-7B-Instruct-v0.1",
|
| 92 |
cache_dir="./.cache",
|
| 93 |
-
|
| 94 |
)
|
| 95 |
model = PeftModel.from_pretrained(model, model_name).to("cuda")
|
| 96 |
|
|
@@ -99,7 +100,7 @@ def prepare_model(model_name):
|
|
| 99 |
model = AutoModelForCausalLM.from_pretrained(
|
| 100 |
"mistralai/Mistral-7B-Instruct-v0.1",
|
| 101 |
cache_dir="./.cache",
|
| 102 |
-
|
| 103 |
quantization_config=BitsAndBytesConfig(
|
| 104 |
load_in_4bit=True,
|
| 105 |
bnb_4bit_use_double_quant=True,
|
|
@@ -149,7 +150,7 @@ def obtain_chain_hf(
|
|
| 149 |
chain = LLMChain(llm=hf, prompt=chat_prompt_template)
|
| 150 |
return chain
|
| 151 |
|
| 152 |
-
|
| 153 |
def generate(
|
| 154 |
model_name: str,
|
| 155 |
template: str,
|
|
|
|
| 82 |
# return AgentAction(action_type="none", argument="")
|
| 83 |
|
| 84 |
@cache
|
| 85 |
+
@spaces.GPU(600)
|
| 86 |
def prepare_model(model_name):
|
| 87 |
compute_type = torch.float16
|
| 88 |
|
|
|
|
| 91 |
model = AutoModelForCausalLM.from_pretrained(
|
| 92 |
"mistralai/Mistral-7B-Instruct-v0.1",
|
| 93 |
cache_dir="./.cache",
|
| 94 |
+
device_map='cuda'
|
| 95 |
)
|
| 96 |
model = PeftModel.from_pretrained(model, model_name).to("cuda")
|
| 97 |
|
|
|
|
| 100 |
model = AutoModelForCausalLM.from_pretrained(
|
| 101 |
"mistralai/Mistral-7B-Instruct-v0.1",
|
| 102 |
cache_dir="./.cache",
|
| 103 |
+
device_map='cuda',
|
| 104 |
quantization_config=BitsAndBytesConfig(
|
| 105 |
load_in_4bit=True,
|
| 106 |
bnb_4bit_use_double_quant=True,
|
|
|
|
| 150 |
chain = LLMChain(llm=hf, prompt=chat_prompt_template)
|
| 151 |
return chain
|
| 152 |
|
| 153 |
+
|
| 154 |
def generate(
|
| 155 |
model_name: str,
|
| 156 |
template: str,
|