Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,8 @@ tokenizer = AutoTokenizer.from_pretrained(model_path)
|
|
17 |
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
18 |
model = AutoModelForCausalLM.from_pretrained(model_path, device_map='cuda', quantization_config=quantization_config)
|
19 |
rm_tokenizer = AutoTokenizer.from_pretrained('OpenAssistant/reward-model-deberta-v3-large-v2')
|
20 |
-
rm_model = AutoModelForSequenceClassification.from_pretrained('OpenAssistant/reward-model-deberta-v3-large-v2', torch_dtype=torch.bfloat16)
|
|
|
21 |
|
22 |
@spaces.GPU
|
23 |
def generate_text(usertitle, content, temperature, max_length, N=3):
|
@@ -30,6 +31,8 @@ def generate_text(usertitle, content, temperature, max_length, N=3):
|
|
30 |
def score(sequence):
|
31 |
inputs = rm_tokenizer(sequence, return_tensors='pt', padding=True, truncation=True, max_length=512).to('cuda')
|
32 |
inputs = {k: v.to('cuda') for k, v in inputs.items()}
|
|
|
|
|
33 |
with torch.no_grad():
|
34 |
outputs = rm_model(**inputs)
|
35 |
logits = outputs.logits
|
|
|
17 |
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
18 |
model = AutoModelForCausalLM.from_pretrained(model_path, device_map='cuda', quantization_config=quantization_config)
|
19 |
rm_tokenizer = AutoTokenizer.from_pretrained('OpenAssistant/reward-model-deberta-v3-large-v2')
|
20 |
+
rm_model = AutoModelForSequenceClassification.from_pretrained('OpenAssistant/reward-model-deberta-v3-large-v2', device_map='cuda', torch_dtype=torch.bfloat16)
|
21 |
+
|
22 |
|
23 |
@spaces.GPU
|
24 |
def generate_text(usertitle, content, temperature, max_length, N=3):
|
|
|
31 |
def score(sequence):
|
32 |
inputs = rm_tokenizer(sequence, return_tensors='pt', padding=True, truncation=True, max_length=512).to('cuda')
|
33 |
inputs = {k: v.to('cuda') for k, v in inputs.items()}
|
34 |
+
# print(rm_model.device)
|
35 |
+
# print(inputs['input_ids'].device)
|
36 |
with torch.no_grad():
|
37 |
outputs = rm_model(**inputs)
|
38 |
logits = outputs.logits
|