Views
No views yet
multi2convai and locally available fastText embeddings you can run:1# assumes working dir is the root of the cloned multi2convai repo
2
3python scripts/run_inference.py -m multi2convai-quality-it-logreg-ft
4
5>>> Create pipeline for config: multi2convai-quality-it-logreg-ft.
6>>> Created a LogisticRegressionFasttextPipeline for domain: 'quality' and language 'it'.
7>>>
8>>> Enter your text (type 'stop' to end execution): Avviare il programma
9>>> 'Avviare il programma' was classified as 'neo.start' (confidence: 0.8943)multi2convai and locally available fastText embeddings you can run:1# assumes working dir is the root of the cloned multi2convai repo
2
3from pathlib import Path
4
5from multi2convai.pipelines.inference.base import ClassificationConfig
6from multi2convai.pipelines.inference.logistic_regression_fasttext import (
7 LogisticRegressionFasttextConfig,
8 LogisticRegressionFasttextPipeline,
9)
10
11language = "it"
12domain = "quality"
13
14# 1. Define paths of model, label dict and embeddings
15model_file = "model.pth"
16label_dict_file = "label_dict.json"
17
18embedding_path = Path(
19 f"../models/embeddings/fasttext/it/wiki.200k.it.embed"
20)
21vocabulary_path = Path(
22 f"../models/embeddings/fasttext/it/wiki.200k.it.vocab"
23)
24
25# 2. Create and setup pipeline
26model_config = LogisticRegressionFasttextConfig(
27 model_file, embedding_path, vocabulary_path
28)
29config = ClassificationConfig(language, domain, label_dict_file, model_config)
30
31pipeline = LogisticRegressionFasttextPipeline(config)
32pipeline.setup()
33
34# 3. Run intent classification on a text of your choice
35label = pipeline.run("Avviare il programma")
36label
37>>> Label(string='neo.start', ratio='0.8943')1# assumes working dir is the root of the cloned multi2convai repo
2
3mkdir models/fasttext/it
4curl https://dl.fbaipublicfiles.com/fasttext/vectors-wiki/wiki.it.vec --output models/fasttext/it/wiki.it.vec
5
6python 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
7
8