检查其他资源
- 我为这个问题添加了一个非常描述性的标题。
- 我在LangChain文档中使用集成搜索进行搜索。
- 我使用GitHub搜索查找类似的问题,但没有找到。
- 我确信这是LangChain中的一个bug,而不是我的代码。
- 通过更新到LangChain的最新稳定版本(或特定集成包)无法解决此bug。
示例代码
以下代码将无限次打印关于鱼的多首诗和诗的多个修订版本:
from langchain_community.chat_models.ollama import ChatOllama
llm = ChatOllama(model='llama3:70b')
for chunk in llm.stream('Write a poem about fish'):
print(chunk.content)
可以通过添加明确的停止条件来解决这个问题:
llm = ChatOllama(model='llama3:70b', stop=["<|eot_id|>"])
请务必将 Ollama
和 ChatOllama
元素更新为为此 Llama3 包含此停止条件。
错误信息和堆栈跟踪(如果适用)
- 无响应*
描述
请参阅示例代码。Llama3下的生成代数永远不会终止
系统信息
系统信息
操作系统:Darwin
操作系统版本:Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020
Python版本:3.11.5 (main, Sep 11 2023, 08:31:25) [Clang 14.0.6 ]
软件包信息
langchain_core: 0.1.45
langchain: 0.1.16
langchain_community: 0.0.32
langsmith: 0.1.43
langchain_google_vertexai: 0.0.5
langchain_openai: 0.0.8
langchain_text_splitters: 0.0.1
langchainhub: 0.1.14
langserve: 0.0.34
没有安装的软件包(不一定是一个问题)
以下软件包未找到:
langgraph
8条答案
按热度按时间k3fezbri1#
更新软件包
rjjhvcjd2#
我之前也遇到了同样的问题,现在已经更新到
langchain==0.1.16
并解决了。pinkon5k3#
我之前也遇到了同样的问题,现在已经解决了。问题仍然存在,使用的是
langchain==0.1.16
配置。我正在使用以下配置:ki0zmccv4#
ChatBedrock
的问题也是如此——它看起来需要一个新的提示模板,适用于 Llama3,该模板应遵循:https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-3/
cl25kdpy5#
解:设甲、乙两车从A地到B地的路程为x千米,
根据题意得$\dfrac{x}{40}-\dfrac{x}{50}=2$,
解得$x=400$.
答:甲、乙两车从A地到B地的路程为400千米。
72qzrwbm6#
@DiazBejaranoD 在我这边没有起作用。
我只是手动添加了停止序列,但似乎可以工作。
^ 希望这对其他人有帮助。
inn6fuwd7#
重复一下原始帖子中的注解。修复错误很容易,使用显式的停止条件示例化ChatModel。
llm = ChatOllama(model='llama3:70b', stop=["<|eot_id|>"])
发布此帖的目的是让有人更新ChatOllama源代码以包含修复。
bsxbgnwa8#
我看到了"无尽的流"和输出中的意外标记。
向num_tokens添加一个有限值可以停止无尽的流,但会截断句子的生成。
当我尝试添加停止条件时,我得到了一个值错误:
ValueError:
stopfound in both the input and default params.
我似乎拥有最新版本的langchain: