stanfordnlp / dspy

DSPy: The framework for programming—not prompting—foundation models
https://dspy.ai
MIT License
18.73k stars 1.43k forks source link

LlamaIndex integration cookbook issue #1209

Closed tituslhy closed 4 months ago

tituslhy commented 4 months ago

Hello!

I was following the cookbook (https://github.com/stanfordnlp/dspy/blob/main/examples/llamaindex/dspy_llamaindex_rag.ipynb) but changed the following variables:

turbo = dspy.OllamaLocal(model="llama3")

and I specified the embeddings model to be a HuggingFace model. LlamaIndex does use OpenAI embeddings as its default embeddings model if this specification isn't made.

from llama_index.core import (
    SimpleDirectoryReader, 
    VectorStoreIndex,
    Settings
)
from llama_index.embeddings.huggingface import HuggingFaceEmbedding

Settings.embed_model = HuggingFaceEmbedding()

docs = SimpleDirectoryReader(
    input_files = ["paul_graham_essay.txt"]
).load_data()

index = VectorStoreIndex.from_documents(docs)

retriever = index.as_retriever(similarity_top_k=2)

I faced an error message when running the cell

from dspy.teleprompt import BootstrapFewShot
from llama_index.core.evaluation import SemanticSimilarityEvaluator

evaluator = SemanticSimilarityEvaluator(similarity_threshold=0.5)

def validate_context_and_answer(example, pred, trace=None):
    """We check that the predicted answer is correct, and that
    the retrieved context does contain the answer."""
    result = evaluator.evaluate(response = pred.answer,
                                reference = example.answer)
    return result.passing

teleprompter = BootstrapFewShot(
    max_labeled_demos=0,
    metric=validate_context_and_answer
)

#compile
compiled_dspy_qp = teleprompter.compile(dspy_qp, trainset=train_examples)

And me error message is: Failed to run or to evaluate example Example({'query_str': 'What did the author do growing up?', 'answer': 'The author wrote short stories and also worked on programming.'}) (input_keys={'query_str'}) with <function validate_context_and_answer at 0x7feac38a1f80> due to 'HuggingFaceEmbedding' object has no attribute '_model'. [dspy.teleprompt.bootstrap] filename=bootstrap.py lineno=211

Can I check if this integration only works for OpenAI LLMs and embedding models?

okhat commented 4 months ago

The issue seems related to llamaindex's HuggingFaceEmbedding when it's used in the new integration? It will help if we see a fuller error trace.

You can pass max_errors=1 to the teleprompter and see if this prints out the full stack trace.

tituslhy commented 4 months ago

Thanks. I passed max_errors=1 and it printed the trace below. Should I raise this ticket on LlamaIndex? Also, I was able to make it work using LlamaIndex's OllamaEmbeddings workaround. I think this issue only exists for the HuggingFaceEmbedding class.


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[23], [line 20](vscode-notebook-cell:?execution_count=23&line=20)
     [13](vscode-notebook-cell:?execution_count=23&line=13) teleprompter = BootstrapFewShot(
     [14](vscode-notebook-cell:?execution_count=23&line=14)     max_labeled_demos=0,
     [15](vscode-notebook-cell:?execution_count=23&line=15)     metric=validate_context_and_answer,
     [16](vscode-notebook-cell:?execution_count=23&line=16)     max_errors=1
     [17](vscode-notebook-cell:?execution_count=23&line=17) )
     [19](vscode-notebook-cell:?execution_count=23&line=19) #compile
---> [20](vscode-notebook-cell:?execution_count=23&line=20) compiled_dspy_qp = teleprompter.compile(dspy_qp, trainset=train_examples)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:84, in BootstrapFewShot.compile(self, student, teacher, trainset)
     [82](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:82) self._prepare_student_and_teacher(student, teacher)
     [83](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:83) self._prepare_predictor_mappings()
---> [84](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:84) self._bootstrap()
     [86](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:86) self.student = self._train()
     [87](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:87) self.student._compiled = True

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:154, in BootstrapFewShot._bootstrap(self, max_bootstraps)
    [151](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:151)     break
    [153](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:153) if example_idx not in bootstrapped:
--> [154](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:154)     success = self._bootstrap_one_example(example, round_idx)
    [156](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:156)     if success:
    [157](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:157)         bootstrapped[example_idx] = True

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:210, in BootstrapFewShot._bootstrap_one_example(self, example, round_idx)
    [208](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:208)         current_error_count = self.error_count
    [209](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:209)     if current_error_count >= self.max_errors:
--> [210](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:210)         raise e
    [211](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:211)     dspy.logger.error(f"Failed to run or to evaluate example {example} with {self.metric} due to {e}.")
    [213](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:213) if success:

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:190, in BootstrapFewShot._bootstrap_one_example(self, example, round_idx)
    [187](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:187)     predictor_cache[name] = predictor.demos
    [188](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:188)     predictor.demos = [x for x in predictor.demos if x != example]
--> [190](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:190) prediction = teacher(**example.inputs())
    [191](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:191) trace = dsp.settings.trace
    [193](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:193) for name, predictor in teacher.named_predictors():

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/primitives/program.py:26, in Module.__call__(self, *args, **kwargs)
     [25](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/primitives/program.py:25) def __call__(self, *args, **kwargs):
---> [26](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/primitives/program.py:26)     return self.forward(*args, **kwargs)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:261, in LlamaIndexModule.forward(self, **kwargs)
    [259](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:259) def forward(self, **kwargs: Any) -> Dict[str, Any]:
    [260](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:260)     """Forward."""
--> [261](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:261)     output_dict = self.query_pipeline.run(**kwargs, return_values_direct=False)
    [262](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:262)     return dspy.Prediction(**output_dict)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:342, in QueryPipeline.run(self, return_values_direct, callback_manager, batch, *args, **kwargs)
    [338](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:338)     query_payload = json.dumps(str(kwargs))
    [339](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:339) with self.callback_manager.event(
    [340](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:340)     CBEventType.QUERY, payload={EventPayload.QUERY_STR: query_payload}
    [341](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:341) ) as query_event:
--> [342](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:342)     outputs, _ = self._run(
    [343](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:343)         *args,
    [344](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:344)         return_values_direct=return_values_direct,
    [345](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:345)         show_intermediates=False,
    [346](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:346)         batch=batch,
    [347](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:347)         **kwargs,
    [348](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:348)     )
    [350](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:350)     return outputs

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:706, in QueryPipeline._run(self, return_values_direct, show_intermediates, batch, *args, **kwargs)
    [704](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:704)     return result_outputs, intermediates
    [705](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:705) else:
--> [706](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:706)     result_outputs, intermediates = self._run_multi(
    [707](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:707)         {root_key: kwargs}, show_intermediates=show_intermediates
    [708](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:708)     )
    [710](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:710)     return (
    [711](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:711)         self._get_single_result_output(result_outputs, return_values_direct),
    [712](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:712)         intermediates,
    [713](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:713)     )

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:857, in QueryPipeline._run_multi(self, module_input_dict, show_intermediates)
    [855](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:855) if self.verbose:
    [856](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:856)     print_debug_input(module_key, module_input)
--> [857](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:857) output_dict = module.run_component(**module_input)
    [859](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:859) if (
    [860](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:860)     show_intermediates
    [861](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:861)     and module_key not in run_state.intermediate_outputs
    [862](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:862) ):
    [863](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:863)     run_state.intermediate_outputs[module_key] = ComponentIntermediates(
    [864](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:864)         inputs=module_input, outputs=output_dict
    [865](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:865)     )

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:201, in QueryComponent.run_component(self, **kwargs)
    [199](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:199) kwargs.update(self.partial_dict)
    [200](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:200) kwargs = self.validate_component_inputs(kwargs)
--> [201](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:201) component_outputs = self._run_component(**kwargs)
    [202](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:202) return self.validate_component_outputs(component_outputs)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:345, in RetrieverComponent._run_component(self, **kwargs)
    [343](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:343) def _run_component(self, **kwargs: Any) -> Any:
    [344](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:344)     """Run component."""
--> [345](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:345)     output = self.retriever.retrieve(kwargs["input"])
    [346](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:346)     return {"output": output}

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    [226](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:226) self.span_enter(
    [227](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:227)     id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
    [228](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:228) )
    [229](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:229) try:
--> [230](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230)     result = func(*args, **kwargs)
    [231](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:231) except BaseException as e:
    [232](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:232)     self.event(SpanDropEvent(span_id=id_, err_str=str(e)))

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:243, in BaseRetriever.retrieve(self, str_or_query_bundle)
    [238](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:238) with self.callback_manager.as_trace("query"):
    [239](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:239)     with self.callback_manager.event(
    [240](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:240)         CBEventType.RETRIEVE,
    [241](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:241)         payload={EventPayload.QUERY_STR: query_bundle.query_str},
    [242](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:242)     ) as retrieve_event:
--> [243](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:243)         nodes = self._retrieve(query_bundle)
    [244](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:244)         nodes = self._handle_recursive_retrieval(query_bundle, nodes)
    [245](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:245)         retrieve_event.on_end(
    [246](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:246)             payload={EventPayload.NODES: nodes},
    [247](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:247)         )

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    [226](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:226) self.span_enter(
    [227](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:227)     id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
    [228](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:228) )
    [229](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:229) try:
--> [230](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230)     result = func(*args, **kwargs)
    [231](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:231) except BaseException as e:
    [232](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:232)     self.event(SpanDropEvent(span_id=id_, err_str=str(e)))

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:97, in VectorIndexRetriever._retrieve(self, query_bundle)
     [94](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:94) if self._vector_store.is_embedding_query:
     [95](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:95)     if query_bundle.embedding is None and len(query_bundle.embedding_strs) > 0:
     [96](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:96)         query_bundle.embedding = (
---> [97](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:97)             self._embed_model.get_agg_embedding_from_queries(
     [98](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:98)                 query_bundle.embedding_strs
     [99](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:99)             )
    [100](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:100)         )
    [101](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:101) return self._get_nodes_with_embeddings(query_bundle)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:184, in BaseEmbedding.get_agg_embedding_from_queries(self, queries, agg_fn)
    [178](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:178) def get_agg_embedding_from_queries(
    [179](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:179)     self,
    [180](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:180)     queries: List[str],
    [181](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:181)     agg_fn: Optional[Callable[..., Embedding]] = None,
    [182](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:182) ) -> Embedding:
    [183](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:183)     """Get aggregated embedding from multiple queries."""
--> [184](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:184)     query_embeddings = [self.get_query_embedding(query) for query in queries]
    [185](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:185)     agg_fn = agg_fn or mean_agg
    [186](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:186)     return agg_fn(query_embeddings)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    [226](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:226) self.span_enter(
    [227](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:227)     id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
    [228](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:228) )
    [229](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:229) try:
--> [230](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230)     result = func(*args, **kwargs)
    [231](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:231) except BaseException as e:
    [232](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:232)     self.event(SpanDropEvent(span_id=id_, err_str=str(e)))

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:133, in BaseEmbedding.get_query_embedding(self, query)
    [125](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:125) dispatcher.event(
    [126](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:126)     EmbeddingStartEvent(
    [127](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:127)         model_dict=model_dict,
    [128](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:128)     )
    [129](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:129) )
    [130](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:130) with self.callback_manager.event(
    [131](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:131)     CBEventType.EMBEDDING, payload={EventPayload.SERIALIZED: self.to_dict()}
    [132](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:132) ) as event:
--> [133](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:133)     query_embedding = self._get_query_embedding(query)
    [135](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:135)     event.on_end(
    [136](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:136)         payload={
    [137](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:137)             EventPayload.CHUNKS: [query],
    [138](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:138)             EventPayload.EMBEDDINGS: [query_embedding],
    [139](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:139)         },
    [140](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:140)     )
    [141](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:141) dispatcher.event(
    [142](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:142)     EmbeddingEndEvent(
    [143](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:143)         chunks=[query],
    [144](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:144)         embeddings=[query_embedding],
    [145](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:145)     )
    [146](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:146) )

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    [226](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:226) self.span_enter(
    [227](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:227)     id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
    [228](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:228) )
    [229](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:229) try:
--> [230](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230)     result = func(*args, **kwargs)
    [231](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:231) except BaseException as e:
    [232](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:232)     self.event(SpanDropEvent(span_id=id_, err_str=str(e)))

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:133, in HuggingFaceEmbedding._get_query_embedding(self, query)
    [131](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:131) def _get_query_embedding(self, query: str) -> List[float]:
    [132](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:132)     """Get query embedding."""
--> [133](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:133)     return self._embed(query, prompt_name="query")

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:124, in HuggingFaceEmbedding._embed(self, sentences, prompt_name)
    [118](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:118) def _embed(
    [119](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:119)     self,
    [120](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:120)     sentences: List[str],
    [121](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:121)     prompt_name: Optional[str] = None,
    [122](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:122) ) -> List[List[float]]:
    [123](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:123)     """Embed sentences."""
--> [124](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:124)     return self._model.encode(
    [125](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:125)         sentences,
    [126](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:126)         batch_size=self.embed_batch_size,
    [127](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:127)         prompt_name=prompt_name,
    [128](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:128)         normalize_embeddings=self.normalize,
    [129](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:129)     ).tolist()

AttributeError: 'HuggingFaceEmbedding' object has no attribute '_model'
```---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[23], [line 20](vscode-notebook-cell:?execution_count=23&line=20)
     [13](vscode-notebook-cell:?execution_count=23&line=13) teleprompter = BootstrapFewShot(
     [14](vscode-notebook-cell:?execution_count=23&line=14)     max_labeled_demos=0,
     [15](vscode-notebook-cell:?execution_count=23&line=15)     metric=validate_context_and_answer,
     [16](vscode-notebook-cell:?execution_count=23&line=16)     max_errors=1
     [17](vscode-notebook-cell:?execution_count=23&line=17) )
     [19](vscode-notebook-cell:?execution_count=23&line=19) #compile
---> [20](vscode-notebook-cell:?execution_count=23&line=20) compiled_dspy_qp = teleprompter.compile(dspy_qp, trainset=train_examples)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:84, in BootstrapFewShot.compile(self, student, teacher, trainset)
     [82](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:82) self._prepare_student_and_teacher(student, teacher)
     [83](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:83) self._prepare_predictor_mappings()
---> [84](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:84) self._bootstrap()
     [86](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:86) self.student = self._train()
     [87](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:87) self.student._compiled = True

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:154, in BootstrapFewShot._bootstrap(self, max_bootstraps)
    [151](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:151)     break
    [153](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:153) if example_idx not in bootstrapped:
--> [154](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:154)     success = self._bootstrap_one_example(example, round_idx)
    [156](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:156)     if success:
    [157](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:157)         bootstrapped[example_idx] = True

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:210, in BootstrapFewShot._bootstrap_one_example(self, example, round_idx)
    [208](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:208)         current_error_count = self.error_count
    [209](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:209)     if current_error_count >= self.max_errors:
--> [210](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:210)         raise e
    [211](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:211)     dspy.logger.error(f"Failed to run or to evaluate example {example} with {self.metric} due to {e}.")
    [213](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:213) if success:

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:190, in BootstrapFewShot._bootstrap_one_example(self, example, round_idx)
    [187](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:187)     predictor_cache[name] = predictor.demos
    [188](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:188)     predictor.demos = [x for x in predictor.demos if x != example]
--> [190](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:190) prediction = teacher(**example.inputs())
    [191](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:191) trace = dsp.settings.trace
    [193](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/teleprompt/bootstrap.py:193) for name, predictor in teacher.named_predictors():

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/primitives/program.py:26, in Module.__call__(self, *args, **kwargs)
     [25](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/primitives/program.py:25) def __call__(self, *args, **kwargs):
---> [26](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/primitives/program.py:26)     return self.forward(*args, **kwargs)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:261, in LlamaIndexModule.forward(self, **kwargs)
    [259](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:259) def forward(self, **kwargs: Any) -> Dict[str, Any]:
    [260](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:260)     """Forward."""
--> [261](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:261)     output_dict = self.query_pipeline.run(**kwargs, return_values_direct=False)
    [262](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/dspy/predict/llamaindex.py:262)     return dspy.Prediction(**output_dict)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:342, in QueryPipeline.run(self, return_values_direct, callback_manager, batch, *args, **kwargs)
    [338](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:338)     query_payload = json.dumps(str(kwargs))
    [339](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:339) with self.callback_manager.event(
    [340](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:340)     CBEventType.QUERY, payload={EventPayload.QUERY_STR: query_payload}
    [341](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:341) ) as query_event:
--> [342](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:342)     outputs, _ = self._run(
    [343](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:343)         *args,
    [344](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:344)         return_values_direct=return_values_direct,
    [345](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:345)         show_intermediates=False,
    [346](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:346)         batch=batch,
    [347](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:347)         **kwargs,
    [348](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:348)     )
    [350](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:350)     return outputs

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:706, in QueryPipeline._run(self, return_values_direct, show_intermediates, batch, *args, **kwargs)
    [704](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:704)     return result_outputs, intermediates
    [705](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:705) else:
--> [706](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:706)     result_outputs, intermediates = self._run_multi(
    [707](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:707)         {root_key: kwargs}, show_intermediates=show_intermediates
    [708](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:708)     )
    [710](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:710)     return (
    [711](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:711)         self._get_single_result_output(result_outputs, return_values_direct),
    [712](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:712)         intermediates,
    [713](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:713)     )

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:857, in QueryPipeline._run_multi(self, module_input_dict, show_intermediates)
    [855](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:855) if self.verbose:
    [856](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:856)     print_debug_input(module_key, module_input)
--> [857](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:857) output_dict = module.run_component(**module_input)
    [859](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:859) if (
    [860](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:860)     show_intermediates
    [861](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:861)     and module_key not in run_state.intermediate_outputs
    [862](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:862) ):
    [863](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:863)     run_state.intermediate_outputs[module_key] = ComponentIntermediates(
    [864](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:864)         inputs=module_input, outputs=output_dict
    [865](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/query_pipeline/query.py:865)     )

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:201, in QueryComponent.run_component(self, **kwargs)
    [199](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:199) kwargs.update(self.partial_dict)
    [200](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:200) kwargs = self.validate_component_inputs(kwargs)
--> [201](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:201) component_outputs = self._run_component(**kwargs)
    [202](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/query_pipeline/query.py:202) return self.validate_component_outputs(component_outputs)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:345, in RetrieverComponent._run_component(self, **kwargs)
    [343](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:343) def _run_component(self, **kwargs: Any) -> Any:
    [344](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:344)     """Run component."""
--> [345](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:345)     output = self.retriever.retrieve(kwargs["input"])
    [346](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:346)     return {"output": output}

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    [226](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:226) self.span_enter(
    [227](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:227)     id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
    [228](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:228) )
    [229](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:229) try:
--> [230](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230)     result = func(*args, **kwargs)
    [231](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:231) except BaseException as e:
    [232](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:232)     self.event(SpanDropEvent(span_id=id_, err_str=str(e)))

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:243, in BaseRetriever.retrieve(self, str_or_query_bundle)
    [238](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:238) with self.callback_manager.as_trace("query"):
    [239](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:239)     with self.callback_manager.event(
    [240](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:240)         CBEventType.RETRIEVE,
    [241](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:241)         payload={EventPayload.QUERY_STR: query_bundle.query_str},
    [242](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:242)     ) as retrieve_event:
--> [243](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:243)         nodes = self._retrieve(query_bundle)
    [244](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:244)         nodes = self._handle_recursive_retrieval(query_bundle, nodes)
    [245](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:245)         retrieve_event.on_end(
    [246](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:246)             payload={EventPayload.NODES: nodes},
    [247](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/base_retriever.py:247)         )

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    [226](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:226) self.span_enter(
    [227](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:227)     id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
    [228](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:228) )
    [229](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:229) try:
--> [230](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230)     result = func(*args, **kwargs)
    [231](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:231) except BaseException as e:
    [232](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:232)     self.event(SpanDropEvent(span_id=id_, err_str=str(e)))

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:97, in VectorIndexRetriever._retrieve(self, query_bundle)
     [94](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:94) if self._vector_store.is_embedding_query:
     [95](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:95)     if query_bundle.embedding is None and len(query_bundle.embedding_strs) > 0:
     [96](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:96)         query_bundle.embedding = (
---> [97](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:97)             self._embed_model.get_agg_embedding_from_queries(
     [98](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:98)                 query_bundle.embedding_strs
     [99](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:99)             )
    [100](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:100)         )
    [101](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/indices/vector_store/retrievers/retriever.py:101) return self._get_nodes_with_embeddings(query_bundle)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:184, in BaseEmbedding.get_agg_embedding_from_queries(self, queries, agg_fn)
    [178](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:178) def get_agg_embedding_from_queries(
    [179](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:179)     self,
    [180](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:180)     queries: List[str],
    [181](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:181)     agg_fn: Optional[Callable[..., Embedding]] = None,
    [182](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:182) ) -> Embedding:
    [183](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:183)     """Get aggregated embedding from multiple queries."""
--> [184](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:184)     query_embeddings = [self.get_query_embedding(query) for query in queries]
    [185](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:185)     agg_fn = agg_fn or mean_agg
    [186](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:186)     return agg_fn(query_embeddings)

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    [226](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:226) self.span_enter(
    [227](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:227)     id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
    [228](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:228) )
    [229](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:229) try:
--> [230](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230)     result = func(*args, **kwargs)
    [231](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:231) except BaseException as e:
    [232](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:232)     self.event(SpanDropEvent(span_id=id_, err_str=str(e)))

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:133, in BaseEmbedding.get_query_embedding(self, query)
    [125](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:125) dispatcher.event(
    [126](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:126)     EmbeddingStartEvent(
    [127](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:127)         model_dict=model_dict,
    [128](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:128)     )
    [129](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:129) )
    [130](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:130) with self.callback_manager.event(
    [131](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:131)     CBEventType.EMBEDDING, payload={EventPayload.SERIALIZED: self.to_dict()}
    [132](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:132) ) as event:
--> [133](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:133)     query_embedding = self._get_query_embedding(query)
    [135](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:135)     event.on_end(
    [136](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:136)         payload={
    [137](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:137)             EventPayload.CHUNKS: [query],
    [138](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:138)             EventPayload.EMBEDDINGS: [query_embedding],
    [139](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:139)         },
    [140](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:140)     )
    [141](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:141) dispatcher.event(
    [142](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:142)     EmbeddingEndEvent(
    [143](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:143)         chunks=[query],
    [144](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:144)         embeddings=[query_embedding],
    [145](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:145)     )
    [146](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/base/embeddings/base.py:146) )

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230, in Dispatcher.span.<locals>.wrapper(func, instance, args, kwargs)
    [226](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:226) self.span_enter(
    [227](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:227)     id_=id_, bound_args=bound_args, instance=instance, parent_id=parent_id
    [228](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:228) )
    [229](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:229) try:
--> [230](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:230)     result = func(*args, **kwargs)
    [231](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:231) except BaseException as e:
    [232](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/core/instrumentation/dispatcher.py:232)     self.event(SpanDropEvent(span_id=id_, err_str=str(e)))

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:133, in HuggingFaceEmbedding._get_query_embedding(self, query)
    [131](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:131) def _get_query_embedding(self, query: str) -> List[float]:
    [132](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:132)     """Get query embedding."""
--> [133](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:133)     return self._embed(query, prompt_name="query")

File /App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:124, in HuggingFaceEmbedding._embed(self, sentences, prompt_name)
    [118](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:118) def _embed(
    [119](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:119)     self,
    [120](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:120)     sentences: List[str],
    [121](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:121)     prompt_name: Optional[str] = None,
    [122](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:122) ) -> List[List[float]]:
    [123](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:123)     """Embed sentences."""
--> [124](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:124)     return self._model.encode(
    [125](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:125)         sentences,
    [126](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:126)         batch_size=self.embed_batch_size,
    [127](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:127)         prompt_name=prompt_name,
    [128](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:128)         normalize_embeddings=self.normalize,
    [129](https://vscode-remote+ssh-002dremote-002bsgsv-002dprd-002dcmva01.vscode-resource.vscode-cdn.net/App/tlim2/Anaconda3/envs/llamaindex/lib/python3.12/site-packages/llama_index/embeddings/huggingface/base.py:129)     ).tolist()

AttributeError: 'HuggingFaceEmbedding' object has no attribute '_model'
okhat commented 4 months ago

I was able to make it work using LlamaIndex's OllamaEmbeddings workaround. I think this issue only exists for the HuggingFaceEmbedding class

That's a really good observation. I think you should include this fact and open it on the llamaindex repo, then. It seems outside DSPy.

That said, if you could show them the snippet below, which is from dspy/predict/llamaindex.py Lines 259-262:

def forward(self, **kwargs: Any) -> Dict[str, Any]:
    """Forward."""
    output_dict = self.query_pipeline.run(**kwargs, return_values_direct=False)
    return dspy.Prediction(**output_dict)
learnbott commented 3 months ago

FWIW, it is an issue with copy.deepcopy() on a LlamaIndex vector stores using HuggingFaceEmbedding. Through copy.deepcopy() HuggingFaceEmbedding loses the attribute _model. This becomes an issue in the teleprompters, as here: https://github.com/stanfordnlp/dspy/blob/d8b8909773fc31e72cec093db2f26109590e524e/dspy/teleprompt/bootstrap.py#L96 where student.reset_copy() uses copy.deepcopy(). Outside the teleprompter everything is kosher.

I submitted a bug fix request at LlamaIndex (https://github.com/run-llama/llama_index/issues/14837)

learnbott commented 3 months ago

This bandaid seem to work for https://github.com/stanfordnlp/dspy/blob/d8b8909773fc31e72cec093db2f26109590e524e/dspy/primitives/module.py#L106

def reset_copy(self):
        import llama_index
        obj = copy.deepcopy(self)
        ######################################################
        for attribute_name in dir(obj):
            if not attribute_name.startswith('_'):
                attribute_value = getattr(obj, attribute_name)
                if isinstance(attribute_value, llama_index.core.indices.vector_store.retrievers.retriever.VectorIndexRetriever):
                    setattr(obj, attribute_name, getattr(self, attribute_name))
        ######################################################
        for param in obj.parameters():
            param.reset()

OR better yet in llama_index/core/schema.py comment out line 84 84 # state["__private_attribute_values__"] = {}