Last active
March 22, 2021 13:38
-
-
Save kristjan-eljand/2fa2da81b3170e951f48e4c34fe8d8d0 to your computer and use it in GitHub Desktop.
model inference on single core
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function that carries out model inference and return generated text | |
def continue_text(beginning): | |
text = generator(beginning, max_length=30, num_return_sequences=1) | |
return text[0]['generated_text'] | |
start = time.time() | |
# Generate text for all beginnings | |
results = [continue_text(beginning) for beginning in sentence_beginnings] | |
print("duration =", time.time() - start) | |
print(results) | |
# Output: | |
# duration = 4.240295648574829 | |
# In Estonia, our main source of energy is electricity - it’s power... | |
# The main task of the technology scout is to identify the types of objects in the environment and use them to check the distance between them.... | |
# Renewable energy is important because it lowers costs in the market but is also a much more reliable fuel... | |
# Electric Vehicles are changing the legal status of vehicle ownership... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment