----------------------
Here's an example of using
percentile_cutoff
with the
SentenceEmbeddingOptimizer
in GPT index:
from llama_index import GPTSimpleVectorIndex
from llama_index.optimization.optimizer import SentenceEmbeddingOptimizer
# load from disk
index = GPTSimpleVectorIndex.load_from_disk('simple_vector_index.json')
print("Without optimization")
start_time = time.time()
res = index.query("What is the population of Berlin?")
end_time = time.time()
print("Total time elapsed: {}".format(end_time - start_time))
print("Answer: {}".format(res))
print("With optimization")
start_time = time.time()
res = index.query("What is the population of Berlin?", optimizer=SentenceEmbeddingOptimizer(percentile_cutoff=0.5))
end_time = time.time()
print("Total time elapsed: {}".format(end_time - start_time))
print("Answer: {}".format(res))
In this example, the
percentile_cutoff
is set to 0.5, which means that the optimizer will only consider the top 50% of sentences based on their similarity to the query when optimizing the input text.
Source: (
https://gpt-index.readthedocs.io/en/latest/how_to/analysis/optimizers.html)
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------