Downloads · 30 days
0
inovex/multi2convai-quality-it-logreg-ft
multi2convai-quality-it-logreg-ft is a text classification model from inovex. Use it when you need a label for a piece of text. The card lists the license as mit.
This model was developed in the Multi2ConvAI project: - domain: Quality (more details about our use cases: (en, de)) - language: Italian (ml) - model type: logistic regression - embeddings: fastText embeddings
Downloads · 30 days
0
Access
Public
Updated Feb 28, 2022
Repo size
38.4 KB
Likes
0
Public
Click a slice to open those files.
.pth38.4 KB · 88%
From the Hugging Face model README
This model was developed in the Multi2ConvAI project:
Requires:
After installing multi2convai and locally available fastText embeddings you can run:
# assumes working dir is the root of the cloned multi2convai repo
python scripts/run_inference.py -m multi2convai-quality-it-logreg-ft
>>> Create pipeline for config: multi2convai-quality-it-logreg-ft.
>>> Created a LogisticRegressionFasttextPipeline for domain: 'quality' and language 'it'.
>>>
>>> Enter your text (type 'stop' to end execution): Avviare il programma
>>> 'Avviare il programma' was classified as 'neo.start' (confidence: 0.8943)
After installing multi2convai and locally available fastText embeddings you can run:
# assumes working dir is the root of the cloned multi2convai repo
from pathlib import Path
from multi2convai.pipelines.inference.base import ClassificationConfig
from multi2convai.pipelines.inference.logistic_regression_fasttext import (
LogisticRegressionFasttextConfig,
LogisticRegressionFasttextPipeline,
)
language = "it"
domain = "quality"
# 1. Define paths of model, label dict and embeddings
model_file = "model.pth"
label_dict_file = "label_dict.json"
embedding_path = Path(
f"../models/embeddings/fasttext/it/wiki.200k.it.embed"
)
vocabulary_path = Path(
f"../models/embeddings/fasttext/it/wiki.200k.it.vocab"
)
# 2. Create and setup pipeline
model_config = LogisticRegressionFasttextConfig(
model_file, embedding_path, vocabulary_path
)
config = ClassificationConfig(language, domain, label_dict_file, model_config)
pipeline = LogisticRegressionFasttextPipeline(config)
pipeline.setup()
# 3. Run intent classification on a text of your choice
label = pipeline.run("Avviare il programma")
label
>>> Label(string='neo.start', ratio='0.8943')
# assumes working dir is the root of the cloned multi2convai repo
mkdir models/fasttext/it
curl https://dl.fbaipublicfiles.com/fasttext/vectors-wiki/wiki.it.vec --output models/fasttext/it/wiki.it.vec
python scripts/serialize_fasttext.py -r fasttext/wiki.it.vec -v fasttext/it/wiki.200k.it.vocab -e fasttext/it/wiki.200k.it.embed -n 200000