Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab 05 got IndexError: list index out of range when calling get_retrieved_nodes() #12

Open
SherryXDing opened this issue Oct 30, 2023 · 0 comments

Comments

@SherryXDing
Copy link

For notebooks in 05_Semantic_Search_with_Reranking, when calling get_retrieved_nodes() with with_reranker=True, got IndexError: list index out of range.
Detailed error message:

IndexError Traceback (most recent call last)
Cell In[26], line 1
----> 1 retrieved_nodes1_withreranker = get_retrieved_nodes(
2 "How has AWS evolved?",
3 vector_top_k=1,
4 reranker_top_n=1,
5 with_reranker=True,
6 )

Cell In[22], line 30, in get_retrieved_nodes(query_str, vector_top_k, reranker_top_n, with_reranker)
21 if with_reranker:
22 # configure reranker
23 reranker = LLMRerank(
24 choice_batch_size=10, # 5,
25 top_n=reranker_top_n,
(...)
28
29 )
---> 30 retrieved_nodes = reranker.postprocess_nodes(retrieved_nodes, query_bundle)
32 return retrieved_nodes

File /opt/conda/lib/python3.10/site-packages/llama_index/indices/postprocessor/llm_rerank.py:85, in LLMRerank.postprocess_nodes(self, nodes, query_bundle)
78 # call each batch independently
79 raw_response = self.service_context.llm_predictor.predict(
80 self.choice_select_prompt,
81 context_str=fmt_batch_str,
82 query_str=query_str,
83 )
---> 85 raw_choices, relevances = self._parse_choice_select_answer_fn(
86 raw_response, len(nodes_batch)
87 )
88 choice_idxs = [int(choice) - 1 for choice in raw_choices]
89 choice_nodes = [nodes_batch[idx] for idx in choice_idxs]

File /opt/conda/lib/python3.10/site-packages/llama_index/indices/utils.py:104, in default_parse_choice_select_answer_fn(answer, num_choices, raise_error)
98 else:
99 raise ValueError(
100 f"Invalid answer line: {answer_line}. "
101 "Answer line must be of the form: "
102 "answer_num: , answer_relevance: "
103 )
--> 104 answer_num = int(line_tokens[0].split(":")[1].strip())
105 if answer_num > num_choices:
106 continue

IndexError: list index out of range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant