Update README.md
Browse files
README.md
CHANGED
@@ -45,6 +45,7 @@ pipeline_tag: text-generation
|
|
45 |
```python
|
46 |
import torch
|
47 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
|
|
48 |
tokenizer = AutoTokenizer.from_pretrained("upstage/Llama-2-70b-instruct-v2")
|
49 |
model = AutoModelForCausalLM.from_pretrained(
|
50 |
"upstage/Llama-2-70b-instruct-v2",
|
@@ -53,10 +54,12 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
53 |
load_in_8bit=True,
|
54 |
rope_scaling={"type": "dynamic", "factor": 2} # allows handling of longer inputs
|
55 |
)
|
|
|
56 |
prompt = "### User:\nThomas is very healthy, but he has to go to the hospital every day. What could be the reasons?\n\n### Assistant:\n"
|
57 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
58 |
del inputs["token_type_ids"]
|
59 |
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
|
|
60 |
output = model.generate(**inputs, streamer=streamer, use_cache=True, max_new_tokens=float('inf'))
|
61 |
output_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
62 |
```
|
|
|
45 |
```python
|
46 |
import torch
|
47 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
48 |
+
|
49 |
tokenizer = AutoTokenizer.from_pretrained("upstage/Llama-2-70b-instruct-v2")
|
50 |
model = AutoModelForCausalLM.from_pretrained(
|
51 |
"upstage/Llama-2-70b-instruct-v2",
|
|
|
54 |
load_in_8bit=True,
|
55 |
rope_scaling={"type": "dynamic", "factor": 2} # allows handling of longer inputs
|
56 |
)
|
57 |
+
|
58 |
prompt = "### User:\nThomas is very healthy, but he has to go to the hospital every day. What could be the reasons?\n\n### Assistant:\n"
|
59 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
60 |
del inputs["token_type_ids"]
|
61 |
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
62 |
+
|
63 |
output = model.generate(**inputs, streamer=streamer, use_cache=True, max_new_tokens=float('inf'))
|
64 |
output_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
65 |
```
|