| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  | from haystack.utils import ( | 
					
						
							|  |  |  |     fetch_archive_from_http, | 
					
						
							| 
									
										
										
										
											2022-03-29 13:53:35 +02:00
										 |  |  |     convert_files_to_docs, | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     clean_wiki_text, | 
					
						
							|  |  |  |     launch_es, | 
					
						
							|  |  |  |     print_answers, | 
					
						
							|  |  |  |     print_documents, | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2022-03-29 13:53:35 +02:00
										 |  |  | from haystack.pipelines import Pipeline | 
					
						
							| 
									
										
										
										
											2021-10-25 15:50:23 +02:00
										 |  |  | from haystack.document_stores import ElasticsearchDocumentStore | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  | from haystack.nodes import ( | 
					
						
							| 
									
										
										
										
											2022-04-26 16:09:39 +02:00
										 |  |  |     BM25Retriever, | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     EmbeddingRetriever, | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     FARMReader, | 
					
						
							|  |  |  |     TransformersQueryClassifier, | 
					
						
							|  |  |  |     SklearnQueryClassifier, | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def tutorial14_query_classifier(): | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     # Download and prepare data - 517 Wikipedia articles for Game of Thrones | 
					
						
							| 
									
										
										
										
											2022-03-21 11:58:51 +01:00
										 |  |  |     doc_dir = "data/tutorial14" | 
					
						
							|  |  |  |     s3_url = "https://s3.eu-central-1.amazonaws.com/deepset.ai-farm-qa/datasets/documents/wiki_gameofthrones_txt14.zip" | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  |     fetch_archive_from_http(url=s3_url, output_dir=doc_dir) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # convert files to dicts containing documents that can be indexed to our datastore | 
					
						
							| 
									
										
										
										
											2022-03-29 13:53:35 +02:00
										 |  |  |     got_docs = convert_files_to_docs(dir_path=doc_dir, clean_func=clean_wiki_text, split_paragraphs=True) | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Initialize DocumentStore and index documents | 
					
						
							|  |  |  |     launch_es() | 
					
						
							|  |  |  |     document_store = ElasticsearchDocumentStore() | 
					
						
							| 
									
										
										
										
											2021-08-30 18:48:28 +05:30
										 |  |  |     document_store.delete_documents() | 
					
						
							| 
									
										
										
										
											2022-03-29 13:53:35 +02:00
										 |  |  |     document_store.write_documents(got_docs) | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Initialize Sparse retriever | 
					
						
							| 
									
										
										
										
											2022-05-03 18:08:23 +02:00
										 |  |  |     bm25_retriever = BM25Retriever(document_store=document_store) | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Initialize dense retriever | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     embedding_retriever = EmbeddingRetriever( | 
					
						
							|  |  |  |         document_store=document_store, | 
					
						
							|  |  |  |         model_format="sentence_transformers", | 
					
						
							|  |  |  |         embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1", | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     document_store.update_embeddings(embedding_retriever, update_existing_embeddings=False) | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     reader = FARMReader(model_name_or_path="deepset/roberta-base-squad2") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print() | 
					
						
							|  |  |  |     print("Sklearn keyword classifier") | 
					
						
							|  |  |  |     print("==========================") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  |     # Here we build the pipeline | 
					
						
							|  |  |  |     sklearn_keyword_classifier = Pipeline() | 
					
						
							|  |  |  |     sklearn_keyword_classifier.add_node(component=SklearnQueryClassifier(), name="QueryClassifier", inputs=["Query"]) | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     sklearn_keyword_classifier.add_node( | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |         component=embedding_retriever, name="EmbeddingRetriever", inputs=["QueryClassifier.output_1"] | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     ) | 
					
						
							| 
									
										
										
										
											2022-05-03 18:08:23 +02:00
										 |  |  |     sklearn_keyword_classifier.add_node( | 
					
						
							|  |  |  |         component=bm25_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"] | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     sklearn_keyword_classifier.add_node(component=reader, name="QAReader", inputs=["ESRetriever", "EmbeddingRetriever"]) | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  |     sklearn_keyword_classifier.draw("pipeline_classifier.png") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Run only the dense retriever on the full sentence query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_1 = sklearn_keyword_classifier.run(query="Who is the father of Arya Stark?") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     print("Embedding Retriever Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_1, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the sparse retriever on a keyword based query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_2 = sklearn_keyword_classifier.run(query="arya stark father") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     print("ES Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_2, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the dense retriever on the full sentence query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_3 = sklearn_keyword_classifier.run(query="which country was jon snow filmed ?") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     print("Embedding Retriever Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_3, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the sparse retriever on a keyword based query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_4 = sklearn_keyword_classifier.run(query="jon snow country") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     print("ES Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_4, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the dense retriever on the full sentence query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_5 = sklearn_keyword_classifier.run(query="who are the younger brothers of arya stark ?") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     print("Embedding Retriever Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_5, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the sparse retriever on a keyword based query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_6 = sklearn_keyword_classifier.run(query="arya stark younger brothers") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     print("ES Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_6, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print() | 
					
						
							|  |  |  |     print("Transformer keyword classifier") | 
					
						
							|  |  |  |     print("==============================") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  |     # Here we build the pipeline | 
					
						
							|  |  |  |     transformer_keyword_classifier = Pipeline() | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     transformer_keyword_classifier.add_node( | 
					
						
							|  |  |  |         component=TransformersQueryClassifier(), name="QueryClassifier", inputs=["Query"] | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     transformer_keyword_classifier.add_node( | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |         component=embedding_retriever, name="EmbeddingRetriever", inputs=["QueryClassifier.output_1"] | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     ) | 
					
						
							|  |  |  |     transformer_keyword_classifier.add_node( | 
					
						
							| 
									
										
										
										
											2022-05-03 18:08:23 +02:00
										 |  |  |         component=bm25_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"] | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     ) | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     transformer_keyword_classifier.add_node( | 
					
						
							|  |  |  |         component=reader, name="QAReader", inputs=["ESRetriever", "EmbeddingRetriever"] | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  |     transformer_keyword_classifier.draw("pipeline_classifier.png") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Run only the dense retriever on the full sentence query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_1 = transformer_keyword_classifier.run(query="Who is the father of Arya Stark?") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     print("Embedding Retriever Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_1, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the sparse retriever on a keyword based query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_2 = transformer_keyword_classifier.run(query="arya stark father") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     print("ES Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_2, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the dense retriever on the full sentence query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_3 = transformer_keyword_classifier.run(query="which country was jon snow filmed ?") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     print("Embedding Retriever Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_3, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the sparse retriever on a keyword based query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_4 = transformer_keyword_classifier.run(query="jon snow country") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     print("ES Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_4, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the dense retriever on the full sentence query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_5 = transformer_keyword_classifier.run(query="who are the younger brothers of arya stark ?") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     print("Embedding Retriever Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_5, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Run only the sparse retriever on a keyword based query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_6 = transformer_keyword_classifier.run(query="arya stark younger brothers") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     print("ES Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_6, details="minimum") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     print() | 
					
						
							|  |  |  |     print("Transformer question classifier") | 
					
						
							|  |  |  |     print("===============================") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Here we build the pipeline | 
					
						
							|  |  |  |     transformer_question_classifier = Pipeline() | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     transformer_question_classifier.add_node(component=embedding_retriever, name="DPRRetriever", inputs=["Query"]) | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     transformer_question_classifier.add_node( | 
					
						
							|  |  |  |         component=TransformersQueryClassifier(model_name_or_path="shahrukhx01/question-vs-statement-classifier"), | 
					
						
							|  |  |  |         name="QueryClassifier", | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |         inputs=["EmbeddingRetriever"], | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     ) | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  |     transformer_question_classifier.add_node(component=reader, name="QAReader", inputs=["QueryClassifier.output_1"]) | 
					
						
							|  |  |  |     transformer_question_classifier.draw("question_classifier.png") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Run only the QA reader on the question query | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_1 = transformer_question_classifier.run(query="Who is the father of Arya Stark?") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     print("Embedding Retriever Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print_answers(res_1, details="minimum") | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-07 19:25:33 +01:00
										 |  |  |     res_2 = transformer_question_classifier.run(query="Arya Stark was the daughter of a Lord.") | 
					
						
							| 
									
										
										
										
											2021-11-09 15:09:26 +01:00
										 |  |  |     print("\n===============================") | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     print("ES Results" + "\n" + "=" * 15) | 
					
						
							| 
									
										
										
										
											2022-03-28 16:54:49 +02:00
										 |  |  |     print_documents(res_2) | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Here we create the keyword vs question/statement query classifier | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     queries = [ | 
					
						
							|  |  |  |         "arya stark father", | 
					
						
							|  |  |  |         "jon snow country", | 
					
						
							|  |  |  |         "who is the father of arya stark", | 
					
						
							|  |  |  |         "which country was jon snow filmed?", | 
					
						
							|  |  |  |     ] | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     keyword_classifier = TransformersQueryClassifier() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for query in queries: | 
					
						
							|  |  |  |         result = keyword_classifier.run(query=query) | 
					
						
							|  |  |  |         if result[1] == "output_1": | 
					
						
							|  |  |  |             category = "question/statement" | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             category = "keyword" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         print(f"Query: {query}, raw_output: {result}, class: {category}") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Here we create the question vs statement query classifier | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  |     queries = [ | 
					
						
							|  |  |  |         "Lord Eddard was the father of Arya Stark.", | 
					
						
							|  |  |  |         "Jon Snow was filmed in United Kingdom.", | 
					
						
							|  |  |  |         "who is the father of arya stark?", | 
					
						
							|  |  |  |         "Which country was jon snow filmed in?", | 
					
						
							|  |  |  |     ] | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     question_classifier = TransformersQueryClassifier(model_name_or_path="shahrukhx01/question-vs-statement-classifier") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for query in queries: | 
					
						
							|  |  |  |         result = question_classifier.run(query=query) | 
					
						
							|  |  |  |         if result[1] == "output_1": | 
					
						
							|  |  |  |             category = "question" | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             category = "statement" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         print(f"Query: {query}, raw_output: {result}, class: {category}") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-03 13:43:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-09 10:43:50 +02:00
										 |  |  | if __name__ == "__main__": | 
					
						
							|  |  |  |     tutorial14_query_classifier() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # This Haystack script was made with love by deepset in Berlin, Germany | 
					
						
							|  |  |  | # Haystack: https://github.com/deepset-ai/haystack | 
					
						
							|  |  |  | # deepset: https://deepset.ai/ |