Find answers from the community

Updated 9 months ago

what would be the best way to extract

what would be the best way to extract keywords from a query string? would it be best to call a fast llm ~7b, or is there something native inside llama index to do this? I would like to extract keywords from the query and then use a node_postprocessor to look for said keywords in node metadata. not sure how practical this is but i find some instances in my testing where I think this would be useful
s
L
3 comments
I would use something like this to do the filtering but curious on best practices for getting the keywords to begin the node post processing

Plain Text
from llama_index.core.postprocessor import KeywordNodePostprocessor

postprocessor = KeywordNodePostprocessor(
    required_keywords=["word1", "word2"], exclude_keywords=["word3", "word4"]
)

postprocessor.postprocess_nodes(nodes)
LLM will definitely give the most diverse keywords

Other smaller models (like stuff based on BERT, or NLTK) can extract keywords only from the text that is actually present
k. that's what i was thinking too. thanks @Logan M
Add a reply
Sign up and join the conversation on Discord