Update README.md
Browse files
README.md
CHANGED
|
@@ -54,12 +54,12 @@ metrics:
|
|
| 54 |
|
| 55 |
```python
|
| 56 |
def get_question(context, answer):
|
| 57 |
-
device = next(
|
| 58 |
input_text = f"Given the context '{context}' and the answer '{answer}', what question can be asked?"
|
| 59 |
-
encoding =
|
| 60 |
|
| 61 |
-
output_tokens =
|
| 62 |
-
out =
|
| 63 |
|
| 64 |
return out
|
| 65 |
```
|
|
|
|
| 54 |
|
| 55 |
```python
|
| 56 |
def get_question(context, answer):
|
| 57 |
+
device = next(QG_model.parameters()).device
|
| 58 |
input_text = f"Given the context '{context}' and the answer '{answer}', what question can be asked?"
|
| 59 |
+
encoding = QG_tokenizer.encode_plus(input_text, padding=True, return_tensors="pt").to(device)
|
| 60 |
|
| 61 |
+
output_tokens = QG_model.generate(**encoding, early_stopping=True, num_beams=5, num_return_sequences=1, no_repeat_ngram_size=2, max_length=100)
|
| 62 |
+
out = QG_tokenizer.decode(output_tokens[0], skip_special_tokens=True).replace("question:", "").strip()
|
| 63 |
|
| 64 |
return out
|
| 65 |
```
|