Spaces:
Runtime error
Runtime error
ashishraics
commited on
Commit
•
4cd85c3
1
Parent(s):
b1bcd39
added example
Browse files- .idea/.gitignore +3 -0
- .idea/NLP.iml +14 -0
- .idea/inspectionProfiles/Project_Default.xml +27 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- app.py +7 -2
- zeroshot_clf_helper.py +4 -2
.idea/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
.idea/NLP.iml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$">
|
5 |
+
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
6 |
+
</content>
|
7 |
+
<orderEntry type="inheritedJdk" />
|
8 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
9 |
+
</component>
|
10 |
+
<component name="PyDocumentationSettings">
|
11 |
+
<option name="format" value="PLAIN" />
|
12 |
+
<option name="myDocStringFormat" value="Plain" />
|
13 |
+
</component>
|
14 |
+
</module>
|
.idea/inspectionProfiles/Project_Default.xml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<profile version="1.0">
|
3 |
+
<option name="myName" value="Project Default" />
|
4 |
+
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
5 |
+
<option name="ignoredErrors">
|
6 |
+
<list>
|
7 |
+
<option value="E302" />
|
8 |
+
<option value="E128" />
|
9 |
+
<option value="E303" />
|
10 |
+
<option value="E265" />
|
11 |
+
<option value="E305" />
|
12 |
+
<option value="E266" />
|
13 |
+
<option value="E501" />
|
14 |
+
</list>
|
15 |
+
</option>
|
16 |
+
</inspection_tool>
|
17 |
+
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
18 |
+
<option name="ignoredIdentifiers">
|
19 |
+
<list>
|
20 |
+
<option value="NLP.app.*" />
|
21 |
+
<option value="streamlit" />
|
22 |
+
<option value="pandas" />
|
23 |
+
</list>
|
24 |
+
</option>
|
25 |
+
</inspection_tool>
|
26 |
+
</profile>
|
27 |
+
</component>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/NLP.iml" filepath="$PROJECT_DIR$/.idea/NLP.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/vcs.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="VcsDirectoryMappings">
|
4 |
+
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
5 |
+
</component>
|
6 |
+
</project>
|
app.py
CHANGED
@@ -292,8 +292,13 @@ if select_task=='Zero Shot Classification':
|
|
292 |
st.write(f"Total time to load MLM Model is {(t2-t1)*1000:.1f} ms")
|
293 |
|
294 |
st.subheader("Zero Shot Classification using NLI & MLM")
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
297 |
input_hypothesis = st.text_input(label="Enter your hypothesis",value="This is an example of")
|
298 |
|
299 |
c1,c2,_,=st.columns(3)
|
|
|
292 |
st.write(f"Total time to load MLM Model is {(t2-t1)*1000:.1f} ms")
|
293 |
|
294 |
st.subheader("Zero Shot Classification using NLI & MLM")
|
295 |
+
|
296 |
+
default_paratext=""" A molar tooth from Southeast Asia probably belonged to a member of a cryptic group of Stone Age hominids called Denisovans, researchers say. If so, this relatively large tooth joins only a handful of fossils from Denisovans, who are known from ancient DNA pegging them as close Neandertal relatives. Analyses of the tooth’s internal structure and protein makeup indicate that the molar came from a girl in the Homo genus. She died between the ages of 3½ and 8½, paleoanthropologist Fabrice Demeter of the University of Copenhagen and colleagues say."""
|
297 |
+
default_labels="""science, politics,sports"""
|
298 |
+
input_texts = st.text_area(label="Input text to classify into topics",
|
299 |
+
height=250, max_chars=1000,
|
300 |
+
value=default_paratext)
|
301 |
+
input_lables = st.text_input(label="Enter labels separated by commas",value=default_labels)
|
302 |
input_hypothesis = st.text_input(label="Enter your hypothesis",value="This is an example of")
|
303 |
|
304 |
c1,c2,_,=st.columns(3)
|
zeroshot_clf_helper.py
CHANGED
@@ -197,12 +197,14 @@ def zero_shot_classification_fillmask_onnx(premise,hypothesis,labels,_session,_t
|
|
197 |
_inputs=_tokenizer(final_input,padding=True, truncation=True,return_tensors="pt")
|
198 |
|
199 |
|
200 |
-
|
201 |
# premise_token_ids=_tokenizer.encode(premise,add_special_tokens=False)
|
202 |
# hypothesis_token_ids=_tokenizer.encode(hypothesis,add_special_tokens=False)
|
203 |
#
|
204 |
# #creating inputs ids
|
205 |
-
# input_ids=[_tokenizer.cls_token_id]+premise_token_ids+[_tokenizer.sep_token_id]+hypothesis_token_ids+[_tokenizer.sep_token_id]
|
|
|
|
|
206 |
# input_ids=np.array(input_ids)
|
207 |
#
|
208 |
# #creating token type ids
|
|
|
197 |
_inputs=_tokenizer(final_input,padding=True, truncation=True,return_tensors="pt")
|
198 |
|
199 |
|
200 |
+
# # lowers the performance
|
201 |
# premise_token_ids=_tokenizer.encode(premise,add_special_tokens=False)
|
202 |
# hypothesis_token_ids=_tokenizer.encode(hypothesis,add_special_tokens=False)
|
203 |
#
|
204 |
# #creating inputs ids
|
205 |
+
# # input_ids=[_tokenizer.cls_token_id]+premise_token_ids+[_tokenizer.sep_token_id]+hypothesis_token_ids+[_tokenizer.sep_token_id]
|
206 |
+
# input_ids=[_tokenizer.cls_token_id]+premise_token_ids+[-1111]+hypothesis_token_ids+[_tokenizer.sep_token_id]
|
207 |
+
#
|
208 |
# input_ids=np.array(input_ids)
|
209 |
#
|
210 |
# #creating token type ids
|