Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,18 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
from transformers import pipeline
|
4 |
import base64
|
5 |
|
6 |
# Load the EasyTerms/legalSummerizerET model from Hugging Face
|
7 |
-
summarizer = pipeline("summarization", model="EasyTerms/legalSummerizerET")
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Function to generate summary using the EasyTerms/legalSummerizerET model
|
10 |
def generate_summary(contract_text):
|
11 |
-
summary = summarizer(contract_text, max_length=
|
12 |
return summary[0]['summary_text']
|
13 |
|
14 |
# Function to handle feedback and store it in a CSV file
|
@@ -37,7 +41,7 @@ def main():
|
|
37 |
st.title("Legal Contract Summarizer with Feedback")
|
38 |
|
39 |
# Input area for legal contract
|
40 |
-
contract_text = st.text_area("Enter the legal contract:")
|
41 |
|
42 |
# Button to generate summary
|
43 |
if st.button("Generate Summary"):
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
from transformers import pipeline, AutoTokenizer
|
4 |
import base64
|
5 |
|
6 |
# Load the EasyTerms/legalSummerizerET model from Hugging Face
|
7 |
+
summarizer = pipeline("summarization", model="EasyTerms/legalSummerizerET", num_labels=1)
|
8 |
+
|
9 |
+
# Increase the maximum token limit
|
10 |
+
tokenizer = AutoTokenizer.from_pretrained("EasyTerms/legalSummerizerET")
|
11 |
+
summarizer.model.config.max_position_embeddings = tokenizer.model_max_length
|
12 |
|
13 |
# Function to generate summary using the EasyTerms/legalSummerizerET model
|
14 |
def generate_summary(contract_text):
|
15 |
+
summary = summarizer(contract_text, max_length=512, min_length=50, length_penalty=2.0, num_beams=4, early_stopping=True)
|
16 |
return summary[0]['summary_text']
|
17 |
|
18 |
# Function to handle feedback and store it in a CSV file
|
|
|
41 |
st.title("Legal Contract Summarizer with Feedback")
|
42 |
|
43 |
# Input area for legal contract
|
44 |
+
contract_text = st.text_area("Enter the legal contract:", height=200) # Increase the height to handle larger contracts
|
45 |
|
46 |
# Button to generate summary
|
47 |
if st.button("Generate Summary"):
|