Spaces:
Sleeping
Sleeping
from transformers import pipeline | |
checkpoint = "C:\\Users\zeyad\Desktop\pythonProject9\LaMini-T5-738M" | |
model = pipeline('text2text-generation', model=checkpoint) | |
# query=" who is salma" | |
# context=["in salma_ahmed.pdf: salma is a computer developer","in salmaaaaa3333.pdf: salma is an employee in arkleap ","in salmaaaaa3333.pdf: salma works from 9 to 5 ","in italy_emploee.pdf: salma is a agent who works as a spy ","in zolompa7.pdf:"] | |
# input_prompt = """ | |
# Given a question and a context, generate reasoning answers form the context in a numbered list format according do different pdfs with format "in [pdf name]:(answer you generate)\n"... | |
# Context is an array that contains multiple answers of query from multiple pdfs in this format "in [pdf name]:[answer of the query in the pdf]"... | |
# Don't generate answer from your data generate only from the provided contexts... | |
# Question:"{}", | |
# Contexts:"{}" | |
# Answers: | |
# (number)-in(pdfname):(answer) | |
# """.format(query,context) | |
# input_prompt= """ | |
# Given a question and a context, generate related reasoning answers from the following contexts that is given ... | |
# Context is an array that contains multiple answers of query from multiple pdfs in this format "in [pdfname]:[answer of the query in the pdf]"... | |
# Do not generate answers from your own data, only generate answers from the provided contexts... | |
# If the contexts doesn't provide an answer or isn't related to the question, respond with "there is no answer for the provided question" | |
# Question:"{}".. | |
# Contexts:"{}".. | |
# Answers [CREATE LIST with the answers for each pdf] :list | |
# """.format(query,context) | |
# input_prompt=""" | |
# question:{} | |
# contexts that has multiple answers in multiple pdfs with format "in [pdf name]:[answer of the query in the pdf]":{} | |
# Answers only from the contexts in numbered list ,don't generate the answer from your data, if the answers related to the question with listing all the answers ,don't mix answers ..only answer for each pdf name with different list item: | |
# """.format(query,context) | |
# input_prompt=""" | |
# given question and contexts that your only allowed to answer from it and only if the answers related to the question..Don't generate answer from your data generate only from the provided contexts.. | |
# context is an array contains answer of the question from multiple pdfs,each answer has this format "in [pdf name]:[answer of the query in the pdf]"... | |
# If the contexts doesn't provide an answer or isn't related to the question, respond with "there is no answer for the provided question"... | |
# you could find that the question could has multiple answer on the same pdf , generate tha answer for this pdf for it's own data ..don't consider the another pdf's data.. | |
# list the answers in a bullet list ,each item has this format "in [pdf name]:[answer of your reasoning to this pdf data only]".. | |
# Question:{} | |
# Contexts:{} | |
# """.format(query,context) | |
# input_prompt=f""" | |
# Answer the following question with related reasoning answers from the following contexts that is given and list all the possible answers but don't make reasoning on all the data together ..only reason the data of same pdf name" | |
# ..Don't generate answer from your data generate only from the provided contexts | |
# ..If the contexts doesn't provide an answer or isn't related to the question, respond with "there is no answer for the provided question" | |
# question:"{query}"+"list what you know" | |
# context:"{context}" | |
# answer: | |
# """ | |
# query="what does salma studies?" | |
# context=["salma is a computer developer( from salma_ahmed.pdf)"," salma is an employee in arkleap (from salmaaaaa3333.pdf) "," salma works from 9 to 5 ( from salmaaaaa3333.pdf)","salma is a agent who works as a spy (from italy_emploee.pdf )","(from salmaaaaa3333.pdf)"] | |
# input_prompt = """ | |
# Given a question and a context, generate reasoning answers from the context in a bullet list with mentioning the source of the answers like the following format "in [PDF name]: [answer you generate]\n"... | |
# provide the answer as mentioned bellow and don't repeat the answer and generate answers only from the contexts and only answer if there is a context related to the question | |
# Provide for any generated answer it's meta data which is given in the context (from **.pdf) | |
# Question: "{}", | |
# Contexts: {} | |
# Answers: | |
# -[answer generated ](from **.pdf) | |
# """.format(query, ', '.join(["{}".format(x) for x in context])) | |
query="who is zozbra?" | |
context=["salma is a computer developer( from salma_ahmed.pdf)"," salma is an employee in arkleap (from salmaaaaa3333.pdf) "," salma works from 9 to 5 ( from salmaaaaa3333.pdf)","salma is a agent who works as a spy (from italy_emploee.pdf )","(from salmaaaaa3333.pdf)"] | |
input_prompt = """ | |
Question: "{}", | |
Contexts: {} | |
you're a context reasoning AI Assistant that make individual answers not one summarized answer and mentions the pdf name for each answer that he generates | |
you're Given a question and a context that contain it's meta data inside brackets with this format (from example.pdf) | |
you're allowed to generate answer for each pdf individual in a bullet list and mention there meta data ,generate answers only from the contexts and only answer if there is a context related to the question | |
You're not allowed to repeat answers | |
you're not allowed to make only one answer that contain summarized answer from all pdfs | |
you're not allowed to predict ..if the question not related to the contexts ..respond with "no answer for this question" | |
""".format(query, ', '.join(["{}".format(x) for x in context])) | |
generated_text = model(input_prompt, max_length=2048, do_sample=False)[0]['generated_text'] | |
print(generated_text) |