m-polignano-uniba
commited on
Commit
•
dd53ae4
1
Parent(s):
addf22e
Update README.md
Browse files
README.md
CHANGED
@@ -68,11 +68,25 @@ prompt = " [INST]<<SYS>>\n" \
|
|
68 |
"Se una domanda non ha senso o non e' coerente con i fatti, spiegane il motivo invece di rispondere in modo non corretto. " \
|
69 |
"Se non conosci la risposta a una domanda, non condividere informazioni false.\n" \
|
70 |
"<</SYS>>\n\n" \
|
71 |
-
f"{user_msg}[/INST]
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
|
74 |
-
outputs = model.generate(input_ids=input_ids, max_length=
|
75 |
-
|
76 |
print(tokenizer.batch_decode(outputs.detach().cpu().numpy()[:, input_ids.shape[1]:], skip_special_tokens=True)[0])
|
77 |
```
|
78 |
|
|
|
68 |
"Se una domanda non ha senso o non e' coerente con i fatti, spiegane il motivo invece di rispondere in modo non corretto. " \
|
69 |
"Se non conosci la risposta a una domanda, non condividere informazioni false.\n" \
|
70 |
"<</SYS>>\n\n" \
|
71 |
+
f"{user_msg}[/INST]"
|
72 |
+
|
73 |
+
pipe = transformers.pipeline(
|
74 |
+
model=model,
|
75 |
+
tokenizer=tokenizer,
|
76 |
+
return_full_text=False, # langchain expects the full text
|
77 |
+
task='text-generation',
|
78 |
+
max_new_tokens=512, # max number of tokens to generate in the output
|
79 |
+
temperature=0.8 #temperature for more or less creative answers
|
80 |
+
)
|
81 |
+
|
82 |
+
# Method 1
|
83 |
+
sequences = pipe(text)
|
84 |
+
for seq in sequences:
|
85 |
+
print(f"{seq['generated_text']}")
|
86 |
+
|
87 |
+
# Method 2
|
88 |
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
|
89 |
+
outputs = model.generate(input_ids=input_ids, max_length=512)
|
|
|
90 |
print(tokenizer.batch_decode(outputs.detach().cpu().numpy()[:, input_ids.shape[1]:], skip_special_tokens=True)[0])
|
91 |
```
|
92 |
|