Sasvataa commited on
Commit
5cbb062
1 Parent(s): 5587e08

Init Commit

Browse files
Files changed (3) hide show
  1. app.py +94 -0
  2. examples.pkl +3 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+ #from Summarizer_Helper import Summary_Gen
4
+
5
+ from gpt4all import GPT4All
6
+ import textwrap
7
+
8
+ with open('examples.pkl', 'rb') as f:
9
+ example_list = pickle.load(f)
10
+
11
+ # Model initialization (assuming the model is already downloaded)
12
+ from huggingface_hub import hf_hub_download
13
+ model_path = "models"
14
+ model_name = "Llama-2-7b-MOM_Summar.Q2_K.gguf"
15
+ # hf_hub_download(repo_id="sasvata/Llama2-7b-MOM-Summary-Finetuned-GGUF", filename=model_name, local_dir=model_path, local_dir_use_symlinks=False)
16
+
17
+ print("Start the model init process")
18
+ model = GPT4All(model_name, model_path, allow_download = False, device="cpu")
19
+ print("Finish the model init process")
20
+
21
+ ## Function to convert plain text to markdown format
22
+ def to_markdown(text):
23
+ text = text.replace('•', ' *')
24
+ return textwrap.indent(text, '> ', predicate=lambda _: True)
25
+
26
+ # Default system prompt for generating conversation summaries
27
+ DEFAULT_SYSTEM_PROMPT = """
28
+ Below is a conversation between a human and an AI agent. Write a summary of the conversation.
29
+ """.strip()
30
+
31
+ def generate_prompt(
32
+ Transcript: str, system_prompt: str = DEFAULT_SYSTEM_PROMPT
33
+ ) -> str:
34
+ return f"""### Instruction: {system_prompt}
35
+
36
+ ### Input:
37
+ {Transcript.strip()}
38
+
39
+ ### Response:
40
+ """.strip()
41
+
42
+ # Function to generate summary with the help of fine-tuned model
43
+ def Summary_Gen(Transcript):
44
+ prompt = generate_prompt(Transcript)
45
+ summary = model.generate(prompt=prompt,max_tokens=1024)
46
+ return summary
47
+
48
+ # Function for text summarization
49
+ def summarize_text(text):
50
+ summarized_text = Summary_Gen(text)
51
+ return summarized_text
52
+
53
+
54
+ st.set_page_config(layout="wide", page_title="MOM-Summary-Generator📑", page_icon="📑")
55
+ st.title("Minutes Of Meeting (MOM) - Summary Generator 📑")
56
+
57
+ # Text input and output elements
58
+ option = st.selectbox(
59
+ "Choose Example",
60
+ example_list,
61
+ index=None,
62
+ placeholder="Choose Example",
63
+ )
64
+
65
+ col1, col2 = st.columns(2)
66
+
67
+ col1.title('Input')
68
+ col2.title('Output')
69
+
70
+ col1.container(height=500, border=True).text_area("", option, height=1000)
71
+ if col1.button("Summarize"):
72
+ with st.spinner('Wait for it...'):
73
+ summary_output = summarize_text(option)
74
+ col2.container(height=500, border=True).markdown(summary_output, unsafe_allow_html=True)
75
+
76
+
77
+ with st.expander("Results Overview"):
78
+ # Text input and output elements
79
+ option = st.selectbox(
80
+ "Choose Example 2",
81
+ example_list,
82
+ index=1,
83
+ placeholder="Choose Example",
84
+ )
85
+
86
+ col1, col2 = st.columns(2)
87
+
88
+ col1.title('Input')
89
+ col1.container(height=500, border=True).markdown(option, unsafe_allow_html=True)
90
+
91
+ col2.title('Output')
92
+ col2.container(height=500, border=True).markdown(option, unsafe_allow_html=True)
93
+
94
+
examples.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2367e2192d9649ba51a3a0886f815aedc1a729a2675a45e8e53037786df542db
3
+ size 6372
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gpt4all==2.3.2
2
+ streamlit==1.32.2