-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 0.0.8
- Loading branch information
Showing
196 changed files
with
8,679 additions
and
2,641 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,42 @@ | ||
node('gpu') { | ||
try { | ||
stage('Clean') { | ||
sh "rm -rf .[^.] .??* *" | ||
timestamps { | ||
try { | ||
stage('Clean') { | ||
sh "rm -rf .[^.] .??* *" | ||
} | ||
stage('Checkout') { | ||
sh "cp -r ${pwd()}@script/* ." | ||
} | ||
stage('Setup') { | ||
env.CUDA_VISIBLE_DEVICES=0 | ||
sh """ | ||
virtualenv --python=python3 '.venv-$BUILD_NUMBER' | ||
. '.venv-$BUILD_NUMBER/bin/activate' | ||
pip install .[tests,docs] | ||
pip install -r dp_requirements/tf-gpu.txt | ||
rm -rf `find . -mindepth 1 -maxdepth 1 ! -name tests ! -name Jenkinsfile ! -name docs ! -name '.venv-$BUILD_NUMBER'` | ||
""" | ||
} | ||
stage('Tests') { | ||
sh """ | ||
. .venv-$BUILD_NUMBER/bin/activate | ||
pytest -v --disable-warnings | ||
cd docs | ||
make clean | ||
make html | ||
""" | ||
currentBuild.result = 'SUCCESS' | ||
} | ||
} | ||
stage('Checkout') { | ||
sh "cp -r ${pwd()}@script/* ." | ||
catch(e) { | ||
currentBuild.result = 'FAILURE' | ||
throw e | ||
} | ||
stage('Setup') { | ||
env.CUDA_VISIBLE_DEVICES=0 | ||
sh """ | ||
virtualenv --python=python3 '.venv-$BUILD_NUMBER' | ||
. '.venv-$BUILD_NUMBER/bin/activate' | ||
pip install .[tests] | ||
pip install -r dp_requirements/tf-gpu.txt | ||
rm -rf `find . -mindepth 1 -maxdepth 1 ! -name tests ! -name Jenkinsfile ! -name '.venv-$BUILD_NUMBER'` | ||
""" | ||
finally { | ||
emailext to: '${DEFAULT_RECIPIENTS}', | ||
subject: "${env.JOB_NAME} - Build # ${currentBuild.number} - ${currentBuild.result}!", | ||
body: '${BRANCH_NAME} - ${BUILD_URL}', | ||
attachLog: true | ||
} | ||
stage('Tests') { | ||
sh """ | ||
. .venv-$BUILD_NUMBER/bin/activate | ||
pytest -v | ||
""" | ||
} | ||
} catch (e) { | ||
emailext to: '${DEFAULT_RECIPIENTS}', | ||
subject: '${PROJECT_NAME} - Build # ${BUILD_NUMBER} - FAILED!', | ||
body: '${BRANCH_NAME} - ${BUILD_URL}', | ||
attachLog: true | ||
throw e | ||
} | ||
emailext to: '${DEFAULT_RECIPIENTS}', | ||
subject: '${PROJECT_NAME} - Build # ${BUILD_NUMBER} - ${BUILD_STATUS}!', | ||
body: '${BRANCH_NAME} - ${BUILD_URL}', | ||
attachLog: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Copyright 2017 Neural Networks and Deep Learning lab, MIPT | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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. | ||
|
||
from typing import List, Optional | ||
|
||
from deeppavlov.core.agent.agent import Agent | ||
from deeppavlov.core.agent.filter import Filter | ||
from deeppavlov.core.agent.processor import Processor | ||
from deeppavlov.core.skill.skill import Skill | ||
from deeppavlov.agents.filters.transparent_filter import TransparentFilter | ||
from deeppavlov.agents.processors.highest_confidence_selector import HighestConfidenceSelector | ||
|
||
|
||
class DefaultAgent(Agent): | ||
""" | ||
DeepPavlov default implementation of Agent abstraction. | ||
Default Agent is an implementation of agent template, with following | ||
pipeline for each utterance batch received by agent: | ||
1) Utterance batch is processed through agent Filter which selects utterances to be processed with each agent skill; | ||
2) Utterances are processed through skills selected for them; | ||
3) Utterances and skill responses are processed through agent Processor which generates agent's response for the outer world. | ||
Defining DefaultAgent means: | ||
a) To define set of skills it uses; | ||
b) To implement skills Filter; | ||
c) To implement Processor. | ||
You can refer to :class:`deeppavlov.core.skill.Skill`, :class:`deeppavlov.core.agent.Filter`, :class:`deeppavlov.core.agent.Processor` base classes to get more info. | ||
Args: | ||
skills: List of initiated agent skills instances. | ||
skills_processor: Initiated agent processor. | ||
skills_filter: Initiated agent filter. | ||
Attributes: | ||
skills: List of initiated agent skills instances. | ||
skills_processor: Initiated agent processor. | ||
skills_filter: Initiated agent filter. | ||
""" | ||
def __init__(self, skills: List[Skill], skills_processor: Optional[Processor]=None, | ||
skills_filter: Optional[Filter]=None, *args, **kwargs) -> None: | ||
super(DefaultAgent, self).__init__(skills=skills) | ||
self.skills_filter: Filter = skills_filter or TransparentFilter(len(skills)) | ||
self.skills_processor: Processor = skills_processor or HighestConfidenceSelector() | ||
|
||
def _call(self, utterances_batch: list, utterances_ids: Optional[list]=None) -> list: | ||
""" | ||
Processes batch of utterances and returns corresponding responses batch. | ||
Each call of Agent passes incoming utterances batch through skills filter, | ||
agent skills, skills processor. Batch of dialog IDs can be provided, in | ||
other case utterances indexes in incoming batch are used as dialog IDs. | ||
Args: | ||
utterances_batch: Batch of incoming utterances. | ||
utterances_ids: Batch of dialog IDs corresponding to incoming utterances. | ||
Returns: | ||
responses: A batch of responses corresponding to the | ||
utterance batch received by agent. | ||
""" | ||
batch_size = len(utterances_batch) | ||
ids = utterances_ids or list(range(batch_size)) | ||
batch_history = [self.history[utt_id] for utt_id in ids] | ||
responses = [] | ||
|
||
filtered = self.skills_filter(utterances_batch, batch_history) | ||
|
||
for skill_i, (filtered_utterances, skill) in enumerate(zip(filtered, self.wrapped_skills)): | ||
skill_i_utt_indexes = [utt_index for utt_index, utt_filter in enumerate(filtered_utterances) if utt_filter] | ||
|
||
if skill_i_utt_indexes: | ||
skill_i_utt_batch = [utterances_batch[i] for i in skill_i_utt_indexes] | ||
res = [(None, 0.)] * batch_size | ||
predicted, confidence = skill(skill_i_utt_batch, skill_i_utt_indexes) | ||
|
||
for i, predicted, confidence in zip(skill_i_utt_indexes, predicted, confidence): | ||
res[i] = (predicted, confidence) | ||
|
||
responses.append(res) | ||
|
||
responses = self.skills_processor(utterances_batch, batch_history, *responses) | ||
|
||
return responses |
Empty file.
Oops, something went wrong.