LennardZuendorf commited on
Commit
9142a0b
1 Parent(s): f5b7609

updating interface to integrate both models

Browse files
Files changed (2) hide show
  1. README.md +19 -0
  2. app.py +19 -33
README.md CHANGED
@@ -10,3 +10,22 @@ pinned: true
10
  license: mit
11
  ---
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  license: mit
11
  ---
12
 
13
+ # legalis demo
14
+
15
+ #### This space is showing a demo of two models I build for a Uni Project about the prediction of court case outcomes. It's based on the similarly named legalis dataset, which contains 2800 court cases from the German Court cases. The dataset is labeled with the outcome of the case (plaintiff won or lost), extracted from the decision in text form (by ChatGPT) and the models are trained to predict the outcome based on the text of the case.
16
+
17
+ ## 🔗 Links:
18
+
19
+ **[RandomForest Model on Huggingface](https://huggingface.co/LennardZuendorf/legalis-scikit)**
20
+
21
+ **[BERT Model on Huggingface](https://huggingface.co/LennardZuendorf/legalis-BERT)**
22
+
23
+ **[Labeled Dataset on Huggingface](https://huggingface.co/datasets/LennardZuendorf/legalis)**
24
+
25
+
26
+ ## 👨‍💻 Author and Credits:
27
+
28
+ **Author:** [@LennardZuendorf](https://github.com/LennardZuendorf)
29
+
30
+ - This project is part of a course in HTW Berlin's Business Computing Bachelor Program ("Unternehmenssoftware")
31
+
app.py CHANGED
@@ -1,39 +1,25 @@
1
- # imports
2
  import gradio as gr
3
- from transformers import pipeline
4
 
5
- # load model via inference pipeline
6
- classifier_pipe = pipeline("text-classification", model="LennardZuendorf/legalis-BERT", top_k=None)
 
 
7
 
 
 
 
 
 
 
8
 
9
- # function to predict the case winner via the model
10
- def predict_fun(text):
11
- predictions = classifier_pipe(text)
12
- return {p["label"]: p["score"] for p in predictions[0]}
 
 
13
 
 
14
 
15
- # gradio interface as a block setup
16
- with gr.Blocks(title='Legalis') as interface:
17
- # top row
18
- with gr.Row():
19
- gr.Markdown(
20
- """
21
- # Legalis BERT Demo
22
- Start typing below to see the output.
23
- """)
24
- # middle row with input text, predict button and output label
25
- with gr.Row():
26
- with gr.Column():
27
- input_text = gr.Textbox(label="Case Facts")
28
- with gr.Row():
29
- predict = gr.Button("Predict")
30
- with gr.Column():
31
- label = gr.Label(label="Predicted Winner")
32
- with gr.Row():
33
- interpretation = gr.components.Interpretation(input_text, visible=False)
34
-
35
- # link predict button to predict function
36
- predict.click(predict_fun, input_text, label)
37
-
38
- # launch command
39
- interface.launch()
 
 
1
  import gradio as gr
 
2
 
3
+ tts_examples = [
4
+ "I love learning machine learning",
5
+ "How do you do?",
6
+ ]
7
 
8
+ scikit_demo = gr.load(
9
+ "LennardZuendorf/legalis-scikit",
10
+ src="models",
11
+ inputs=gr.Textbox(lines=5, max_lines=6, label="Input Text"),
12
+ title="scikit-learn"
13
+ )
14
 
15
+ bert_demo = gr.load(
16
+ "LennardZuendorf/legalis-bert",
17
+ src="models",
18
+ inputs=gr.Textbox(lines=5, max_lines=6, label="Input Text"),
19
+ title="bert"
20
+ )
21
 
22
+ demo = gr.TabbedInterface([scikit_demo, bert_demo], ["BERT Classification", "scikit-learn Classification"])
23
 
24
+ if __name__ == "__main__":
25
+ demo.launch()