Update README.md
Browse files
README.md
CHANGED
@@ -70,18 +70,20 @@ You can also run this model using the following code:
|
|
70 |
import transformers
|
71 |
from transformers import AutoTokenizer
|
72 |
|
|
|
|
|
73 |
# Format prompt
|
74 |
message = [
|
75 |
{"role": "system", "content": "You are a helpful assistant chatbot."},
|
76 |
{"role": "user", "content": "What is a Large Language Model?"}
|
77 |
]
|
78 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
79 |
prompt = tokenizer.apply_chat_template(message, add_generation_prompt=True, tokenize=False)
|
80 |
|
81 |
# Create pipeline
|
82 |
pipeline = transformers.pipeline(
|
83 |
"text-generation",
|
84 |
-
model=
|
85 |
tokenizer=tokenizer
|
86 |
)
|
87 |
|
@@ -94,7 +96,8 @@ sequences = pipeline(
|
|
94 |
num_return_sequences=1,
|
95 |
max_length=200,
|
96 |
)
|
97 |
-
|
|
|
98 |
|
99 |
|
100 |
# streaming example
|
|
|
70 |
import transformers
|
71 |
from transformers import AutoTokenizer
|
72 |
|
73 |
+
model_id = "halbihn/NeuralHermes-2.5-Mistral-7B"
|
74 |
+
|
75 |
# Format prompt
|
76 |
message = [
|
77 |
{"role": "system", "content": "You are a helpful assistant chatbot."},
|
78 |
{"role": "user", "content": "What is a Large Language Model?"}
|
79 |
]
|
80 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
81 |
prompt = tokenizer.apply_chat_template(message, add_generation_prompt=True, tokenize=False)
|
82 |
|
83 |
# Create pipeline
|
84 |
pipeline = transformers.pipeline(
|
85 |
"text-generation",
|
86 |
+
model=model_id,
|
87 |
tokenizer=tokenizer
|
88 |
)
|
89 |
|
|
|
96 |
num_return_sequences=1,
|
97 |
max_length=200,
|
98 |
)
|
99 |
+
response = sequences[0]['generated_text'].split("<|im_start|>assistant")[-1].strip()
|
100 |
+
print(response)
|
101 |
|
102 |
|
103 |
# streaming example
|