You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to add a tool that translates kor to eng.
Under the same system prompt, gpt-4o-mini calls the tool, whereas open-source models translate the text directly.
Here’s a list of open-source models I have tested:
Are there any open-source models suitable for calling tools?
(or should I tweak my prompt?)
fromlangchain.agentsimporttoolfromtransformersimportAutoProcessor, SeamlessM4Tv2Model, pipelinetranslator=pipeline(
"translation",
model="facebook/nllb-200-distilled-600M",
device=0,
src_lang="kor_Hang",
tgt_lang="eng_Latn",
max_length=512,
)
@tooldeftranslate_kor_to_eng(korean_text):
"""Translate Korean text to English text"""print("tool called")
translated_text=translator(korean_text)[0]["translation_text"]
returntranslated_texttools= [translate_kor_to_eng]
llm_with_tools=ChatOpenAI(model="gpt-4o-mini").bind_tools(tools)
...
system_prompt= \
""" You are a translator. Given a Korean text (or non-English), you will translate it to English. Use a tool called 'translate_kor_to_eng' that can translate Korean text to English text. """chat_prompt_template=ChatPromptTemplate.from_messages(
[
SystemMessagePromptTemplate.from_template(system_prompt),
HumanMessagePromptTemplate.from_template("Text: {user_input}"),
]
)
gpt-4o-mini
================================ Human Message =================================
Text: 이것은 LLM 모델의 번역 능력을 테스트하기 위한 프롬프트 입니다.
================================== Ai Message ==================================
Tool Calls:
translate_kor_to_eng (call_MZYhbabGTZmLvk9fL2fPu0ic)
Call ID: call_MZYhbabGTZmLvk9fL2fPu0ic
Args:
korean_text: 이것은 LLM 모델의 번역 능력을 테스트하기 위한 프롬프트 입니다.
tool called
================================= Tool Message =================================
Name: translate_kor_to_eng
This is a prompt to test the translation ability of the LLM model.
================================== Ai Message ==================================
This is a prompt to test the translation ability of the LLM model.
Open-source (ex. phi-4)
================================ Human Message =================================
Text: 이것은 LLM 모델의 번역 능력을 테스트하기 위한 프롬프트 입니다.
================================== Ai Message ==================================
This is a prompt for testing the translation capabilities of an LLM model.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to add a tool that translates
kor
toeng
.Under the same system prompt,
gpt-4o-mini
calls the tool, whereas open-source models translate the text directly.Here’s a list of open-source models I have tested:
Are there any open-source models suitable for calling tools?
(or should I tweak my prompt?)
gpt-4o-mini
Open-source (ex. phi-4)
Beta Was this translation helpful? Give feedback.
All reactions