Skip to content

Commit

Permalink
Merge pull request #33 from OpenVoiceOS/release-1.1.1a1
Browse files Browse the repository at this point in the history
Release 1.1.1a1
  • Loading branch information
JarbasAl authored Dec 12, 2024
2 parents d5965cb + 0443bd8 commit e2876ea
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Changelog

## [1.1.0a1](https://github.com/OpenVoiceOS/ovos-padatious-pipeline-plugin/tree/1.1.0a1) (2024-12-09)
## [1.1.1a1](https://github.com/OpenVoiceOS/ovos-padatious-pipeline-plugin/tree/1.1.1a1) (2024-12-11)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-padatious-pipeline-plugin/compare/1.0.5...1.1.0a1)
[Full Changelog](https://github.com/OpenVoiceOS/ovos-padatious-pipeline-plugin/compare/1.1.0...1.1.1a1)

**Merged pull requests:**

- feat:delayed\_padatious\_training [\#29](https://github.com/OpenVoiceOS/ovos-padatious-pipeline-plugin/pull/29) ([JarbasAl](https://github.com/JarbasAl))
- performance: paralelize inference [\#32](https://github.com/OpenVoiceOS/ovos-padatious-pipeline-plugin/pull/32) ([JarbasAl](https://github.com/JarbasAl))



Expand Down
52 changes: 44 additions & 8 deletions ovos_padatious/intent_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,58 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import time
from concurrent.futures import ThreadPoolExecutor
from typing import List
from ovos_padatious.intent import Intent
from ovos_padatious.match_data import MatchData
from ovos_padatious.training_manager import TrainingManager
from ovos_padatious.util import tokenize
from ovos_utils.log import LOG


class IntentManager(TrainingManager):
def __init__(self, cache):
super(IntentManager, self).__init__(Intent, cache)
"""
Manages intents and performs matching using the OVOS Padatious framework.
Args:
cache (str): Path to the cache directory for storing trained models.
"""
def __init__(self, cache: str, debug: bool = False):
super().__init__(Intent, cache)
self.debug = debug

def calc_intents(self, query: str, entity_manager) -> List[MatchData]:
"""
Calculate matches for the given query against all registered intents.
Args:
query (str): The input query to match.
entity_manager: The entity manager for resolving entities in the query.
def calc_intents(self, query, entity_manager):
Returns:
List[MatchData]: A list of matches sorted by confidence.
"""
sent = tokenize(query)
matches = []
for i in self.objects:
match = i.match(sent, entity_manager)
match.detokenize()
matches.append(match)

def match_intent(intent):
start_time = time.monotonic()
try:
match = intent.match(sent, entity_manager)
match.detokenize()
if self.debug:
LOG.debug(f"Inference for intent '{intent.name}' took {time.monotonic() - start_time} seconds")
return match
except Exception as e:
LOG.error(f"Error processing intent '{intent.name}': {e}")
return None

# Parallelize matching
with ThreadPoolExecutor() as executor:
matches = list(executor.map(match_intent, self.objects))

# Filter out None results from failed matches
matches = [match for match in matches if match]

return matches
2 changes: 1 addition & 1 deletion ovos_padatious/simple_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def calc_weight(w): return pow(len(w), 3.0)

train_data = fann.training_data()
train_data.set_train_data(inputs, outputs)
LOG.debug(f"Training {self.name} with samples: {n_pos} positive + {n_neg} negative")
LOG.debug(f"Training {self.name} with {len(self.ids)} inputs and samples: {n_pos} positive + {n_neg} negative")
for _ in range(10):
self.configure_net()
self.net.train_on_data(train_data, 1000, 0, 0)
Expand Down
4 changes: 2 additions & 2 deletions ovos_padatious/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 1
VERSION_MINOR = 1
VERSION_BUILD = 0
VERSION_ALPHA = 0
VERSION_BUILD = 1
VERSION_ALPHA = 1
# END_VERSION_BLOCK

0 comments on commit e2876ea

Please sign in to comment.