File size: 1,555 Bytes
8677815
 
 
 
 
 
 
 
 
4823e70
8677815
4823e70
8677815
 
 
4823e70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8677815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from haystack.nodes import PromptNode, PromptTemplate
from haystack.nodes import AnswerParser
from haystack.nodes import TransformersSummarizer

def prompting_model():
    '''
    Define a prompt node in haystack pipeline
    ''' 

    # prompt_node = PromptNode(model_name_or_path="facebook/galactica-125m", default_prompt_template="deepset/question-answering-per-document")
    
    prompt_node = PromptNode(model_name_or_path="facebook/galactica-125m")

    return prompt_node

def prompting_model_2():
    '''
    Define a prompt node in haystack pipeline, with detailed prompt
    '''

    custom_prompt = PromptTemplate(prompt = """ You are a helpful and knowledgeable agent. To achieve your goal of answering complex questions,
                                                 you have access to the following paragraph :
                                                {join(documents)}

                                                Your output should be a detailed summary of the paragraph
                                                 """)
    
    summarization_template = PromptTemplate("deepset/summarization")
                                   
    prompt_node = PromptNode(model_name_or_path="facebook/galactica-125m", default_prompt_template=custom_prompt)

    return prompt_node

def summarize():

    '''
    Use a summarizer node, to summarize the output of generator
    To remove redundancy/repitition
    '''

    summarizer = TransformersSummarizer(model_name_or_path="google/pegasus-xsum")

    return summarizer