Last active
August 9, 2021 19:32
-
-
Save zacc/40f618b76bd26db2664409b76ed74cff to your computer and use it in GitHub Desktop.
run transformers gpt-2 locally to test output
This file contains hidden or 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
from simpletransformers.language_generation import LanguageGenerationModel, LanguageGenerationArgs | |
def main(): | |
model_path = "models/<model_folder>/" | |
model = LanguageGenerationModel("gpt2", model_path, args={'fp16': False, 'cache_dir': f"{model_path}.cache/"}, use_cuda=False) | |
args = { | |
'max_length': 1000, | |
'num_return_sequences': 10, | |
'repetition_penalty': 1.01, | |
'stop_token': '<|endoftext|>', | |
'temperature': 0.8, | |
'top_k': 40, | |
} | |
prefix = '<|soss|><|sot|>' | |
for text in model.generate(prompt=prefix, args=args, verbose=True): | |
print("<<<<<<<<") | |
print(text) | |
continue | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment