additional_kwargs
with the OpenAILike component in LlamaIndex. However, in the context of the OpenAI component, additional_kwargs
is listed as a field, suggesting it can be passed as an argument during initialization.from llama_index.llms import OpenAI llm = OpenAI( temperature=0.1, model="gpt-4", additional_kwargs={"logprobs": True} )
additional_kwargs
with OpenAILike, please refer to the LlamaIndex documentation ().retrieve
method of the Auto Merging Retriever returns a list of nodes, which are the results of the retrieval process. from llama_index.retrievers.auto_merging_retriever import AutoMergingRetriever # Define the base retriever and the auto merging retriever base_retriever = base_index.as_retriever(similarity_top_k=6) retriever = AutoMergingRetriever(base_retriever, storage_context, verbose=True) # Define the query string query_str = ( "What could be the potential outcomes of adjusting the amount of safety" " data used in the RLHF stage?" ) # Retrieve the nodes nodes = retriever.retrieve(query_str) # Print the number of nodes print(len(nodes))
nodes
is a list of merged nodes that match the query string. You can then process these nodes as you wish, without necessarily generating an answer.query_bundle
is a string object, and you're trying to access query_str
attribute from it, which doesn't exist because strings in Python don't have a query_str
attribute.query_bundle
is typically an instance of a QueryBundle
object, which does have a query_str
attribute. It seems like there might be a mistake in your code where query_bundle
is being assigned a string value instead of a QueryBundle
object.query_bundle
is typically used:from llama_index.query_bundle import QueryBundle # Define the query string query_str = "What could be the potential outcomes of adjusting the amount of safety data used in the RLHF stage?" # Create a QueryBundle object query_bundle = QueryBundle(query_str) # Now you can access query_str attribute from query_bundle print(query_bundle.query_str)
query_bundle
is correctly assigned a QueryBundle
object. If you continue to experience issues, please refer to the LlamaIndex documentation () for more information on how to use QueryBundle
.SimilarityPostprocessor
class in LlamaIndex. This class allows you to filter out nodes that have a similarity score below a certain threshold.from llama_index.postprocessor import SimilarityPostprocessor # Retrieve nodes nodes = retriever.retrieve("test query str") # Filter nodes below 0.75 similarity score processor = SimilarityPostprocessor(similarity_cutoff=0.75) filtered_nodes = processor.postprocess_nodes(nodes)
filtered_nodes
will only contain nodes that have a similarity score of 0.75 or higher.