Skip to content

Commit

Permalink
changes in output
Browse files Browse the repository at this point in the history
  • Loading branch information
Geun Han Chung authored and Geun Han Chung committed Nov 24, 2024
1 parent e5129d9 commit a45a2b8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions backend/generate_answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,23 @@ def get_device():
def generate_initial_note(page_content, model, tokenizer):
inputs = tokenizer(f"Generate notes for the given content: {page_content}", return_tensors="pt")
outputs = model.generate(**inputs)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
final_output = ""
for output in outputs:
final_output += tokenizer.decode(output, skip_special_tokens=True)
return final_output

def generate_note(page_content, note_content, model, tokenizer):
inputs = tokenizer(f"I did not like this note: {note_content}. Generate new notes for the given content: {page_content}", return_tensors="pt")
outputs = model.generate(**inputs)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
final_output = ""
for output in outputs:
final_output += tokenizer.decode(output, skip_special_tokens=True)
return final_output

def generate_quiz_review(origin_content, wrong_questions, model, tokenizer):
inputs = tokenizer(f"I generated note based on this content: {origin_content} and I got these questions wrong: {wrong_questions}. Help me to generate review based on wrong questions", return_tensors="pt")
outputs = model.generate(**inputs)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
final_output = ""
for output in outputs:
final_output += tokenizer.decode(output, skip_special_tokens=True)
return final_output

0 comments on commit a45a2b8

Please sign in to comment.