Spaces:
Runtime error
Runtime error
add
Browse files- Dockerfile +17 -3
- gradio_ner.py +90 -0
- requirements.txt +2 -1
Dockerfile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
# you will also find guides on how best to write your Dockerfile
|
| 3 |
|
| 4 |
-
FROM python:3.
|
| 5 |
|
| 6 |
WORKDIR /code
|
| 7 |
|
|
@@ -9,6 +9,20 @@ COPY ./requirements.txt /code/requirements.txt
|
|
| 9 |
|
| 10 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 11 |
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
# you will also find guides on how best to write your Dockerfile
|
| 3 |
|
| 4 |
+
FROM python:3.11.5
|
| 5 |
|
| 6 |
WORKDIR /code
|
| 7 |
|
|
|
|
| 9 |
|
| 10 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 11 |
|
| 12 |
+
# Set up a new user named "user" with user ID 1000
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
|
| 15 |
+
# Switch to the "user" user
|
| 16 |
+
USER user
|
| 17 |
+
|
| 18 |
+
# Set home to the user's home directory
|
| 19 |
+
ENV HOME=/home/user \
|
| 20 |
+
PATH=/home/user/.local/bin:$PATH
|
| 21 |
+
|
| 22 |
+
# Set the working directory to the user's home directory
|
| 23 |
+
WORKDIR $HOME/app
|
| 24 |
+
|
| 25 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 26 |
+
COPY --chown=user . $HOME/app
|
| 27 |
+
|
| 28 |
+
CMD ["python", "gradio_ner.py"]
|
gradio_ner.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
examples = [
|
| 5 |
+
"""
|
| 6 |
+
Notice of Representation
|
| 7 |
+
Tachyon & Park PLLC
|
| 8 |
+
1618 25th Ave
|
| 9 |
+
Spokane, Washington(WA), 99208
|
| 10 |
+
Direct Insurance Company
|
| 11 |
+
5555 Dakota St.
|
| 12 |
+
Athens, GA 23001
|
| 13 |
+
Re: Estate of Bryan Terrell
|
| 14 |
+
Policy Number: 117213657
|
| 15 |
+
Date of death: 6/8/2021
|
| 16 |
+
To Whom It May Concern:
|
| 17 |
+
I have been retained by Saskia Mcgee to handle the abovenamed estate. My understanding is
|
| 18 |
+
that they had a life insurance policy with your company. If this is correct, please send a letter to
|
| 19 |
+
my office indicating you have received our letter of representation. Additionally, please do not
|
| 20 |
+
contact our client going forward.
|
| 21 |
+
We request that you deliver posthaste, the full policy amount of $400,000. If you are aware of
|
| 22 |
+
any additional policies in force, please provide us with that information. Additionally, if there
|
| 23 |
+
are any exclusions or liens on the policy, we request that information as well.
|
| 24 |
+
If you have any questions, please contact my office.
|
| 25 |
+
Sincerely,
|
| 26 |
+
J Rock, esq.
|
| 27 |
+
""",
|
| 28 |
+
"""
|
| 29 |
+
Notice of Representation
|
| 30 |
+
Budget Mutual Insurance Company
|
| 31 |
+
9876 Infinity Ave
|
| 32 |
+
Springfield, MI 65541
|
| 33 |
+
Colin & Bryier PLLC
|
| 34 |
+
9514 8th Ave S
|
| 35 |
+
Auburn, Washington(WA), 98002
|
| 36 |
+
Our Client: Aysha Gilmore
|
| 37 |
+
Date of death: 7/8/2021
|
| 38 |
+
To Whom It May Concern,
|
| 39 |
+
I have been retained by Aysha Gilmore to handle the estate of Kyron Marks. My understanding
|
| 40 |
+
is that they had a life insurance policy (#193635138) with your company. If this is correct,
|
| 41 |
+
please send a letter to my office indicating you have received our letter of representation.
|
| 42 |
+
Additionally, please do not contact our client going forward.
|
| 43 |
+
We are requesting that you forward the full policy amount of $25,000. Please forward an
|
| 44 |
+
acknowledgement of our demand and please forward the umbrella policy information if one is
|
| 45 |
+
applicable. Please send my secretary any information regarding liens on his policy.
|
| 46 |
+
Please contact my office if you have any questions.
|
| 47 |
+
Sincerely,
|
| 48 |
+
Angela Berry, Attorney""",
|
| 49 |
+
"""
|
| 50 |
+
Notice of Representation
|
| 51 |
+
Number One Insurance Company
|
| 52 |
+
1234 Gateway Dr
|
| 53 |
+
Chicago, IL 15002
|
| 54 |
+
Quiroga PLLC
|
| 55 |
+
9668 Rainier Ave S
|
| 56 |
+
Kent, Washington(WA), 98031
|
| 57 |
+
Re: Estate of Sana Keith
|
| 58 |
+
Policy number: 462204232
|
| 59 |
+
Our client: Oliver Davis
|
| 60 |
+
Date of death: 2/14/2020
|
| 61 |
+
To Whom It May Concern,
|
| 62 |
+
I have been retained by Oliver Davis to handle the estate of Sana Keith. My understanding is
|
| 63 |
+
that they had a life insurance policy with your company. If this is correct, please send a letter to
|
| 64 |
+
my office indicating you have received our letter of representation. Additionally, please do not
|
| 65 |
+
contact our client going forward.
|
| 66 |
+
Our understanding is that the policy was for the amount of $60,000. If that is correct, please
|
| 67 |
+
forward that amount to our office. If there are any forms that need to be completed, please
|
| 68 |
+
forward those as well. If you are aware of any additional policies that are in force, send
|
| 69 |
+
information about those policies to our office.
|
| 70 |
+
If you have any questions, please contact my office.
|
| 71 |
+
Sincerely,
|
| 72 |
+
John D Locke, Esq"""
|
| 73 |
+
]
|
| 74 |
+
# Replace this with your own checkpoint
|
| 75 |
+
model_checkpoint = "aimlnerd/bert-finetuned-legalentity-ner"
|
| 76 |
+
ner_pipeline = pipeline(
|
| 77 |
+
"token-classification", model=model_checkpoint, aggregation_strategy="simple"
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
def ner(text):
|
| 81 |
+
output = ner_pipeline(text)
|
| 82 |
+
return {"text": text, "entities": output}
|
| 83 |
+
|
| 84 |
+
demo = gr.Interface(ner,
|
| 85 |
+
gr.Textbox(placeholder="Enter text here..."),
|
| 86 |
+
gr.HighlightedText(),
|
| 87 |
+
examples=examples)
|
| 88 |
+
|
| 89 |
+
demo.launch(share=True)
|
| 90 |
+
print()
|
requirements.txt
CHANGED
|
@@ -6,4 +6,5 @@ datasets==2.16.1
|
|
| 6 |
evaluate==0.4.1
|
| 7 |
accelerate==0.25.0
|
| 8 |
seqeval==1.2.2
|
| 9 |
-
pandas==2.1.4
|
|
|
|
|
|
| 6 |
evaluate==0.4.1
|
| 7 |
accelerate==0.25.0
|
| 8 |
seqeval==1.2.2
|
| 9 |
+
pandas==2.1.4
|
| 10 |
+
gradio==4.13.0
|