-
Notifications
You must be signed in to change notification settings - Fork 4
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
0 parents
commit a3eacb7
Showing
3 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Instructions | ||
|
||
We've provided a VERY basic Python script to perform inference against the Hugging Face `bert-base-uncased` model. This model takes in a string with a `[MASK]` key. The model will respond with | ||
a list of JSON objects containing a probability score, a token, the token string (the value that will fill in `[MASK]`), and the original string with the `[MASK]` key replaced. | ||
|
||
For example: | ||
|
||
Input: | ||
``` | ||
"Hello I'm a [MASK] model." | ||
``` | ||
|
||
Output: | ||
``` | ||
[ | ||
{ | ||
"score": 0.10731063783168793, | ||
"token": 4827, | ||
"token_str": "fashion", | ||
"sequence": "hello i'm a fashion model." | ||
}, | ||
{ | ||
"score": 0.08774515986442566, | ||
"token": 2535, | ||
"token_str": "role", | ||
"sequence": "hello i'm a role model." | ||
}, | ||
{ | ||
"score": 0.05338398739695549, | ||
"token": 2047, | ||
"token_str": "new", | ||
"sequence": "hello i'm a new model." | ||
}, | ||
{ | ||
"score": 0.04667206481099129, | ||
"token": 3565, | ||
"token_str": "super", | ||
"sequence": "hello i'm a super model." | ||
}, | ||
{ | ||
"score": 0.027095932513475418, | ||
"token": 2986, | ||
"token_str": "fine", | ||
"sequence": "hello i'm a fine model." | ||
} | ||
] | ||
``` | ||
|
||
We would like you to create a REST API service with 2 endpoints: | ||
* `/inference`: This endpoint should accept the string to replace in a JSON object by POST, and respond with the JSON provided by the model. | ||
* `/healthcheck`: This endpoint should return an HTTP 200. | ||
|
||
It's up to you which REST framework you prefer to use, be it Flask, FastAPI, or Django. | ||
|
||
# To perform this excercise: | ||
1. Fork this repo. | ||
2. Commit your changes to your fork. | ||
3. Submit a link to your fork, along with an explanation of your choices (such as REST framework, or anything else you want to point out). This can be in a README in your repo, or a few paragraphs in your response email. | ||
|
||
# What we would like to see: | ||
* A working REST API. | ||
* Any additional Python requirements added to `requirements.txt`. | ||
* API documentation! At the very least a README file with the expected input as a cURL call, and sample JSON output. | ||
* Bonus points if you add API documentation using something like OpenAPI. | ||
* Tell us what else you would do to make this model ready for production use. | ||
|
||
# Bonus Points: | ||
* Dockerize the application. | ||
* Create a pipeline to automatically build and deploy the application to a server. | ||
* Implement a different model. | ||
|
||
# How will you be evaluated | ||
|
||
We're not looking for perfection; we really want to see how you tackle a problem, so document your process. | ||
|
||
If you had to Google 90% of it to get it to work, THAT'S OK! It's not always about knowing the right answer, | ||
it's about knowing how to get the right answer. If you found solutions on the Internet, please cite them in your explanation. |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import json | ||
from transformers import pipeline | ||
|
||
unmasker = pipeline('fill-mask', model='bert-base-uncased') | ||
|
||
output = unmasker("Hello I'm a [MASK] model.") | ||
|
||
print(json.dumps(output, indent=4)) |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
transformers | ||
torch |