Skip to content

Commit 62214f0

Browse files
ospillingervishalbollu
authored andcommitted
Add search completion example
(cherry picked from commit 15aeb5f)
1 parent 852c74a commit 62214f0

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

examples/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
- [Iris classification](pytorch/iris-classifier): deploy a model to classify iris flowers.
1616

17+
- [Search completion](pytorch/search-completer): deploy a model to complete search terms.
18+
1719
- [Text generation with DistilGPT2](pytorch/text-generator): deploy Hugging Face's DistilGPT2 model to generate text.
1820

1921
- [Answer generation with DialoGPT](pytorch/answer-generator): deploy Microsoft's DialoGPT model to answer questions.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- kind: deployment
2+
name: search
3+
4+
- kind: api
5+
name: completer
6+
predictor:
7+
path: predictor.py
8+
compute:
9+
cpu: 1
10+
gpu: 1
11+
mem: 4G
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import torch
2+
import regex
3+
import tqdm
4+
5+
roberta = torch.hub.load("pytorch/fairseq", "roberta.large")
6+
roberta.eval()
7+
roberta.cuda()
8+
9+
10+
def predict(sample, metadata):
11+
predictions = roberta.fill_mask(sample["text"] + " <mask>", topk=5)
12+
return [prediction[0] for prediction in predictions]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
torch
2+
regex
3+
tqdm
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"text": "machine learning is"
3+
}

0 commit comments

Comments
 (0)