Create dockerfile
Browse files- dockerfile +22 -0
dockerfile
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from sentence_transformers import SentenceTransformer
|
2 |
+
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
3 |
+
|
4 |
+
|
5 |
+
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
6 |
+
question_model = "deepset/tinyroberta-squad2"
|
7 |
+
|
8 |
+
nlp = pipeline('question-answering', model=question_model, tokenizer=question_model)
|
9 |
+
|
10 |
+
|
11 |
+
def modifyQuery(query_string):
|
12 |
+
binary_embeddings = model.encode([query_string], precision="binary")
|
13 |
+
return binary_embeddings[0].tolist()
|
14 |
+
|
15 |
+
|
16 |
+
def answerQuestion(question, context):
|
17 |
+
QA_input = {
|
18 |
+
'question': question,
|
19 |
+
'context': context
|
20 |
+
}
|
21 |
+
res = nlp(QA_input)
|
22 |
+
return res['answer']
|