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

Chunking for confidence if context exceeds context length #635

Merged
merged 6 commits into from
Nov 20, 2023

Conversation

rajasbansal
Copy link
Contributor

@rajasbansal rajasbansal commented Nov 17, 2023

In this PR, we will chunk confidence prompts in order to support getting confidence from a model having context length smaller than the context length supported by the generation model. We do this by chunking the document into smaller chunks and sending the prompt along with the smaller chunks of the document. we support multiple aggregation functions over the confidence chunks.

For extraction, max makes more sense than mean which might make more sense for a classification task

Copy link
Contributor

@nihit nihit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

"""Returns the number of tokens in the prompt"""
return len(self.confidence_tokenizer.encode(str(inp)))

def chunk_string(self, inp: str, chunk_size: int) -> List[str]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to utils.py ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uses the tokenizer, for encoding and decoding so kept it here

@rajasbansal rajasbansal merged commit d4b0c0c into main Nov 20, 2023
2 checks passed
@rajasbansal rajasbansal deleted the confidence_chunking branch November 20, 2023 19:57
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

Successfully merging this pull request may close these issues.

2 participants