texts = [
"Basquetball is a great sport.",
"Fly me to the moon is one of my favourite songs.",
"The Celtics are my favourite team.",
"This is a document about the Boston Celtics",
"I simply love going to the movies",
"The Boston Celtics won the game by 20 points",
"This is just a random text.",
"Elden Ring is one of the best games in the last 15 years.",
"L. Kornet is one of the best Celtics players.",
"Larry Bird was an iconic NBA player.",
]
用户提问如下:
query = "What can you tell me about the Celtics?"
那么按照相似检索结果排序如下:
[Document(page_content='This is a document about the Boston Celtics', metadata={}),
Document(page_content='The Celtics are my favourite team.', metadata={}),
Document(page_content='L. Kornet is one of the best Celtics players.', metadata={}),
Document(page_content='The Boston Celtics won the game by 20 points', metadata={}),
Document(page_content='Larry Bird was an iconic NBA player.', metadata={}),
Document(page_content='Elden Ring is one of the best games in the last 15 years.', metadata={}),
Document(page_content='Basquetball is a great sport.', metadata={}),
Document(page_content='I simply love going to the movies', metadata={}),
Document(page_content='Fly me to the moon is one of my favourite songs.', metadata={}),
Document(page_content='This is just a random text.', metadata={})]
再经过重排序之后的结果:
[Document(page_content='The Celtics are my favourite team.', metadata={}),
Document(page_content='The Boston Celtics won the game by 20 points', metadata={}),
Document(page_content='Elden Ring is one of the best games in the last 15 years.', metadata={}),
Document(page_content='I simply love going to the movies', metadata={}),
Document(page_content='This is just a random text.', metadata={}),
Document(page_content='Fly me to the moon is one of my favourite songs.', metadata={}),
Document(page_content='Basquetball is a great sport.', metadata={}),
Document(page_content='Larry Bird was an iconic NBA player.', metadata={}),
Document(page_content='L. Kornet is one of the best Celtics players.', metadata={}),
Document(page_content='This is a document about the Boston Celtics', metadata={})]
可以看到,此前的This is just a random text.这种无关的文本已经被调整到中间位置了。新的问答将基于这种问答排序结果问答。