Skip to content

Instantly share code, notes, and snippets.

@mrsndmn
Created October 23, 2023 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrsndmn/ff09eb7c1af844f168553dc260659ee8 to your computer and use it in GitHub Desktop.
Save mrsndmn/ff09eb7c1af844f168553dc260659ee8 to your computer and use it in GitHub Desktop.
from team_code.generate import get_ppl, generate_text, setup_model_and_tokenizer
def test_generate_text_get_ppl():
model, tokenizer = setup_model_and_tokenizer()
queries = [
[{"type": "text", "content": "What is the capital of Great Britain?"}],
[{"type": "text", "content": "And what is the famous place there?"}]
]
resp = None
history = None
for cur_query_list in queries:
resp, history = generate_text(model, tokenizer, cur_query_list, history)
print("resp", resp)
cur_query_tuple = ( cur_query_list, resp )
ppl, history = get_ppl(model, tokenizer, cur_query_tuple, history)
print("ppl", ppl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment