Add lookup tables to NLU model
Browse files- .gitattributes +1 -0
- app.py +6 -14
.gitattributes
CHANGED
|
@@ -41,3 +41,4 @@ woz_nlu_agent/models/nlu/checkpoint filter=lfs diff=lfs merge=lfs -text
|
|
| 41 |
woz_nlu_agent/models/nlu/component_2_LexicalSyntacticFeaturizer.feature_to_idx_dict.pkl filter=lfs diff=lfs merge=lfs -text
|
| 42 |
woz_nlu_agent/models/nlu/component_3_CountVectorsFeaturizer.pkl filter=lfs diff=lfs merge=lfs -text
|
| 43 |
woz_nlu_agent/models/nlu/** filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 41 |
woz_nlu_agent/models/nlu/component_2_LexicalSyntacticFeaturizer.feature_to_idx_dict.pkl filter=lfs diff=lfs merge=lfs -text
|
| 42 |
woz_nlu_agent/models/nlu/component_3_CountVectorsFeaturizer.pkl filter=lfs diff=lfs merge=lfs -text
|
| 43 |
woz_nlu_agent/models/nlu/** filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
woz_nlu_agent/models/nlu-lookup-1/** filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -10,12 +10,13 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
| 10 |
|
| 11 |
|
| 12 |
# Rasa intent + entity extractor
|
| 13 |
-
RASA_MODEL_PATH = "woz_nlu_agent/models/nlu"
|
| 14 |
-
interpreter =
|
| 15 |
|
| 16 |
# OOS classifier
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
MODEL_TYPES = {
|
|
@@ -30,7 +31,7 @@ def predict(model_type, input):
|
|
| 30 |
elif MODEL_TYPES[model_type] == "oos":
|
| 31 |
return oos_predict(input)
|
| 32 |
elif MODEL_TYPES[model_type] == "intent_transformer":
|
| 33 |
-
return "
|
| 34 |
|
| 35 |
|
| 36 |
def oos_predict(input):
|
|
@@ -67,15 +68,6 @@ def rasa_predict(input):
|
|
| 67 |
|
| 68 |
|
| 69 |
def main():
|
| 70 |
-
global interpreter
|
| 71 |
-
print("Loading model...")
|
| 72 |
-
print(os.listdir("woz_nlu_agent/models/nlu"))
|
| 73 |
-
print(open("woz_nlu_agent/models/nlu/metadata.json", "r").read())
|
| 74 |
-
import json
|
| 75 |
-
print(json.load(open("woz_nlu_agent/models/nlu/metadata.json", "r")))
|
| 76 |
-
|
| 77 |
-
interpreter = Interpreter.load(RASA_MODEL_PATH)
|
| 78 |
-
print("Model loaded.")
|
| 79 |
iface = gr.Interface(fn=predict, inputs=[gr.inputs.Dropdown(list(MODEL_TYPES.keys())), "text"], outputs="text")
|
| 80 |
iface.launch()
|
| 81 |
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
# Rasa intent + entity extractor
|
| 13 |
+
RASA_MODEL_PATH = "woz_nlu_agent/models/nlu-lookup-1"
|
| 14 |
+
interpreter = Interpreter.load(RASA_MODEL_PATH)
|
| 15 |
|
| 16 |
# OOS classifier
|
| 17 |
+
OOS_MODEL= "msamogh/autonlp-cai-out-of-scope-649919116"
|
| 18 |
+
tokenizer = AutoTokenizer.from_pretrained(OOS_MODEL)
|
| 19 |
+
model = AutoModelForSequenceClassification.from_pretrained(OOS_MODEL)
|
| 20 |
|
| 21 |
|
| 22 |
MODEL_TYPES = {
|
|
|
|
| 31 |
elif MODEL_TYPES[model_type] == "oos":
|
| 32 |
return oos_predict(input)
|
| 33 |
elif MODEL_TYPES[model_type] == "intent_transformer":
|
| 34 |
+
return "WIP: intent_transformer"
|
| 35 |
|
| 36 |
|
| 37 |
def oos_predict(input):
|
|
|
|
| 68 |
|
| 69 |
|
| 70 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
iface = gr.Interface(fn=predict, inputs=[gr.inputs.Dropdown(list(MODEL_TYPES.keys())), "text"], outputs="text")
|
| 72 |
iface.launch()
|
| 73 |
|