Skip to content

Commit

Permalink
changing the name of the retrievers from es_retriever to retriever (#…
Browse files Browse the repository at this point in the history
…2487)

* changing the name of the retrievers from es_retriever to retriever

* Update Documentation & Code Style

* name fix 2

* Update Documentation & Code Style

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
TuanaCelik and github-actions[bot] committed May 3, 2022
1 parent 509944f commit b6e369d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 37 deletions.
14 changes: 7 additions & 7 deletions docs/_src/tutorials/tutorials/11.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ document_store.delete_documents()
document_store.write_documents(got_docs)

# Initialize Sparse retriever
es_retriever = BM25Retriever(document_store=document_store)
bm25_retriever = BM25Retriever(document_store=document_store)

# Initialize dense retriever
embedding_retriever = EmbeddingRetriever(
Expand All @@ -134,7 +134,7 @@ Here we have an `ExtractiveQAPipeline` (the successor to the now deprecated `Fin
from haystack.pipelines import ExtractiveQAPipeline

# Prebuilt pipeline
p_extractive_premade = ExtractiveQAPipeline(reader=reader, retriever=es_retriever)
p_extractive_premade = ExtractiveQAPipeline(reader=reader, retriever=bm25_retriever)
res = p_extractive_premade.run(
query="Who is the father of Arya Stark?", params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}}
)
Expand All @@ -147,7 +147,7 @@ If you want to just do the retrieval step, you can use a `DocumentSearchPipeline
```python
from haystack.pipelines import DocumentSearchPipeline

p_retrieval = DocumentSearchPipeline(es_retriever)
p_retrieval = DocumentSearchPipeline(bm25_retriever)
res = p_retrieval.run(query="Who is the father of Arya Stark?", params={"Retriever": {"top_k": 10}})
print_documents(res, max_text_len=200)
```
Expand Down Expand Up @@ -207,7 +207,7 @@ We do this by adding the building blocks that we initialized as nodes in the gra
```python
# Custom built extractive QA pipeline
p_extractive = Pipeline()
p_extractive.add_node(component=es_retriever, name="Retriever", inputs=["Query"])
p_extractive.add_node(component=bm25_retriever, name="Retriever", inputs=["Query"])
p_extractive.add_node(component=reader, name="Reader", inputs=["Retriever"])

# Now we can run it
Expand All @@ -234,7 +234,7 @@ from haystack.nodes import JoinDocuments

# Create ensembled pipeline
p_ensemble = Pipeline()
p_ensemble.add_node(component=es_retriever, name="ESRetriever", inputs=["Query"])
p_ensemble.add_node(component=bm25_retriever, name="ESRetriever", inputs=["Query"])
p_ensemble.add_node(component=embedding_retriever, name="EmbeddingRetriever", inputs=["Query"])
p_ensemble.add_node(
component=JoinDocuments(join_mode="concatenate"), name="JoinResults", inputs=["ESRetriever", "EmbeddingRetriever"]
Expand Down Expand Up @@ -308,7 +308,7 @@ class CustomQueryClassifier(BaseComponent):
# Here we build the pipeline
p_classifier = Pipeline()
p_classifier.add_node(component=CustomQueryClassifier(), name="QueryClassifier", inputs=["Query"])
p_classifier.add_node(component=es_retriever, name="ESRetriever", inputs=["QueryClassifier.output_1"])
p_classifier.add_node(component=bm25_retriever, name="ESRetriever", inputs=["QueryClassifier.output_1"])
p_classifier.add_node(component=embedding_retriever, name="EmbeddingRetriever", inputs=["QueryClassifier.output_2"])
p_classifier.add_node(component=reader, name="QAReader", inputs=["ESRetriever", "EmbeddingRetriever"])
p_classifier.draw("pipeline_classifier.png")
Expand Down Expand Up @@ -336,7 +336,7 @@ You can print out debug information from nodes in your pipelines in a few differ

```python
# 1) You can set the `debug` attribute of a given node.
es_retriever.debug = True
bm25_retriever.debug = True

# 2) You can provide `debug` as a parameter when running your pipeline
result = p_classifier.run(query="Who is the father of Arya Stark?", params={"ESRetriever": {"debug": True}})
Expand Down
8 changes: 5 additions & 3 deletions docs/_src/tutorials/tutorials/14.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ document_store.delete_documents()
document_store.write_documents(got_docs)

# Initialize Sparse retriever
es_retriever = BM25Retriever(document_store=document_store)
bm25_retriever = BM25Retriever(document_store=document_store)

# Initialize dense retriever
embedding_retriever = EmbeddingRetriever(
Expand Down Expand Up @@ -159,7 +159,7 @@ sklearn_keyword_classifier.add_node(component=SklearnQueryClassifier(), name="Qu
sklearn_keyword_classifier.add_node(
component=embedding_retriever, name="EmbeddingRetriever", inputs=["QueryClassifier.output_1"]
)
sklearn_keyword_classifier.add_node(component=es_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"])
sklearn_keyword_classifier.add_node(component=bm25_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"])
sklearn_keyword_classifier.add_node(component=reader, name="QAReader", inputs=["ESRetriever", "EmbeddingRetriever"])
sklearn_keyword_classifier.draw("pipeline_classifier.png")
```
Expand Down Expand Up @@ -221,7 +221,9 @@ transformer_keyword_classifier.add_node(
transformer_keyword_classifier.add_node(
component=embedding_retriever, name="EmbeddingRetriever", inputs=["QueryClassifier.output_1"]
)
transformer_keyword_classifier.add_node(component=es_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"])
transformer_keyword_classifier.add_node(
component=bm25_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"]
)
transformer_keyword_classifier.add_node(component=reader, name="QAReader", inputs=["ESRetriever", "EmbeddingRetriever"])
transformer_keyword_classifier.draw("pipeline_classifier.png")
```
Expand Down
10 changes: 5 additions & 5 deletions haystack/json-schemas/haystack-pipeline-master.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2102,11 +2102,6 @@
"custom_query": {
"title": "Custom Query",
"type": "string"
},
"scale_score": {
"title": "Scale Score",
"default": true,
"type": "boolean"
}
},
"required": [
Expand Down Expand Up @@ -2643,6 +2638,11 @@
"custom_query": {
"title": "Custom Query",
"type": "string"
},
"scale_score": {
"title": "Scale Score",
"default": true,
"type": "boolean"
}
},
"required": [
Expand Down
16 changes: 8 additions & 8 deletions tutorials/Tutorial11_Pipelines.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"document_store.write_documents(got_docs)\n",
"\n",
"# Initialize Sparse retriever\n",
"es_retriever = BM25Retriever(document_store=document_store)\n",
"bm25_retriever = BM25Retriever(document_store=document_store)\n",
"\n",
"# Initialize dense retriever\n",
"embedding_retriever = EmbeddingRetriever(\n",
Expand Down Expand Up @@ -263,7 +263,7 @@
"from haystack.pipelines import ExtractiveQAPipeline\n",
"\n",
"# Prebuilt pipeline\n",
"p_extractive_premade = ExtractiveQAPipeline(reader=reader, retriever=es_retriever)\n",
"p_extractive_premade = ExtractiveQAPipeline(reader=reader, retriever=bm25_retriever)\n",
"res = p_extractive_premade.run(\n",
" query=\"Who is the father of Arya Stark?\", params={\"Retriever\": {\"top_k\": 10}, \"Reader\": {\"top_k\": 5}}\n",
")\n",
Expand Down Expand Up @@ -292,7 +292,7 @@
"source": [
"from haystack.pipelines import DocumentSearchPipeline\n",
"\n",
"p_retrieval = DocumentSearchPipeline(es_retriever)\n",
"p_retrieval = DocumentSearchPipeline(bm25_retriever)\n",
"res = p_retrieval.run(query=\"Who is the father of Arya Stark?\", params={\"Retriever\": {\"top_k\": 10}})\n",
"print_documents(res, max_text_len=200)"
]
Expand Down Expand Up @@ -412,7 +412,7 @@
"source": [
"# Custom built extractive QA pipeline\n",
"p_extractive = Pipeline()\n",
"p_extractive.add_node(component=es_retriever, name=\"Retriever\", inputs=[\"Query\"])\n",
"p_extractive.add_node(component=bm25_retriever, name=\"Retriever\", inputs=[\"Query\"])\n",
"p_extractive.add_node(component=reader, name=\"Reader\", inputs=[\"Retriever\"])\n",
"\n",
"# Now we can run it\n",
Expand Down Expand Up @@ -458,7 +458,7 @@
"\n",
"# Create ensembled pipeline\n",
"p_ensemble = Pipeline()\n",
"p_ensemble.add_node(component=es_retriever, name=\"ESRetriever\", inputs=[\"Query\"])\n",
"p_ensemble.add_node(component=bm25_retriever, name=\"ESRetriever\", inputs=[\"Query\"])\n",
"p_ensemble.add_node(component=embedding_retriever, name=\"EmbeddingRetriever\", inputs=[\"Query\"])\n",
"p_ensemble.add_node(\n",
" component=JoinDocuments(join_mode=\"concatenate\"), name=\"JoinResults\", inputs=[\"ESRetriever\", \"EmbeddingRetriever\"]\n",
Expand Down Expand Up @@ -570,7 +570,7 @@
"# Here we build the pipeline\n",
"p_classifier = Pipeline()\n",
"p_classifier.add_node(component=CustomQueryClassifier(), name=\"QueryClassifier\", inputs=[\"Query\"])\n",
"p_classifier.add_node(component=es_retriever, name=\"ESRetriever\", inputs=[\"QueryClassifier.output_1\"])\n",
"p_classifier.add_node(component=bm25_retriever, name=\"ESRetriever\", inputs=[\"QueryClassifier.output_1\"])\n",
"p_classifier.add_node(component=embedding_retriever, name=\"EmbeddingRetriever\", inputs=[\"QueryClassifier.output_2\"])\n",
"p_classifier.add_node(component=reader, name=\"QAReader\", inputs=[\"ESRetriever\", \"EmbeddingRetriever\"])\n",
"p_classifier.draw(\"pipeline_classifier.png\")\n",
Expand Down Expand Up @@ -627,7 +627,7 @@
"outputs": [],
"source": [
"# 1) You can set the `debug` attribute of a given node.\n",
"es_retriever.debug = True\n",
"bm25_retriever.debug = True\n",
"\n",
"# 2) You can provide `debug` as a parameter when running your pipeline\n",
"result = p_classifier.run(query=\"Who is the father of Arya Stark?\", params={\"ESRetriever\": {\"debug\": True}})\n",
Expand Down Expand Up @@ -777,4 +777,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
14 changes: 7 additions & 7 deletions tutorials/Tutorial11_Pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def tutorial11_pipelines():
document_store.write_documents(got_docs)

# Initialize Sparse retriever
es_retriever = BM25Retriever(document_store=document_store)
bm25_retriever = BM25Retriever(document_store=document_store)

# Initialize dense retriever
embedding_retriever = EmbeddingRetriever(
Expand All @@ -51,7 +51,7 @@ def tutorial11_pipelines():
print("########################")

query = "Who is the father of Arya Stark?"
p_extractive_premade = ExtractiveQAPipeline(reader=reader, retriever=es_retriever)
p_extractive_premade = ExtractiveQAPipeline(reader=reader, retriever=bm25_retriever)
res = p_extractive_premade.run(query=query, params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}})
print("\nQuery: ", query)
print("Answers:")
Expand All @@ -62,7 +62,7 @@ def tutorial11_pipelines():
print("##########################")

query = "Who is the father of Arya Stark?"
p_retrieval = DocumentSearchPipeline(es_retriever)
p_retrieval = DocumentSearchPipeline(bm25_retriever)
res = p_retrieval.run(query=query, params={"Retriever": {"top_k": 10}})
print()
print_documents(res, max_text_len=200)
Expand Down Expand Up @@ -108,7 +108,7 @@ def tutorial11_pipelines():

# Custom built extractive QA pipeline
p_extractive = Pipeline()
p_extractive.add_node(component=es_retriever, name="Retriever", inputs=["Query"])
p_extractive.add_node(component=bm25_retriever, name="Retriever", inputs=["Query"])
p_extractive.add_node(component=reader, name="Reader", inputs=["Retriever"])

# Now we can run it
Expand All @@ -125,7 +125,7 @@ def tutorial11_pipelines():

# Create ensembled pipeline
p_ensemble = Pipeline()
p_ensemble.add_node(component=es_retriever, name="ESRetriever", inputs=["Query"])
p_ensemble.add_node(component=bm25_retriever, name="ESRetriever", inputs=["Query"])
p_ensemble.add_node(component=embedding_retriever, name="EmbeddingRetriever", inputs=["Query"])
p_ensemble.add_node(
component=JoinDocuments(join_mode="concatenate"),
Expand Down Expand Up @@ -166,7 +166,7 @@ def run(self, query):
# Here we build the pipeline
p_classifier = Pipeline()
p_classifier.add_node(component=CustomQueryClassifier(), name="QueryClassifier", inputs=["Query"])
p_classifier.add_node(component=es_retriever, name="ESRetriever", inputs=["QueryClassifier.output_1"])
p_classifier.add_node(component=bm25_retriever, name="ESRetriever", inputs=["QueryClassifier.output_1"])
p_classifier.add_node(component=embedding_retriever, name="EmbeddingRetriever", inputs=["QueryClassifier.output_2"])
p_classifier.add_node(component=reader, name="QAReader", inputs=["ESRetriever", "EmbeddingRetriever"])
p_classifier.draw("pipeline_classifier.png")
Expand All @@ -193,7 +193,7 @@ def run(self, query):
# You can print out debug information from nodes in your pipelines in a few different ways.

# 1) You can set the `debug` attribute of a given node.
es_retriever.debug = True
bm25_retriever.debug = True

# 2) You can provide `debug` as a parameter when running your pipeline
result = p_classifier.run(query="Who is the father of Arya Stark?", params={"ESRetriever": {"debug": True}})
Expand Down
10 changes: 6 additions & 4 deletions tutorials/Tutorial14_Query_Classifier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
"document_store.write_documents(got_docs)\n",
"\n",
"# Initialize Sparse retriever\n",
"es_retriever = BM25Retriever(document_store=document_store)\n",
"bm25_retriever = BM25Retriever(document_store=document_store)\n",
"\n",
"# Initialize dense retriever\n",
"embedding_retriever = EmbeddingRetriever(\n",
Expand Down Expand Up @@ -464,7 +464,7 @@
"sklearn_keyword_classifier.add_node(\n",
" component=embedding_retriever, name=\"EmbeddingRetriever\", inputs=[\"QueryClassifier.output_1\"]\n",
")\n",
"sklearn_keyword_classifier.add_node(component=es_retriever, name=\"ESRetriever\", inputs=[\"QueryClassifier.output_2\"])\n",
"sklearn_keyword_classifier.add_node(component=bm25_retriever, name=\"ESRetriever\", inputs=[\"QueryClassifier.output_2\"])\n",
"sklearn_keyword_classifier.add_node(component=reader, name=\"QAReader\", inputs=[\"ESRetriever\", \"EmbeddingRetriever\"])\n",
"sklearn_keyword_classifier.draw(\"pipeline_classifier.png\")"
]
Expand Down Expand Up @@ -557,7 +557,9 @@
"transformer_keyword_classifier.add_node(\n",
" component=embedding_retriever, name=\"EmbeddingRetriever\", inputs=[\"QueryClassifier.output_1\"]\n",
")\n",
"transformer_keyword_classifier.add_node(component=es_retriever, name=\"ESRetriever\", inputs=[\"QueryClassifier.output_2\"])\n",
"transformer_keyword_classifier.add_node(\n",
" component=bm25_retriever, name=\"ESRetriever\", inputs=[\"QueryClassifier.output_2\"]\n",
")\n",
"transformer_keyword_classifier.add_node(component=reader, name=\"QAReader\", inputs=[\"ESRetriever\", \"EmbeddingRetriever\"])\n",
"transformer_keyword_classifier.draw(\"pipeline_classifier.png\")"
]
Expand Down Expand Up @@ -6780,4 +6782,4 @@
},
"nbformat": 4,
"nbformat_minor": 1
}
}
8 changes: 5 additions & 3 deletions tutorials/Tutorial14_Query_Classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def tutorial14_query_classifier():
document_store.write_documents(got_docs)

# Initialize Sparse retriever
es_retriever = BM25Retriever(document_store=document_store)
bm25_retriever = BM25Retriever(document_store=document_store)

# Initialize dense retriever
embedding_retriever = EmbeddingRetriever(
Expand All @@ -55,7 +55,9 @@ def tutorial14_query_classifier():
sklearn_keyword_classifier.add_node(
component=embedding_retriever, name="EmbeddingRetriever", inputs=["QueryClassifier.output_1"]
)
sklearn_keyword_classifier.add_node(component=es_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"])
sklearn_keyword_classifier.add_node(
component=bm25_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"]
)
sklearn_keyword_classifier.add_node(component=reader, name="QAReader", inputs=["ESRetriever", "EmbeddingRetriever"])
sklearn_keyword_classifier.draw("pipeline_classifier.png")

Expand Down Expand Up @@ -107,7 +109,7 @@ def tutorial14_query_classifier():
component=embedding_retriever, name="EmbeddingRetriever", inputs=["QueryClassifier.output_1"]
)
transformer_keyword_classifier.add_node(
component=es_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"]
component=bm25_retriever, name="ESRetriever", inputs=["QueryClassifier.output_2"]
)
transformer_keyword_classifier.add_node(
component=reader, name="QAReader", inputs=["ESRetriever", "EmbeddingRetriever"]
Expand Down

0 comments on commit b6e369d

Please sign in to comment.