-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffcfb53
commit da089fe
Showing
10 changed files
with
16,451 additions
and
93 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,31 +3,13 @@ | |
@author:XuMing([email protected]) | ||
@description: | ||
""" | ||
import argparse | ||
import sys | ||
import torch | ||
|
||
sys.path.append('..') | ||
from autocomplete.gpt2 import Infer | ||
|
||
use_cuda = torch.cuda.is_available() | ||
if __name__ == '__main__': | ||
prompts = [ | ||
"""from torch import nn | ||
class LSTM(Module): | ||
def __init__(self, *, | ||
n_tokens: int, | ||
embedding_size: int, | ||
hidden_size: int, | ||
n_layers: int):""", | ||
"""import numpy as np | ||
import torch | ||
import torch.nn as""", | ||
"import java.util.ArrayList", | ||
] | ||
infer = Infer(model_name="gpt2", model_dir="shibing624/code-autocomplete-gpt2-base", use_cuda=use_cuda) | ||
for prompt in prompts: | ||
res = infer.predict(prompt) | ||
print("Query:", prompt) | ||
print("Result:", res) | ||
print("=" * 20) | ||
m = Infer(model_name="gpt2", model_dir="shibing624/code-autocomplete-gpt2-base", use_cuda=use_cuda) | ||
i = m.predict('import torch.nn as') | ||
print(i) |
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
Oops, something went wrong.