Skip to content

Commit

Permalink
Merge pull request #6 from TideDra/dev
Browse files Browse the repository at this point in the history
truncate TLDR prompt
  • Loading branch information
TideDra authored Nov 29, 2024
2 parents 77b864f + 1853fa5 commit c2fc4c7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tldr.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def get_paper_tldr(paper:arxiv.Result, model:Llama) -> str:
prompt = prompt.replace('__ABSTRACT__', paper.summary)
prompt = prompt.replace('__INTRODUCTION__', introduction)
prompt = prompt.replace('__CONCLUSION__', conclusion)
prompt_tokens = model.tokenize(prompt.encode('utf-8'))
prompt_tokens = prompt_tokens[:3800] # truncate to 3800 tokens
prompt = model.detokenize(prompt_tokens).decode('utf-8')
response = model.create_chat_completion(
messages=[
{"role": "system", "content": "You are an assistant who perfectly summarizes scientific paper, and gives the core idea of the paper to the user."},
Expand Down

0 comments on commit c2fc4c7

Please sign in to comment.