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-corona-de-logreg-ft
4
5>>> Create pipeline for config: multi2convai-corona-de-logreg-ft.
6>>> Created a LogisticRegressionFasttextPipeline for domain: 'corona' and language 'de'.
7>>>
8>>> Enter your text (type 'stop' to end execution): Muss ich eine Maske tragen?
9>>> 'Muss ich eine Maske tragen?' was classified as 'corona.masks' (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 = "de"
12domain = "corona"
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/de/wiki.200k.de.embed"
20)
21vocabulary_path = Path(
22 f"../models/embeddings/fasttext/de/wiki.200k.de.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("Muss ich eine Maske tragen?")
36label
37>>> Label(string='corona.masks', ratio='0.8943')1# assumes working dir is the root of the cloned multi2convai repo
2
3mkdir models/fasttext/de
4curl https://dl.fbaipublicfiles.com/fasttext/vectors-wiki/wiki.de.vec --output models/fasttext/de/wiki.de.vec
5
6python scripts/serialize_fasttext.py -r fasttext/wiki.de.vec -v fasttext/de/wiki.200k.de.vocab -e fasttext/de/wiki.200k.de.embed -n 200000
7
8