-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: universal resp selector for debug * feat: universal resp selector for debug * feat: universal resp selector distribution * fix; upd services lm * feat: universal skill_selector * feat: universal skill working with multiple prompts and llms * feat: component card * fix; getting skill name not none * fix: codestyle * fix: resp selector vars * fix: remove sending apikeys with raw uttr attrs * fix: increase timeout * fix: do not use user attrs * fix: promtp to skill seletor * fix: select all skills (for resp selector debug) * fix: distribution with skill selector * fix: attrs * fix: attrs extra * fix: turning on all skills and getting skill names from input * fix: default value * feat: return all hypotheses for debug mode * fix: order of calls * fix: remove external internal * feat: docs * feat: component cards * fix: env in cards --------- Co-authored-by: smilni <[email protected]>
- Loading branch information
1 parent
f4779b8
commit 5f8133a
Showing
18 changed files
with
435 additions
and
11 deletions.
There are no files selected for viewing
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
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
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,25 @@ | ||
name: skill_selector | ||
display_name: Universal LLM-based Skill Selector | ||
component_type: null | ||
model_type: Dictionary/Pattern-based | ||
is_customizable: false | ||
author: [email protected] | ||
description: Algorithm that selects skills to generate hypotheses among the given list of all available | ||
skills in pipeline and provided LLM service | ||
ram_usage: 100M | ||
gpu_usage: null | ||
group: skill_selectors | ||
connector: | ||
protocol: http | ||
timeout: 10.0 | ||
url: http://universal-llm-based-skill-selector:8187/respond | ||
dialog_formatter: state_formatters.dp_formatters:cropped_dialog | ||
response_formatter: state_formatters.dp_formatters:simple_formatter_service | ||
previous_services: | ||
- annotators | ||
required_previous_services: null | ||
state_manager_method: null | ||
tags: null | ||
endpoint: respond | ||
service: skill_selectors/universal_llm_based_skill_selector/service_configs/universal-llm-based-skill-selector | ||
date_created: '2023-03-16T09:45:32' |
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
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
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
29 changes: 29 additions & 0 deletions
29
skill_selectors/universal_llm_based_skill_selector/Dockerfile
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,29 @@ | ||
FROM python:3.10 | ||
|
||
RUN mkdir /src | ||
|
||
COPY ./skill_selectors/universal_llm_based_skill_selector/requirements.txt /src/requirements.txt | ||
RUN pip install -r /src/requirements.txt | ||
|
||
ARG SERVICE_PORT | ||
ENV SERVICE_PORT ${SERVICE_PORT} | ||
ARG GENERATIVE_TIMEOUT | ||
ENV GENERATIVE_TIMEOUT ${GENERATIVE_TIMEOUT} | ||
ARG ENVVARS_TO_SEND | ||
ENV ENVVARS_TO_SEND ${ENVVARS_TO_SEND} | ||
ARG N_UTTERANCES_CONTEXT=5 | ||
ENV N_UTTERANCES_CONTEXT ${N_UTTERANCES_CONTEXT} | ||
ARG DEFAULT_LM_SERVICE_URL | ||
ENV DEFAULT_LM_SERVICE_URL ${DEFAULT_LM_SERVICE_URL} | ||
ARG DEFAULT_LM_SERVICE_CONFIG | ||
ENV DEFAULT_LM_SERVICE_CONFIG ${DEFAULT_LM_SERVICE_CONFIG} | ||
ARG MAX_N_SKILLS | ||
ENV MAX_N_SKILLS ${MAX_N_SKILLS} | ||
|
||
COPY skill_selectors/universal_llm_based_skill_selector /src | ||
WORKDIR /src | ||
COPY ./common/ ./common/ | ||
COPY ./components/ ./components/ | ||
|
||
|
||
CMD gunicorn --workers=1 server:app -b 0.0.0.0:${SERVICE_PORT} --timeout=1200 |
92 changes: 92 additions & 0 deletions
92
skill_selectors/universal_llm_based_skill_selector/README.md
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,92 @@ | ||
# Universal LLM-based Skill Selector | ||
|
||
## Description | ||
|
||
Debugging Skill Selector is a component selecting a list of skills to generate hypotheses. | ||
The LLM-based Skill Selector utilizes LLM service to select the skills in a generative manner. | ||
The considered LLM-service, generative parameters and prompt are provided IN attributes of | ||
the last human utterance. The list of all available skills is picked up from human utterance attributes. | ||
|
||
|
||
**Important** Provide `"return_all_hypotheses": True` (to return joined list of all returned hypotheses) | ||
and `"selected_skills": "all"` (to turn on dff_universal_prompted_skill because all other prompted skills | ||
are not deployed during debugging process). | ||
|
||
How to use: | ||
|
||
```python | ||
import requests | ||
import random | ||
from time import sleep | ||
|
||
|
||
LM_SERVICES_MAPPING = { | ||
"ChatGPT": "http://openai-api-chatgpt:8145/respond", | ||
} | ||
for lm_service in ["ChatGPT"]: | ||
print(f"Checking `Universal Assistant` with `{lm_service}`") | ||
|
||
result = requests.post( | ||
"http://0.0.0.0:4242", | ||
json={ | ||
"user_id": f"test-user-{random.randint(100, 1000)}", | ||
"payload": "How much is two plus two?", | ||
# ---------------------------- batch of universal skills to generate hypotheses | ||
"skill_name": ["Mathematician Skill", "blondy_skill"], | ||
"prompt": ["Answer as a mathematician.", "Answer like you are a stupid Blondy Girl."], | ||
"lm_service_url": [LM_SERVICES_MAPPING[lm_service], LM_SERVICES_MAPPING[lm_service]], | ||
"lm_service_config": [ | ||
{ | ||
"max_new_tokens": 64, | ||
"temperature": 0.9, | ||
"top_p": 1.0, | ||
"frequency_penalty": 0, | ||
"presence_penalty": 0 | ||
}, | ||
None | ||
], | ||
"lm_service_kwargs": [ | ||
{"openai_api_key": "FILL IN"}, | ||
{"openai_api_key": "FILL IN"} | ||
], | ||
# ---------------------------- response selector MUST RETURN ALL HYPOTHESES JOINED | ||
"return_all_hypotheses": True, | ||
# ---------------------------- skill selector | ||
"selected_skills": "all", # must use it to turn on universal skill (others are not deployed!) | ||
"skill_selector_prompt": """ | ||
Select up to 2 the most relevant to the dialog context skills based on the given short descriptions of abilities of different skills of the assistant. | ||
Skills: | ||
"Mathematician Skill": "A skill pretending to be a mathematician." | ||
"blondy_skill": "A Skill pretending to be a blondy girl." | ||
Return only names of the selected skills divided by comma. Do not respond to the dialog context.""", | ||
"skill_selector_lm_service_url": LM_SERVICES_MAPPING[lm_service], | ||
"skill_selector_lm_service_config": | ||
{ | ||
"max_new_tokens": 64, | ||
"temperature": 0.4, | ||
"top_p": 1.0, | ||
"frequency_penalty": 0, | ||
"presence_penalty": 0 | ||
}, | ||
"skill_selector_lm_service_kwargs": {"openai_api_key": "FILL IN"}, | ||
}).json() | ||
print(f"Response:\n{result['response']}") | ||
if result["active_skill"] not in ["Dummy Skill", "dummy_skill"]: | ||
print("Success!") | ||
elif lm_service in ["ChatGPT", "GPT-3.5"]: | ||
print(f"\nATTENTION! OpenAI services do not work!\n") | ||
else: | ||
print(f"\nERROR: `Universal Assistant` returned `{result}`\n") | ||
sleep(5) | ||
``` | ||
|
||
### Parameters | ||
|
||
The algorithm utilizes `N_UTTERANCES_CONTEXT` last utterances as a context for LLM. | ||
Number of returned skills can ve varied by the prompt itself. | ||
|
||
## Dependencies | ||
|
||
- generative service `DEFAULT_LM_SERVICE_URL` or the given in attributes in the last human utterance |
9 changes: 9 additions & 0 deletions
9
skill_selectors/universal_llm_based_skill_selector/requirements.txt
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,9 @@ | ||
flask==1.1.1 | ||
itsdangerous==2.0.1 | ||
gunicorn==19.9.0 | ||
requests==2.22.0 | ||
numpy==1.25.0 | ||
sentry-sdk==0.12.3 | ||
jinja2<=3.0.3 | ||
Werkzeug<=2.0.3 | ||
pyyaml==6.0.1 |
Oops, something went wrong.