lr-bert-base-uncased / main_test.py
Uan Sholanbayev
add custom handler
8f18779
raw
history blame
3.25 kB
from handler import EndpointHandler
summary = "The article discusses the principles and process of doing " \
"great work, emphasizing the importance of choosing the " \
"right field, developing a deep interest, and working hard." \
" It also highlights the significance of curiosity, delight," \
" and the desire to do something impressive. The author " \
"further discusses the challenges of figuring out what to" \
" work on, the dangers of procrastination, and the importance" \
" of consistency and exponential growth. The article " \
"concludes by highlighting the importance of intellectual " \
"honesty and avoiding affectation.\n\n• Choosing the right " \
"field\n • The author suggests that the work one chooses " \
"should be something they have a natural aptitude for, a deep" \
" interest in, and offers scope to do great work. The author" \
" also emphasizes the importance of working on one's own " \
"projects and following one's curiosity.\n\n• Figuring out what" \
" to work on\n • The author discusses the challenges of " \
"figuring out what to work on, especially when young and " \
"inexperienced. The author suggests trying lots of things, " \
"meeting lots of people, reading lots of books, and asking" \
" lots of questions to discover one's interests.\n\n• The " \
"dangers of procrastination\n • The author warns against " \
"procrastination, especially per-project procrastination, which" \
" can lead to significant delays in starting ambitious " \
"projects. The author suggests regularly asking oneself" \
" if they are working on what they most want to work on.\n\n•" \
" The importance of consistency and exponential growth\n • " \
"The author emphasizes the importance of consistency in work" \
" and the potential for exponential growth. The author " \
"suggests that work that compounds can lead to exponential " \
"growth, but warns that the early stages of exponential growth" \
" can feel flat and be undervalued.\n\n• Intellectual honesty " \
"and avoiding affectation\n • The author concludes by " \
"highlighting the importance of intellectual honesty and " \
"avoiding affectation. The author suggests that being earnest" \
" and intellectually honest can help one see new ideas and truths."
query = "What are the principles of doing great work according to the article?"
ir_query = "What are the best recipes for a vegan diet?"
semi_relevant_query = "Did Cristiano Ronaldo did a great work in Saudi league?"
# init handler
my_handler = EndpointHandler(path="./bert_lr.pkl")
# prepare sample payload
relevant_payload = {"queries": [query], "texts": [summary]}
irrelevant_payload = {"queries": semi_relevant_query, "texts": [summary]}
# test the handler
relevant_pred=my_handler(relevant_payload)
irrelevant_pred=my_handler(irrelevant_payload)
# show results
print("relevant_pred", relevant_pred)
print("irrelevant_pred", irrelevant_pred)