Instructions to use Egrove/keyword-intent-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Egrove/keyword-intent-classifier with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Egrove/keyword-intent-classifier", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
File size: 772 Bytes
1f4627a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """Preprocessing for the keyword intent classifier.
Ship this module alongside keyword_intent_model.pkl. The pickled
TfidfVectorizer references `intent_preprocess.preprocess_text`, so this
module must be importable (on sys.path) before joblib.load().
"""
import re
import string
def preprocess_text(text):
"""Must match the preprocessing used at training time."""
if text is None:
return ""
text = str(text).lower().strip()
text = re.sub(r"\s+", " ", text)
# keep '+', '#', '.' (e.g. "c++", "c#", ".net"); strip other punctuation
punctuation_to_remove = (
string.punctuation.replace("+", "").replace("#", "").replace(".", "")
)
text = text.translate(str.maketrans("", "", punctuation_to_remove))
return text.strip()
|