增加对GLM-4大模型的支持
まだ誰も着手していません。
評価
調査の方向性
tiktoken.encoding_for_model が呼び出されている camel/model_backend.py から始め、GLM_4 と提供された BASE_URL を使って報告されたコマンドを再現します。モデル名とトークンエンコーディングがどのように選択されるかを追跡します。報告された tokenizer KeyError が発生せず、このコマンドから GLM-4 を呼び出せれば完了です。
索引モデルが issue の本文から書いたものです。
説明
调用方法:
export BASE_URL="https://open.bigmodel.cn/api/paas/v4/"
export OPENAI_API_KEY="XXXXXXXXXXXXXXXXXXXX"
python run.py --task "[Develop a snake game]" --name "[snamer03]" --model=GLM_4
错误日志:
...
Note that we must ONLY discuss the product modality and do not discuss anything else! Once we all have expressed our opinion(s) and agree with the results of the discussion unanimously, any of us must actively terminate the discussion by replying with only one line, which starts with a single word , followed by our final product modality without any other words, e.g., " PowerPoint".
Traceback (most recent call last):
File "/Users/rui/anaconda3/envs/ChatDev_conda_env/lib/python3.9/site-packages/tenacity/init.py", line 382, in call
result = fn(*args, **kwargs)
File "/Users/rui/workbrench/ChatDev/camel/utils.py", line 157, in wrapper
return func(self, *args, **kwargs)
File "/Users/rui/workbrench/ChatDev/camel/agents/chat_agent.py", line 239, in step
response = self.model_backend.run(messages=openai_messages)
File "/Users/rui/workbrench/ChatDev/camel/model_backend.py", line 68, in run
encoding = tiktoken.encoding_for_model(self.model_type.value)
File "/Users/rui/anaconda3/envs/ChatDev_conda_env/lib/python3.9/site-packages/tiktoken/model.py", line 70, in encoding_for_model
raise KeyError(
KeyError: 'Could not automatically map glm-4 to a tokeniser. Please use tiktok.get_encoding to explicitly get the tokeniser you expect.'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/rui/workbrench/ChatDev/run.py", line 135, in
chat_chain.execute_chain()
File "/Users/rui/workbrench/ChatDev/chatdev/chat_chain.py", line 168, in execute_chain
self.execute_step(phase_item)
File "/Users/rui/workbrench/ChatDev/chatdev/chat_chain.py", line 138, in execute_step
self.chat_env = self.phases[phase].execute(self.chat_env,
File "/Users/rui/workbrench/ChatDev/chatdev/phase.py", line 295, in execute
self.chatting(chat_env=chat_env,
File "/Users/rui/workbrench/ChatDev/chatdev/utils.py", line 79, in wrapper
return func(*args, **kwargs)
File "/Users/rui/workbrench/ChatDev/chatdev/phase.py", line 133, in chatting
assistant_response, user_response = role_play_session.step(input_user_msg, chat_turn_limit == 1)
File "/Users/rui/workbrench/ChatDev/camel/agents/role_playing.py", line 247, in step
assistant_response = self.assistant_agent.step(user_msg_rst)
File "/Users/rui/anaconda3/envs/ChatDev_conda_env/lib/python3.9/site-packages/tenacity/init.py", line 289, in wrapped_f
return self(f, *args, **kw)
File "/Users/rui/anaconda3/envs/ChatDev_conda_env/lib/python3.9/site-packages/tenacity/init.py", line 379, in call
do = self.iter(retry_state=retry_state)
File "/Users/rui/anaconda3/envs/ChatDev_conda_env/lib/python3.9/site-packages/tenacity/init.py", line 326, in iter
raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x119747fd0 state=finished raised KeyError>]
代码定位:
/site-packages/tiktoken/model.py
MODEL_TO_ENCODING: dict[str, str] = {
# chat
"gpt-4": "cl100k_base",
"gpt-3.5-turbo": "cl100k_base",
# text
"text-davinci-003": "p50k_base",
"text-davinci-002": "p50k_base",
"text-davinci-001": "r50k_base",
"text-curie-001": "r50k_base",
"text-babbage-001": "r50k_base",
"text-ada-001": "r50k_base",
"davinci": "r50k_base",
"curie": "r50k_base",
"babbage": "r50k_base",
"ada": "r50k_base",
# code
"code-davinci-002": "p50k_base",
"code-davinci-001": "p50k_base",
"code-cushman-002": "p50k_base",
"code-cushman-001": "p50k_base",
"davinci-codex": "p50k_base",
"cushman-codex": "p50k_base",
# edit
"text-davinci-edit-001": "p50k_edit",
"code-davinci-edit-001": "p50k_edit",
# embeddings
"text-embedding-ada-002": "cl100k_base",
# old embeddings
"text-similarity-davinci-001": "r50k_base",
"text-similarity-curie-001": "r50k_base",
"text-similarity-babbage-001": "r50k_base",
"text-similarity-ada-001": "r50k_base",
"text-search-davinci-doc-001": "r50k_base",
"text-search-curie-doc-001": "r50k_base",
"text-search-babbage-doc-001": "r50k_base",
"text-search-ada-doc-001": "r50k_base",
"code-search-babbage-code-001": "r50k_base",
"code-search-ada-code-001": "r50k_base",
# open source
"gpt2": "gpt2",
}
def encoding_for_model(model_name: str) -> Encoding:
"""Returns the encoding used by a model."""
encoding_name = None
if model_name in MODEL_TO_ENCODING:
encoding_name = MODEL_TO_ENCODING[model_name]
else:
# Check if the model matches a known prefix
# Prefix matching avoids needing library updates for every model version release
# Note that this can match on non-existent models (e.g., gpt-3.5-turbo-FAKE)
for model_prefix, model_encoding_name in MODEL_PREFIX_TO_ENCODING.items():
if model_name.startswith(model_prefix):
return get_encoding(model_encoding_name)
if encoding_name is None:
raise KeyError(
f"Could not automatically map {model_name} to a tokeniser. "
"Please use `tiktok.get_encoding` to explicitly get the tokeniser you expect."
) from None
return get_encoding(encoding_name)
- 主要言語
- Python
- スター
- 34.5k
- フォーク
- 4.3k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenBMB/ChatDev のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
-
CodeReviewModification never shows the programmer the six review regulations, so fixes are made blind to the checklist they are re-reviewed against対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
FunctionManager silently drops tool modules containing dataclasses with postponed annotations対応中かも @inchang-ing が 12 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
OpenBMB/ChatDev の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
PedestrianDynamics/pyFDS-Evac#766 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 91/100
alchaincyf/nuwa-skill#86 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信
-
Docs Needs Triage
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
pandas-dev/pandas#71055 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: graphify reads files that git's global ignore file hides対応中かも @smngvlkz が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Graphify-Labs/graphify#4335 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信