Repository: deepset-ai/haystack

Issue:
wrong top_k parameter usage in RAG Tutorials
**Describe the bug**
ValueError: too many values to unpack (expected 2)

**Error message**
/opt/anaconda/envs/haystack/lib/python3.7/site-packages/sqlalchemy/orm/relationships.py:3454: SAWarning: relationship 'DocumentORM.Meta' will copy column document.id to column meta.document_id, which conflicts with relationship(s): 'MetaORM.Document' (copies document.id to meta.document_id), 'DocumentORM.meta' (copies document.id to meta.document_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   The 'overlaps' parameter may be used to remove this warning.
  for (pr, fr_) in other_props
/opt/anaconda/envs/haystack/lib/python3.7/site-packages/sqlalchemy/orm/relationships.py:3454: SAWarning: relationship 'MetaORM.documents' will copy column document.id to column meta.document_id, which conflicts with relationship(s): 'MetaORM.Document' (copies document.id to meta.document_id), 'DocumentORM.meta' (copies document.id to meta.document_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   The 'overlaps' parameter may be used to remove this warning.
  for (pr, fr_) in other_props
03/18/2021 15:49:54 - INFO - haystack.document_store.faiss -   Updating embeddings for 75 docs...
  0%|          | 0/75 [00:00<?, ?it/s]
Creating Embeddings:   0%|          | 0/5 [00:00<?, ? Batches/s]
Creating Embeddings:  20%|██        | 1/5 [00:00<00:00,  8.52 Batches/s]
Creating Embeddings:  40%|████      | 2/5 [00:00<00:00,  8.50 Batches/s]
Creating Embeddings:  60%|██████    | 3/5 [00:00<00:00,  8.49 Batches/s]
Creating Embeddings: 100%|██████████| 5/5 [00:00<00:00,  8.91 Batches/s]
  0%|          | 0/75 [00:00<?, ?it/s]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-21be89473f19> in <module>
      7 # Add documents embeddings to index
      8 document_store.update_embeddings(
----> 9     retriever=retriever
     10 )

/opt/anaconda/envs/haystack/lib/python3.7/site-packages/haystack/document_store/faiss.py in update_embeddings(self, retriever, index, update_existing_embeddings, filters, batch_size)
    223                     vector_id_map[doc.id] = vector_id
    224                     vector_id += 1
--> 225                 self.update_vector_ids(vector_id_map, index=index)
    226                 progress_bar.update(batch_size)
    227         progress_bar.close()

/opt/anaconda/envs/haystack/lib/python3.7/site-packages/haystack/document_store/sql.py in update_vector_ids(self, vector_id_map, index, batch_size)
    354                 DocumentORM.vector_id: case(
    355                     chunk_map,
--> 356                     value=DocumentORM.id,
    357                 )
    358             }, synchronize_session=False)

<string> in case(*whens, **kw)

/opt/anaconda/envs/haystack/lib/python3.7/site-packages/sqlalchemy/sql/elements.py in __init__(self, *whens, **kw)
   2762                     coercions.expect(roles.ExpressionElementRole, r),
   2763                 )
-> 2764                 for (c, r) in whens
   2765             ]
   2766         else:

/opt/anaconda/envs/haystack/lib/python3.7/site-packages/sqlalchemy/sql/elements.py in <listcomp>(.0)
   2762                     coercions.expect(roles.ExpressionElementRole, r),
   2763                 )
-> 2764                 for (c, r) in whens
   2765             ]
   2766         else:

ValueError: too many values to unpack (expected 2)

**Expected behavior**
After install installing a fresh conda env+pip install farm-haystack, I do not expect to see any errors while trying your tutorials esp. Tutorial7_RAG_Generator.ipynb

**Additional context**
Perhaps you could regulate the requirements file or fix the tutorials. I also fixed another bug in the notebook:
RAGenerator(\n",
    "    model_name_or_path=\"facebook/rag-token-nq\",\n",
    "    use_gpu=True,\n",
    "    top_k_answers=1,\n",  <-----------------------top_k=1
    "    max_length=200,\n",
    "    min_length=2,\n",
    "    embed_title=True,\n",
    "    num_beams=2,\n",


**To Reproduce**
Fresh conda env + cuda 10+py 3.7 (acc to pytorch.org) + pip install farm-haystack

**System:**
 - OS: centos 7
 - GPU/CPU: rtx2080 + amd64 threadripper 2920
 - Haystack version (commit or version number):  latest and 0.7.0
 - DocumentStore: ?
 - Reader: ?
 - Retriever: ?

Thanks for looking into it. Br, Per



Discussion:

Resolving patch:
diff --git a/tutorials/Tutorial7_RAG_Generator.py b/tutorials/Tutorial7_RAG_Generator.py
--- a/tutorials/Tutorial7_RAG_Generator.py
+++ b/tutorials/Tutorial7_RAG_Generator.py
@@ -57,7 +57,7 @@ def tutorial7_rag_generator():
     generator = RAGenerator(
         model_name_or_path="facebook/rag-token-nq",
         use_gpu=True,
-        top_k_answers=1,
+        top_k=1,
         max_length=200,
         min_length=2,
         embed_title=True,


Test patch: