speedy-utils 1.1.6__py3-none-any.whl → 1.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- llm_utils/__init__.py +1 -5
- llm_utils/chat_format/transform.py +9 -9
- llm_utils/group_messages.py +1 -1
- llm_utils/lm/async_lm/__init__.py +6 -1
- llm_utils/lm/async_lm/_utils.py +7 -4
- llm_utils/lm/async_lm/async_llm_task.py +465 -110
- llm_utils/lm/async_lm/async_lm.py +273 -665
- llm_utils/lm/async_lm/async_lm_base.py +405 -0
- llm_utils/lm/async_lm/lm_specific.py +136 -0
- llm_utils/lm/utils.py +1 -3
- llm_utils/scripts/vllm_load_balancer.py +49 -37
- speedy_utils/__init__.py +3 -1
- speedy_utils/common/notebook_utils.py +4 -4
- speedy_utils/common/report_manager.py +2 -3
- speedy_utils/common/utils_cache.py +233 -3
- speedy_utils/common/utils_io.py +2 -0
- speedy_utils/scripts/mpython.py +1 -3
- {speedy_utils-1.1.6.dist-info → speedy_utils-1.1.7.dist-info}/METADATA +1 -1
- speedy_utils-1.1.7.dist-info/RECORD +39 -0
- llm_utils/lm/chat_html.py +0 -246
- llm_utils/lm/lm_json.py +0 -68
- llm_utils/lm/sync_lm.py +0 -943
- speedy_utils-1.1.6.dist-info/RECORD +0 -40
- {speedy_utils-1.1.6.dist-info → speedy_utils-1.1.7.dist-info}/WHEEL +0 -0
- {speedy_utils-1.1.6.dist-info → speedy_utils-1.1.7.dist-info}/entry_points.txt +0 -0
llm_utils/__init__.py
CHANGED
|
@@ -10,7 +10,6 @@ from .chat_format import (
|
|
|
10
10
|
transform_messages_to_chatml,
|
|
11
11
|
)
|
|
12
12
|
from .lm.async_lm import AsyncLLMTask, AsyncLM
|
|
13
|
-
from .lm.sync_lm import LM, LLMTask
|
|
14
13
|
|
|
15
14
|
__all__ = [
|
|
16
15
|
"transform_messages",
|
|
@@ -21,10 +20,7 @@ __all__ = [
|
|
|
21
20
|
"display_conversations",
|
|
22
21
|
"build_chatml_input",
|
|
23
22
|
"format_msgs",
|
|
24
|
-
# "group_messages_by_len",
|
|
25
|
-
"LM",
|
|
26
|
-
"AsyncLM",
|
|
27
23
|
"display_chat_messages_as_html",
|
|
28
|
-
"
|
|
24
|
+
"AsyncLM",
|
|
29
25
|
"AsyncLLMTask",
|
|
30
26
|
]
|
|
@@ -16,9 +16,9 @@ def identify_format(item):
|
|
|
16
16
|
def _transform_sharegpt_to_chatml(
|
|
17
17
|
item, default_system_message="You are a helpful assistant.", print_msg=False
|
|
18
18
|
):
|
|
19
|
-
assert isinstance(
|
|
20
|
-
item
|
|
21
|
-
)
|
|
19
|
+
assert isinstance(item, dict), (
|
|
20
|
+
"The item is not in the correct format. Please check the format of the item."
|
|
21
|
+
)
|
|
22
22
|
|
|
23
23
|
messages = []
|
|
24
24
|
system_msg = item.get("system", "")
|
|
@@ -116,16 +116,16 @@ def transform_messages_to_chatml(input_data, input_format="auto"):
|
|
|
116
116
|
input_data = deepcopy(input_data)
|
|
117
117
|
if isinstance(input_data, list):
|
|
118
118
|
input_format = "chatlm"
|
|
119
|
-
assert (
|
|
120
|
-
|
|
121
|
-
)
|
|
119
|
+
assert input_data[0].get("role") is not None, (
|
|
120
|
+
"The input format is not recognized. Please specify the input format."
|
|
121
|
+
)
|
|
122
122
|
elif isinstance(input_data, dict):
|
|
123
123
|
input_data = _transform_sharegpt_to_chatml(input_data)
|
|
124
124
|
input_format = "sharegpt"
|
|
125
125
|
elif isinstance(input_data, str):
|
|
126
|
-
assert (
|
|
127
|
-
"
|
|
128
|
-
)
|
|
126
|
+
assert "<|im_end|>" in input_data, (
|
|
127
|
+
"The input format is not recognized. Please specify the input format."
|
|
128
|
+
)
|
|
129
129
|
input_format = "chatlm"
|
|
130
130
|
parts = input_data.split("<|im_end|>")
|
|
131
131
|
input_data = []
|
llm_utils/group_messages.py
CHANGED
|
@@ -76,7 +76,7 @@ def group_messages_by_len(
|
|
|
76
76
|
"""
|
|
77
77
|
if messages is None:
|
|
78
78
|
raise ValueError("messages parameter cannot be None")
|
|
79
|
-
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
|
79
|
+
from transformers.models.auto.tokenization_auto import AutoTokenizer # type: ignore
|
|
80
80
|
|
|
81
81
|
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
82
82
|
|
llm_utils/lm/async_lm/_utils.py
CHANGED
|
@@ -48,13 +48,17 @@ def _yellow(t):
|
|
|
48
48
|
return _color(33, t)
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
TParsed = TypeVar("TParsed", bound=BaseModel)
|
|
51
|
+
# TParsed = TypeVar("TParsed", bound=BaseModel)
|
|
52
52
|
|
|
53
|
+
InputModelType = TypeVar("InputModelType", bound=BaseModel)
|
|
54
|
+
OutputModelType = TypeVar("OutputModelType", bound=BaseModel)
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
|
|
57
|
+
class ParsedOutput(TypedDict, Generic[OutputModelType]):
|
|
55
58
|
messages: List
|
|
56
59
|
completion: Any
|
|
57
|
-
parsed:
|
|
60
|
+
parsed: OutputModelType
|
|
61
|
+
model_kwargs: Dict[str, Any]
|
|
58
62
|
|
|
59
63
|
|
|
60
64
|
# --------------------------------------------------------------------------- #
|
|
@@ -185,7 +189,6 @@ __all__ = [
|
|
|
185
189
|
"Messages",
|
|
186
190
|
"LegacyMsgs",
|
|
187
191
|
"RawMsgs",
|
|
188
|
-
"TParsed",
|
|
189
192
|
"ParsedOutput",
|
|
190
193
|
"get_tokenizer",
|
|
191
194
|
"inspect_word_probs_async",
|