Mr-Vicky-01
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -8,7 +8,7 @@ pip install transformers[torch]
|
|
8 |
```
|
9 |
|
10 |
```python
|
11 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
12 |
import torch
|
13 |
import time
|
14 |
|
@@ -19,17 +19,31 @@ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
|
19 |
|
20 |
question = "How many Vulnerability found today"
|
21 |
db_result = "243"
|
22 |
-
summ_inp = f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
import time
|
25 |
start = time.time()
|
26 |
|
27 |
-
|
28 |
model.to(device)
|
29 |
inputs = inputs.to(device)
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
end = time.time()
|
35 |
print(f"Time taken: {end - start}")
|
|
|
8 |
```
|
9 |
|
10 |
```python
|
11 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
|
12 |
import torch
|
13 |
import time
|
14 |
|
|
|
19 |
|
20 |
question = "How many Vulnerability found today"
|
21 |
db_result = "243"
|
22 |
+
summ_inp = f"""<|im_start|>system
|
23 |
+
Generate a clear and accurate response based on the user's question and the database output.<|im_end|>
|
24 |
+
<|im_start|>user
|
25 |
+
user_question:
|
26 |
+
{question}
|
27 |
+
db_response:
|
28 |
+
{db_result}<|im_end|>
|
29 |
+
<|im_start|>assistant"""
|
30 |
|
31 |
import time
|
32 |
start = time.time()
|
33 |
|
34 |
+
encodeds = tokenizer(summ_inp, return_tensors="pt",truncation=True).input_ids.to(device)
|
35 |
model.to(device)
|
36 |
inputs = inputs.to(device)
|
37 |
+
text_streamer = TextStreamer(tokenizer, skip_prompt = True)
|
38 |
+
response = finetuned_model.generate(
|
39 |
+
input_ids=encodeds,
|
40 |
+
streamer=text_streamer,
|
41 |
+
max_new_tokens=512,
|
42 |
+
use_cache=True,
|
43 |
+
pad_token_id=151645,
|
44 |
+
eos_token_id=151645,
|
45 |
+
num_return_sequences=1
|
46 |
+
)
|
47 |
|
48 |
end = time.time()
|
49 |
print(f"Time taken: {end - start}")
|