Skip to content

Instantly share code, notes, and snippets.

@kristjan-eljand
Last active March 22, 2021 13:38
Show Gist options
  • Save kristjan-eljand/2fa2da81b3170e951f48e4c34fe8d8d0 to your computer and use it in GitHub Desktop.
Save kristjan-eljand/2fa2da81b3170e951f48e4c34fe8d8d0 to your computer and use it in GitHub Desktop.
model inference on single core
# 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