-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Feat: Support Ranking Method #1820
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
base: main
Are you sure you want to change the base?
Conversation
Wait this actually looks fire, why hasn't this been merged |
Yeah, this looks really cool! The code for this is short and sweet, would love to see it merged! |
You save my day.. really thanks! |
Hi @abetlen. Thank you for your support. May I have your opinion on this PR? |
def embed( | ||
self, | ||
input: Union[str, List[str]], | ||
normalize: bool = False, | ||
truncate: bool = True, | ||
return_count: bool = False, | ||
special_tokenize: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yutyan0119 ,
This is an awesome PR. Nice work! I use this almost everyday.
I have a suggestion. Would it be better to rename the arg. 'special_tokenize' -> 'add_special_tokens'? As the tokenizer endpoint has a arg. named 'add_special', this renaming would bring better fluency.
Moreover, I would like you to add an error handling mechanism as follows:
- If the "documents" is an empty list then, return None.
I have faced this issue a few times and this will be a nice "user-comfort" edit.
Description
Hello @abetlen! Thank you for your work on this library.
This PR introduces a new rank method in the Llama class, enabling users to rank documents based on their relevance to a given query. This functionality is useful for tasks such as document retrieval and relevance scoring within a list of documents. This addition corresponds to the feature introduced in llama.cpp PR #9510 and also addresses the request for re-ranking support mentioned in Issue #1794.
Changes Made:
1. New Method: rank
2. Embed Method Enhancement
Usage Example
output