L4 - Error while running the notebook on colab

I am trying to run the L4 notebook in Google Colab.
I have installed the required packages and their dependencies using the following commands:
!pip install openai
!pip install llama-index
!pip install trulens_eval
!pip install sentence_transformers

However, when I run the following line:

auto_merging_response = auto_merging_engine.query(
“What is the importance of networking in AI?”
)

It keeps throwing the following error:


AttributeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 auto_merging_response = auto_merging_engine.query(
2 “What is the importance of networking in AI?”
3 )
5 frames
/usr/local/lib/python3.10/dist-packages/llama_index/postprocessor/sbert_rerank.py in _postprocess_nodes(self, nodes, query_bundle)
76
77 for node, score in zip(nodes, scores):
—> 78 if self.keep_retrieval_score:
79 # keep the retrieval score in metadata
80 node.node.metadata[“retrieval_score”] = node.score
AttributeError: ‘SentenceTransformerRerank’ object has no attribute ‘keep_retrieval_score’

What I have tried:

  • I tried to find out whether there were any specific version dependencies but I could not get that information anywhere.
  • I googled for this error, there were no links that were of any use.

Versions installed:
Name: llama-index Version: 0.9.36
Name: sentence-transformers Version: 2.2.2

If someone could help me in resolving this issue.

Hi @tusharganguli,

Since LLM is a new field, all the related libraries get updated frequently. From the error you are getting, it seems like the same happened here.

You can do pip freeze in any one notebook on the platform and see what package versions are being used there for openai, llama-index, trulens_eval and sentence_transformers.

Then you can install those same packages in the colab and try again.

Best,
Mubsi

Hi @Mubsi ,
Thanks for your suggestion. After installing the specific versions it worked like a charm!

To elaborate for anyone else who faces this issue:

pip freeze and pip show did not work for me as it only shows the following packages:

Package Version


gyp 0.1
mercurial 6.3.2
pip 23.0.1
setuptools 66.1.1
six 1.16.0
wheel 0.38.4

  1. Run the following python code to find out the versions of the packages in the platform:

import openai
import llama_index
import trulens_eval
print(“OpenAI GPT version:”, openai.version)
print(“llama-index version:”, llama_index.version)
print(“trulens_eval version:”, trulens_eval.version)

  1. Install the specific versions in colab alongwith other dependencies. The versions that worked for me:

!pip install openai==1.3.5
!pip install llama-index==0.9.8
!pip install python-dotenv
!pip install trulens_eval==0.18.1
!pip install pypdf
!pip install sentence_transformers

Regards,
Tushar

Thank you for sharing the information with our community as well. I’m going to close this thread now.