parth parekh
commited on
Commit
·
bfa14f8
1
Parent(s):
6650029
running now
Browse files- __pycache__/predictor.cpython-312.pyc +0 -0
- app.py +2 -4
- predictor.py +4 -2
- requirements.txt +73 -4
- vocab.pth +3 -0
__pycache__/predictor.cpython-312.pyc
ADDED
Binary file (7.53 kB). View file
|
|
app.py
CHANGED
@@ -46,12 +46,10 @@ async def detect_contact(input: TextInput):
|
|
46 |
}
|
47 |
|
48 |
# If no regex patterns match, use the model
|
49 |
-
|
50 |
-
|
51 |
-
is_contact = probability > 0.5 # You can adjust this threshold as needed
|
52 |
return {
|
53 |
"text": input.text,
|
54 |
-
"contact_probability": probability,
|
55 |
"is_contact_info": is_contact,
|
56 |
"method": "model"
|
57 |
}
|
|
|
46 |
}
|
47 |
|
48 |
# If no regex patterns match, use the model
|
49 |
+
# Probability of containing contact info
|
50 |
+
is_contact = predict(input.text) # You can adjust this threshold as needed
|
|
|
51 |
return {
|
52 |
"text": input.text,
|
|
|
53 |
"is_contact_info": is_contact,
|
54 |
"method": "model"
|
55 |
}
|
predictor.py
CHANGED
@@ -83,16 +83,18 @@ test_sentences = [
|
|
83 |
]
|
84 |
|
85 |
|
|
|
86 |
def predict(text):
|
87 |
with torch.no_grad():
|
88 |
inputs = torch.tensor([text_pipeline(text)])
|
89 |
if inputs.size(1) < max(FILTER_SIZES):
|
|
|
90 |
padding = torch.zeros(1, max(FILTER_SIZES) - inputs.size(1), dtype=torch.long)
|
91 |
inputs = torch.cat([inputs, padding], dim=1)
|
92 |
inputs = inputs.to(device)
|
93 |
outputs = model(inputs)
|
94 |
-
|
95 |
-
|
96 |
|
97 |
|
98 |
# Test the sentences
|
|
|
83 |
]
|
84 |
|
85 |
|
86 |
+
# Function to predict
|
87 |
def predict(text):
|
88 |
with torch.no_grad():
|
89 |
inputs = torch.tensor([text_pipeline(text)])
|
90 |
if inputs.size(1) < max(FILTER_SIZES):
|
91 |
+
# Pad the input if it's shorter than the largest filter size
|
92 |
padding = torch.zeros(1, max(FILTER_SIZES) - inputs.size(1), dtype=torch.long)
|
93 |
inputs = torch.cat([inputs, padding], dim=1)
|
94 |
inputs = inputs.to(device)
|
95 |
outputs = model(inputs)
|
96 |
+
return torch.argmax(outputs, dim=1).item()
|
97 |
+
|
98 |
|
99 |
|
100 |
# Test the sentences
|
requirements.txt
CHANGED
@@ -1,4 +1,73 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
annotated-types==0.7.0
|
2 |
+
anyio==4.6.0
|
3 |
+
blis==0.7.11
|
4 |
+
catalogue==2.0.10
|
5 |
+
certifi==2024.8.30
|
6 |
+
charset-normalizer==3.3.2
|
7 |
+
click==8.1.7
|
8 |
+
cloudpathlib==0.19.0
|
9 |
+
colorama==0.4.6
|
10 |
+
confection==0.1.5
|
11 |
+
cymem==2.0.8
|
12 |
+
distro==1.9.0
|
13 |
+
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1-py3-none-any.whl#sha256=86cc141f63942d4b2c5fcee06630fd6f904788d2f0ab005cce45aadb8fb73889
|
14 |
+
fastapi==0.115.0
|
15 |
+
filelock==3.13.1
|
16 |
+
fsspec==2024.2.0
|
17 |
+
greenlet==3.1.1
|
18 |
+
groq==0.11.0
|
19 |
+
h11==0.14.0
|
20 |
+
httpcore==1.0.5
|
21 |
+
httpx==0.27.2
|
22 |
+
huggingface-hub==0.25.1
|
23 |
+
idna==3.10
|
24 |
+
Jinja2==3.1.3
|
25 |
+
langcodes==3.4.0
|
26 |
+
language_data==1.2.0
|
27 |
+
marisa-trie==1.2.0
|
28 |
+
markdown-it-py==3.0.0
|
29 |
+
MarkupSafe==2.1.5
|
30 |
+
mdurl==0.1.2
|
31 |
+
mpmath==1.3.0
|
32 |
+
murmurhash==1.0.10
|
33 |
+
networkx==3.2.1
|
34 |
+
numpy==1.26.3
|
35 |
+
packaging==24.1
|
36 |
+
pillow==10.2.0
|
37 |
+
preshed==3.0.9
|
38 |
+
psycopg2==2.9.9
|
39 |
+
pydantic==2.9.2
|
40 |
+
pydantic_core==2.23.4
|
41 |
+
Pygments==2.18.0
|
42 |
+
PyYAML==6.0.2
|
43 |
+
regex==2024.9.11
|
44 |
+
requests==2.32.3
|
45 |
+
rich==13.8.1
|
46 |
+
safetensors==0.4.5
|
47 |
+
setuptools==70.0.0
|
48 |
+
shellingham==1.5.4
|
49 |
+
smart-open==7.0.4
|
50 |
+
sniffio==1.3.1
|
51 |
+
spacy==3.7.6
|
52 |
+
spacy-legacy==3.0.12
|
53 |
+
spacy-loggers==1.0.5
|
54 |
+
SQLAlchemy==2.0.35
|
55 |
+
srsly==2.4.8
|
56 |
+
starlette==0.38.5
|
57 |
+
sympy==1.12
|
58 |
+
thinc==8.2.5
|
59 |
+
tokenizers==0.19.1
|
60 |
+
torch==2.2.0
|
61 |
+
torchaudio==2.4.1+cu118
|
62 |
+
torchdata==0.7.1
|
63 |
+
torchtext==0.16.2
|
64 |
+
torchvision==0.19.1+cu118
|
65 |
+
tqdm==4.66.5
|
66 |
+
transformers==4.44.2
|
67 |
+
typer==0.12.5
|
68 |
+
typing_extensions==4.12.2
|
69 |
+
urllib3==2.2.3
|
70 |
+
uvicorn==0.30.6
|
71 |
+
wasabi==1.1.3
|
72 |
+
weasel==0.4.1
|
73 |
+
wrapt==1.16.0
|
vocab.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:28edf2ae44d144c4566f0e5f95b856391166ac138ee578bac7fd9db151e1790a
|
3 |
+
size 5184491
|