BramVanroy
commited on
Commit
·
5d476c4
1
Parent(s):
290ecb9
Update README.md
Browse files
README.md
CHANGED
@@ -46,14 +46,31 @@ from transformers import pipeline
|
|
46 |
|
47 |
# If you want to add a system message, add a dictionary with role "system". However, this will likely have little
|
48 |
# effect since the model was only finetuned using a single system message.
|
49 |
-
messages = [
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
# Just apply the template but leave the tokenization for the pipeline to do
|
53 |
-
prompt = pipe.tokenizer.apply_chat_template(
|
|
|
|
|
|
|
54 |
|
55 |
# Only return the newly generated tokens, not prompt+new_tokens (return_full_text=False)
|
56 |
-
generated = pipe(
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
generated[0]["generated_text"]
|
59 |
# ' De officiële talen van België zijn Nederlands, Frans en Duits. Daarnaast worden er nog een aantal andere talen gesproken, waaronder Engels, Spaans, Italiaans, Portugees, Turks, Arabisch en veel meer. '
|
|
|
46 |
|
47 |
# If you want to add a system message, add a dictionary with role "system". However, this will likely have little
|
48 |
# effect since the model was only finetuned using a single system message.
|
49 |
+
messages = [
|
50 |
+
{
|
51 |
+
"role": "user",
|
52 |
+
"content": "Welke talen worden er in België gesproken?"
|
53 |
+
}
|
54 |
+
]
|
55 |
+
pipe = pipeline(
|
56 |
+
"text-generation",
|
57 |
+
model="BramVanroy/Llama-2-13b-chat-dutch",
|
58 |
+
device_map="auto"
|
59 |
+
)
|
60 |
|
61 |
# Just apply the template but leave the tokenization for the pipeline to do
|
62 |
+
prompt = pipe.tokenizer.apply_chat_template(
|
63 |
+
messages,
|
64 |
+
tokenize=False
|
65 |
+
)
|
66 |
|
67 |
# Only return the newly generated tokens, not prompt+new_tokens (return_full_text=False)
|
68 |
+
generated = pipe(
|
69 |
+
prompt,
|
70 |
+
do_sample=True,
|
71 |
+
max_new_tokens=128,
|
72 |
+
return_full_text=False
|
73 |
+
)
|
74 |
|
75 |
generated[0]["generated_text"]
|
76 |
# ' De officiële talen van België zijn Nederlands, Frans en Duits. Daarnaast worden er nog een aantal andere talen gesproken, waaronder Engels, Spaans, Italiaans, Portugees, Turks, Arabisch en veel meer. '
|