Spaces:
Paused
Paused
truongghieu
commited on
Commit
•
c22d12b
1
Parent(s):
e602433
Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,11 @@ bnb_config = BitsAndBytesConfig(
|
|
12 |
)
|
13 |
|
14 |
|
15 |
-
tokenizer = AutoTokenizer.from_pretrained("truongghieu/deci-finetuned", trust_remote_code=True)
|
16 |
# Load model in this way if use GPU
|
17 |
-
|
18 |
|
19 |
-
model = AutoModelForCausalLM.from_pretrained("truongghieu/deci-finetuned", trust_remote_code=True)
|
20 |
# Move the model to the GPU if available
|
21 |
|
22 |
generation_config = GenerationConfig(
|
@@ -34,7 +34,7 @@ generation_config = GenerationConfig(
|
|
34 |
# Define a function that takes a text input and generates a text output
|
35 |
def generate_text(text):
|
36 |
input_text = f'###Human: \"{text}\"'
|
37 |
-
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
38 |
output_ids = model.generate(input_ids, generation_config=generation_config)
|
39 |
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
40 |
return output_text
|
|
|
12 |
)
|
13 |
|
14 |
|
15 |
+
tokenizer = AutoTokenizer.from_pretrained("truongghieu/deci-finetuned", trust_remote_code=True).to(device)
|
16 |
# Load model in this way if use GPU
|
17 |
+
model = AutoModelForCausalLM.from_pretrained("truongghieu/deci-finetuned", trust_remote_code=True, quantization_config=bnb_config).to(device)
|
18 |
|
19 |
+
# model = AutoModelForCausalLM.from_pretrained("truongghieu/deci-finetuned", trust_remote_code=True)
|
20 |
# Move the model to the GPU if available
|
21 |
|
22 |
generation_config = GenerationConfig(
|
|
|
34 |
# Define a function that takes a text input and generates a text output
|
35 |
def generate_text(text):
|
36 |
input_text = f'###Human: \"{text}\"'
|
37 |
+
input_ids = tokenizer.encode(input_text, return_tensors="pt").to(device)
|
38 |
output_ids = model.generate(input_ids, generation_config=generation_config)
|
39 |
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
40 |
return output_text
|