Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyLLM parameter control #200

Open
ChettakattuA opened this issue Jan 15, 2024 · 3 comments
Open

KeyLLM parameter control #200

ChettakattuA opened this issue Jan 15, 2024 · 3 comments

Comments

@ChettakattuA
Copy link

I am using KeyLLM for a keyword extraction tool. I have already implemented the extraction tool with KeyBERT now since LLM seems to be a cool approach i would like to switch it to KeyLLM.

But the parameters of KeyLLm seems to be too controlled. For example we had many parameters like stopwords, diversity, topN etc in keyBERT which gave us a great control over the keywords we can get but KeyLLM lack trthese parameters.

but even if we mention it in prompt the the attempt seems to fail in many ways.

import openai
from keybert.llm import OpenAI
from keybert import KeyLLM

Create your LLM

openai.api_key = "sk-............."
prompt = """
I have the following document:
[DOCUMENT]

Display 10 terms that best describe the document. Extract terms only from document.
Avoid the keywords in following list:
RESIN, Grant Agreement

"""

[['Climate Resilient Cities', 'Infrastructures', 'Fact Sheet', 'RESIN', '']]

Which seems to be doing nothing the prompt mentions.

Can you suggest me some edits?

@MaartenGr
Copy link
Owner

The prompt template is indeed key in this case but it all depends on the LLM that you choose. Some are better than others at following instructions. For instance, GPT-4 tends to follow instructions much better than GPT-3.5. Moreover, you can use KeyBERT together with KeyLLM. There, the candidate keywords will be passed to KeyLLM and the LLM can still decide by itself which to keep and which to throw away.

@ChettakattuA
Copy link
Author

ChettakattuA commented Jan 25, 2024

So how is exactly KeyBERT+KeyLLM work? just prompting and asking llm to give as keywords from a list and it make use of weighting system to find the answer than the traditional QA we do like in chat gpt?
Also, if we first use KeyBERT then imagine we got 5 relevant keywords, do we just give these keywords as candidates to KeyLLM?? Or how exactly the combination works?

@MaartenGr
Copy link
Owner

So how is exactly KeyBERT+KeyLLM work? just prompting and asking llm to give as keywords from a list and it make use of weighting system to find the answer than the traditional QA we do like in chat gpt? Also, if we first use KeyBERT then imagine we got 5 relevant keywords, do we just give these keywords as candidates to KeyLLM?? Or how exactly the combination works?

You can find an extensive description on how it works here: https://maartengr.github.io/KeyBERT/guides/keyllm.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants