Spaces:
Sleeping
Sleeping
Commit
·
0f51a7f
1
Parent(s):
6759ca3
import knowledge_extraction model
Browse files
app.py
CHANGED
@@ -1,20 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import
|
3 |
-
import torch
|
4 |
|
5 |
-
# Load the
|
6 |
-
model_name = "
|
7 |
-
|
8 |
-
model = BertForSequenceClassification.from_pretrained(model_name)
|
9 |
|
10 |
# Streamlit UI
|
11 |
-
st.title("
|
12 |
-
text_input = st.
|
13 |
|
14 |
if text_input:
|
15 |
-
#
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline
|
|
|
3 |
|
4 |
+
# Load the token classification pipeline
|
5 |
+
model_name = "jjzha/jobbert_knowledge_extraction"
|
6 |
+
pipe = pipeline("token-classification", model=model_name)
|
|
|
7 |
|
8 |
# Streamlit UI
|
9 |
+
st.title("Token Classification with Hugging Face")
|
10 |
+
text_input = st.text_area("Enter text for token classification:")
|
11 |
|
12 |
if text_input:
|
13 |
+
# Perform token classification
|
14 |
+
results = pipe(text_input)
|
15 |
+
|
16 |
+
# Display the results
|
17 |
+
st.write("Token Classification Results:")
|
18 |
+
for result in results:
|
19 |
+
st.write(f"Entity: {result['entity']}, Word: {result['word']}, Score: {result['score']:.2f}")
|