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

simple zero-shot eval function: generation length #84

Open
norakassner opened this issue Dec 13, 2021 · 1 comment
Open

simple zero-shot eval function: generation length #84

norakassner opened this issue Dec 13, 2021 · 1 comment
Assignees

Comments

@norakassner
Copy link
Collaborator

No description provided.

@norakassner norakassner moved this to Generation Length in Modeling Metadata Dec 13, 2021
@norakassner norakassner self-assigned this Dec 13, 2021
@norakassner norakassner changed the title simple zero-shot eval function simple zero-shot eval function: generation length Dec 13, 2021
@chkla
Copy link
Collaborator

chkla commented Feb 4, 2022

For a simple evaluation without defined categories for length, we can add a percentage threshold and check if the generated text is in a certain range. Possible implementation:

def eval_generation_length(generated_text, expected_len, threshold):
	"""
	Our goal is to evaluate the length of a given generated text string in terms of expected and actual length with a threshold.

	Example: 
		Prompt: "a text with around [100] chars" expected length 100 chars, 
		Generated text: "the cake is a lie ..." actual text length 93,
		Evaluation with threshold 10%: check if text 93 is between 100-10% and 100+10% 
	"""

	input_len = len(generated_text)
	threshold_range = expected_len*(threshold/100)

	expected_len_min = expected_len-threshold_range # len - threshold
	expected_len_max = expected_len+threshold_range # len + threshold

	print("For a given text with {} chars, the threshold {} is used to define a soft boundary to check if it is between {} and {}".format(input_len, threshold, expected_len_min, input_len, expected_len_max))

	if expected_len_min < input_len and input_len < expected_len_max:
		return True
	else:
		return False

if __name__ == "__main__":
	text = "Obama was the guest of honor at the conference. Bieber performed at the concert last night." # generated text
	prompt_defined_len = 100 # text with x chars
	threshold = 25 # x %

	print("Evaluation: {}".format(eval_generation_length(text, prompt_defined_len, threshold)))

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

No branches or pull requests

2 participants