Update README.md
Browse files
README.md
CHANGED
|
@@ -33,6 +33,33 @@ Raises:
|
|
| 33 |
|
| 34 |
For more information on my dataset, please see the included referenced dataset.
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# Hyperparameters
|
| 37 |
|
| 38 |
MAX_SOURCE_LENGTH = 256 <br>
|
|
|
|
| 33 |
|
| 34 |
For more information on my dataset, please see the included referenced dataset.
|
| 35 |
|
| 36 |
+
You can test the model using this:
|
| 37 |
+
|
| 38 |
+
```
|
| 39 |
+
from transformers import T5ForConditionalGeneration, AutoTokenizer
|
| 40 |
+
|
| 41 |
+
checkpoint = "Mir-2002/codet5p-google-style-docstrings"
|
| 42 |
+
device = "cuda" # or CPU
|
| 43 |
+
|
| 44 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 45 |
+
model = T5ForConditionalGeneration.from_pretrained(checkpoint).to(device)
|
| 46 |
+
|
| 47 |
+
input = """
|
| 48 |
+
def calculate_sum(a, b):
|
| 49 |
+
return a + b
|
| 50 |
+
"""
|
| 51 |
+
|
| 52 |
+
inputs = tokenizer.encode(input, return_tensors="pt").to(device)
|
| 53 |
+
outputs = model.generate(inputs, max_length=128)
|
| 54 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 55 |
+
# Calculate the sum of two numbers.
|
| 56 |
+
|
| 57 |
+
# Args:
|
| 58 |
+
# a (int): The first number.
|
| 59 |
+
# b (int): The second number.
|
| 60 |
+
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
# Hyperparameters
|
| 64 |
|
| 65 |
MAX_SOURCE_LENGTH = 256 <br>
|