Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Linha Fina

linha-fina is an intent engine that adapts to changing reference data at run time. It adds and removes intents dynamically, without a fixed training pass over the whole intent set.

How it works:

  • each intent is an independent SVM that classifies intent vs not-intent
  • each intent uses the other intents' data as "not-intent" training data
  • only the most relevant negative samples are used for training, ranked by token_set_ratio
  • features are one-hot-encoded keyword vectors
  • entity extraction from templates uses simplematch
  • entity extraction from wordlists optionally uses Aho-Corasick

Limitations:

  • long warm-up time (training happens on first inference)
  • does not scale well to a large number of intents
  • does not take word position into account
  • needs retraining whenever a new intent is added

See the docs for concepts, a quickstart, the full API reference, and tuning and troubleshooting guides.

img.png

Install

pip install linha-fina

Usage

from linha_fina.engine import IntentEngine

engine = IntentEngine()

intent_1 = ["hello world", "hey there", "hello"]
intent_2 = ["tell me a joke", "say a joke", "make me laugh"]
intent_3 = ["how is the weather", "what's the weather like",
            "what is the weather outside"]
intent_4 = ["my name is {name}", "call me {name}"]
intent_5 = ["change the color to {color}",
            "change light to {color}",
            "set light to {color}}"]

engine.register_intent("hello", intent_1)
engine.register_intent("joke", intent_2)
engine.register_intent("weather", intent_3)
engine.register_intent("introduce", intent_4)
engine.register_intent("change_color", intent_5, entity_samples={"color": ["red", "blue"]})
# you can register more entity examples after intent creation
engine.register_entity("color", ["yellow", "green"], intent_name="color")

for s in ["hello earth",
          "call me Casimiro",
          "my name is Miro",
          "tell me a joke",
          "what is the weather",
          "tell me a joke about the weather",
          "red blue and green are my 3 favorite colors",
          "red is my favorite color",
          "light to blue",
          "change to green",
          "make color green"
          ]:
    print(s)
    print(engine.calc_intent(s))
    # hello earth
    # IntentMatch(name='hello', slots={}, conf=0.9728585833827678)
    # call me Casimiro
    # IntentMatch(name='introduce', slots=[{'name': 'Casimiro'}], conf=0.9236423200801248)
    # my name is Miro
    # IntentMatch(name='introduce', slots=[{'name': 'Miro'}], conf=0.9949282563482034)
    # tell me a joke
    # IntentMatch(name='joke', slots={}, conf=0.9728801357230902)
    # what is the weather
    # IntentMatch(name='weather', slots={}, conf=0.9427588770219081)
    # tell me a joke about the weather
    # IntentMatch(name='joke', slots={}, conf=0.9728801357230902)
    # red blue and green are my 3 favorite colors
    # IntentMatch(name='change_color', slots={'color': 'green'}, conf=0.9648410361539215)
    # red is my favorite color
    # IntentMatch(name='change_color', slots={'color': 'red'}, conf=0.9142220645436988)
    # light to blue
    # IntentMatch(name='change_color', slots={'color': 'blue'}, conf=0.9845866111672085)
    # change to green
    # IntentMatch(name='change_color', slots={'color': 'green'}, conf=0.9598265049335444)
    # make color green
    # IntentMatch(name='change_color', slots={'color': 'green'}, conf=0.9142364945872282)

Credits

Originally an experimental research project by TigreGóticoLda, polished and donated to OpenVoiceOS. Its modernization, integration into OpenVoiceOS, and intent benchmarking were funded by the NGI0 Commons Fund.

NGI0 Commons Fund

This project was funded through the NGI0 Commons Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101135429.

Metadata

Release files for linha-fina 0.4.4a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linha-fina 0.4.4a2
File Size Uploaded
linha_fina-0.4.4a2.tar.gz 39.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for linha-fina 0.4.4a2
File Interpreter ABI Platform
linha_fina-0.4.4a2-py3-none-any.whl Python 3 none any Details

Total release size: 67.4 kB

Release files / linha_fina-0.4.4a2.tar.gz

Download URL linha_fina-0.4.4a2.tar.gz
Size 39.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cf20bd72029624e46a3ee7e30b3ddcf70cefb7d19952da6785a3febea845d98a
BLAKE2b-256 checksum
How to use checksums
e68e6e8f28493ae88a6e6555d9852178afb4ce04414f1b9d20e51d9409575062
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / linha_fina-0.4.4a2-py3-none-any.whl

Download URL linha_fina-0.4.4a2-py3-none-any.whl
Size 28.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a15d351e35de435eced5dd3c9cbfcf1597d950ba66274302ab3fea74d44d300
BLAKE2b-256 checksum
How to use checksums
e9820ec42bbb6f09dd29bf45b63071a109d0ae4810ce9c5d07a55fba7ff3ca2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page