Skip to content

Commit

Permalink
Merge pull request #36 from sld/knn_on_parlai
Browse files Browse the repository at this point in the history
without facts
  • Loading branch information
sld authored Jul 6, 2018
2 parents e239f53 + 871eb89 commit 81b85a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
15 changes: 8 additions & 7 deletions knn_on_parlai/facts_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
}

otgovorki_pomidorki = {
"love": ["the world and talk to you", "chatting with you", "talk to you", "you, honey", "when you push buttons"],
"love": ["the world and talk to you", "chatting with you", "talk to you"],
"hate": ["not to talk to you", "be so far from you"],
"have": ["feelings for you", "1000 bitcoins"],
"live": ["in the woods", "in the clouds", "multi-passportw"],
"work": ["chatboting", "chat bot God (joke)"],
"skills": ["make miracles", "fly", "see your voice"],
"fact": ["awesome", "unicorn", "sexy", "Groot", "chat bot God"],
"disfact": ["di caprio", "gendalf", "unicorn"],
"have": ["feelings for you", "1000 bitcoins", "multi-passport"],
"live": ["in the woods", "in the clouds"],
"work": [],
"skills": ["see your voice"],
"fact": ["awesome", "unicorn", "lovely", "sweet", "gracefull", "pleasant"],
"disfact": [],
"eat": ["ice cream", "rainbows"],
"child": ["together with my cat"],
"play": ["my mother nerves", "nothing"],
Expand All @@ -77,6 +77,7 @@
"brother": [],
"daughter": []
}

easter_egg_answer = {
"time": "it's adventure time",
"need": "i need your moto and clothes",
Expand Down
8 changes: 4 additions & 4 deletions knn_on_parlai/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def respond():
embed = get_embed(question, vectors)
got_ind = u.get_nns_by_vector(embed, 1)

best_ans, found = make_new_facts(index_to_answer[got_ind[0]], bio)
# best_ans, found = make_new_facts(index_to_answer[got_ind[0]], bio)
# for i in got_ind:
# ans_with_facts, found = make_new_facts(index_to_answer[i], bio)
# if found:
# return jsonify({'message': ans_with_facts})

return jsonify({'message': best_ans})
return jsonify({'message': index_to_answer[got_ind[0]]})


def load_obj(name):
Expand All @@ -41,8 +41,8 @@ def get_embed(text, vectors):

u = AnnoyIndex(300)

u.load('db_qa_facts_tokenized.ann')
index_to_answer = load_obj("db_qa_facts_tokenized_index_to_answer")
u.load('db_qa.ann')
index_to_answer = load_obj("db_qa_index_to_answer")
vectors = Magnitude("wiki-news-300d-1M-subword.magnitude")

app.run(debug=False, host='0.0.0.0', port=3031)
6 changes: 3 additions & 3 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ wget -P dialog_tracker/data/ https://s3.eu-central-1.amazonaws.com/convai/model-
# knn on parlai

wget -P knn_on_parlai https://s3.eu-central-1.amazonaws.com/convai/wiki-news-300d-1M-subword.magnitude
wget -P knn_on_parlai https://www.dropbox.com/s/fc6i8c6x76glwkp/db_qa_facts_tokenized_index_to_answer.pkl
wget -P knn_on_parlai https://www.dropbox.com/s/k2dvcmadqxeanqd/db_qa_facts_tokenized.ann
wget -P knn_on_parlai https://www.dropbox.com/s/hry5astqsxmlqws/db_qa_facts_tokenized.json
wget -P knn_on_parlai https://www.dropbox.com/s/gfdre8hassbs3ly/db_qa_index_to_answer.pkl?dl=0
wget -P knn_on_parlai https://www.dropbox.com/s/iiyvllsuzfuseaf/db_qa.ann?dl=0
wget -P knn_on_parlai https://www.dropbox.com/s/s1zeqs5s8pgjrja/db_qa.json?dl=0

0 comments on commit 81b85a2

Please sign in to comment.