Create keywords using KeyLLM
masterUse KeyLLM to generate keywords that do not necessarily need to appear in the input documents. This process asks the LLM to come up with keywords based on the document content.
First, install the required LLM provider (e.g., openai):
pip install openaiThen, initialize the OpenAI wrapper and pass it to KeyLLM.
import openai
from keybert.llm import OpenAI
from keybert import KeyLLM
# Create your LLM
client = openai.OpenAI(api_key=MY_API_KEY)
llm = OpenAI(client)
# Load it in KeyLLM
kw_model = KeyLLM(llm)
# Extract keywords
keywords = kw_model.extract_keywords(documents)