Retrieve Chunks
Retrieve relevant chunks from a vector store using MMR (Maximal Marginal Relevance).
retrieve_relevant_chunks(self, query, paper_ids=None, top_k=25, mmr_diversity=1.0)
Retrieve the most relevant chunks for a query using maximal marginal relevance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
Query string |
required |
paper_ids
|
Optional[List[str]]
|
Optional list of paper IDs to filter by |
None
|
top_k
|
int
|
Number of chunks to retrieve |
25
|
mmr_diversity
|
float
|
Diversity parameter for MMR (higher = more diverse) |
1.0
|
Returns:
Type | Description |
---|---|
List[Document]
|
List of document chunks |
Source code in aiagents4pharma/talk2scholars/tools/pdf/utils/retrieve_chunks.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|