NuchaITSkillNER / app.py
Nucha's picture
Update app.py
6b5852a verified
raw
history blame
2.74 kB
import streamlit as st
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
# โหลด Tokenizer และ Model
model_name = "Nucha/Nucha_SkillNER_BERT"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForTokenClassification.from_pretrained(model_name)
# สร้าง NER Pipeline
ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
# UI ด้วย Streamlit
col1, col2 = st.columns(2)
with col1:
st.header("Input")
default_text="""Experience in customer-facing roles (AI/Tech industry preferred) with strong track record of performance e.g., Technical Sales, Pre-Sales Engineer, Technical Consultant, Entrepreneur, etc.
Bachelor’s or master’s degree in data science, Computer science, Statistics, Business, or related fields.
Highly driven and motivated to understand clients’ needs, provide impactful and appropriate solution recommendations, close sales, and support clients.
Very logical and structured in thinking and communication approach.
Familiarity with Data Science tools e.g.
Experience working with Machine Learning/Deep Learning.
Strong communication, presentation, and pitching skills, both oral and written in English and Thai .
Comfortable giving presentations and working with C-levels and senior management.
Ability to work independently and with teams to manage internal and external stakeholders.
Knowledge in Software Engineering/Architecture is a plus.
"""
text = st.text_area("Enter text for NER analysis:", value=default_text, height=400, max_chars=None, key=None, help=None, placeholder=None)
analyze_button = st.button("Analyze")
st.write("""**Example Inputs:**
- I am proficient in Python, Java, and machine learning.
- The candidate has experience with TensorFlow, data analysis, and cloud computing.""")
with col2:
st.header("Result")
# ใช้ st.markdown กับ CSS เพื่อปรับขนาดฟอนต์
st.markdown("<span style='font-size: 14px;'>Press button [Analyze]</span>", unsafe_allow_html=True)
if analyze_button:
ner_results = ner_pipeline(text)
# Display results in a structured output block
if ner_results:
output_data = [{"Entity": entity['word'], "Label": entity['entity'], "Score": f"{entity['score']:.4f}"} for entity in ner_results]
st.table(output_data) # Display as a table
else:
st.write("No entities found.")
# ใช้ st.markdown กับ CSS เพื่อปรับขนาดฟอนต์
st.markdown("<span style='font-size: 14px;'>JSON</span>", unsafe_allow_html=True)
st.write(ner_results)