Comments (4)
See examples here https://github.com/InternLM/lagent#run-a-react-agent-with-internlm.
You can simply choose to use llama2 by replacing the model name of internlm to llama2 through Huggingface Transformer.
from lagent.
See examples here https://github.com/InternLM/lagent#run-a-react-agent-with-internlm. You can simply choose to use llama2 by replacing the model name of internlm to llama2 through Huggingface Transformer.
我用Llama-2-7b-chat-hf 模型,报如下错误
Cell In[5], line 16
8 python_interpreter = PythonInterpreter()
10 chatbot = ReAct(
11 llm=llm,
12 action_executor=ActionExecutor(
13 actions=[search_tool, python_interpreter]),
14 )
---> 16 response = chatbot.chat('若$z=-1+\sqrt{3}i$,则$\frac{z}{{z\overline{z}-1}}=\left(\ \ \right)$')
17 print(response.response)
File ~/lagent/lagent/agents/react.py:222, in ReAct.chat(self, message)
216 for turn in range(self.max_turn):
217 prompt = self._protocol.format(
218 chat_history=self.session_history,
219 inner_step=self._inner_history,
220 action_executor=self._action_executor,
221 force_stop=force_stop)
--> 222 response = self._llm.generate_from_template(prompt, 512)
223 self._inner_history.append(
224 dict(role='assistant', content=response))
225 thought, action, action_input = self._protocol.parse(
226 response, self._action_executor)
File ~/lagent/lagent/llms/huggingface.py:128, in HFTransformer.generate_from_template(self, templates, max_out_len, **kwargs)
121 """Generate completion from a list of templates.
122
123 Args:
124 templates (List[PromptType]): A list of templates.
125 max_out_len (int): The maximum length of the output.
126 """
127 inputs = self.parse_template(templates)
--> 128 response = self.generate(inputs, max_out_len=max_out_len, **kwargs)
129 return response.replace(
130 self.template_parser.roles['assistant']['end'].strip(),
131 '').strip()
File ~/lagent/lagent/llms/huggingface.py:105, in HFTransformer.generate(self, inputs, max_out_len, **kwargs)
101 input_ids = self.tokenizer(
102 inputs, truncation=True,
103 max_length=self.max_seq_len - max_out_len)['input_ids']
104 input_ids = torch.tensor(input_ids, device=self.model.device)
--> 105 outputs = self.model.generate(
106 input_ids, max_new_tokens=max_out_len, **kwargs)
108 if not self.extract_pred_after_decode:
109 outputs = outputs[:, input_ids.shape[1]:]
File ~/anaconda3/envs/langchain/lib/python3.11/site-packages/torch/utils/_contextlib.py:115, in context_decorator..decorate_context(*args, **kwargs)
112 @functools.wraps(func)
113 def decorate_context(*args, **kwargs):
114 with ctx_factory():
--> 115 return func(*args, **kwargs)
File ~/anaconda3/envs/langchain/lib/python3.11/site-packages/transformers/generation/utils.py:1261, in GenerationMixin.generate(self, inputs, generation_config, logits_processor, stopping_criteria, prefix_allowed_tokens_fn, synced_gpus, assistant_model, streamer, **kwargs)
1258 synced_gpus = False
1260 # 1. Handle generation_config
and kwargs that might update it, and validate the .generate()
call
-> 1261 self._validate_model_class()
1263 # priority: generation_config
argument > model.generation_config
(the default generation config)
1264 if generation_config is None:
1265 # legacy: users may modify the model configuration to control generation -- update the generation config
1266 # model attribute accordingly, if it was created from the model config
File ~/anaconda3/envs/langchain/lib/python3.11/site-packages/transformers/generation/utils.py:1135, in GenerationMixin._validate_model_class(self)
1133 if generate_compatible_classes:
1134 exception_message += f" Please use one of the following classes instead: {generate_compatible_classes}"
-> 1135 raise TypeError(exception_message)
TypeError: The current model class (LlamaModel) is not compatible with .generate()
, as it doesn't have a language model head. Please use one of the following classes instead: {'LlamaForCausalLM'}
from lagent.
As suggested in the error log, you should change the LLaMaModel
to LlamaForCauslLM
. For Lagent, you need to change the LLM from HFTransformer
to HFTransformerCausalLM
.
from lagent.
As suggested in the error log, you should change the
LLaMaModel
toLlamaForCauslLM
. For Lagent, you need to change the LLM fromHFTransformer
toHFTransformerCausalLM
.
agent 代理的一点都不准
from lagent.
Related Issues (20)
- Bug: ModuleNotFoundError: No module named 'ilagent' HOT 1
- 使用 example/internlm2_agent_wen_demo 出现问题
- internlm2_agent_cli_demo 运行出错 HOT 2
- 运行示例时报错TypeError: LMDeployClient.__init__() missing 1 required positional argument: 'path' HOT 2
- May I know once I want to make a LLM by `BaseAPIModel`, where could I input the url_base? HOT 6
- Lagent Web Demo csv数据分析运行出错
- 如何设计微调数据? HOT 2
- 请问,我如何调用第三方的api HOT 1
- 运行示例时报错requests.exceptions.ConnectTimeout HOT 1
- 工具调用幻觉严重
- 为什么部署成功了internlm2_agent_web_demo.py,但是模型回答不调用工具呢? HOT 1
- internlm2_agent_web_demo的actions都无法调用么
- 使用lagent.actions.PPT时,发现的一个BUG。 HOT 2
- 目前GPTAPI不支持internlm api调用吗? HOT 2
- 由于internlm api不支持system输入,所以agent工具调用不能用,有没有什么解决方法啊?
- lagent/llms/lmdepoly_wrapper.py 文件名错误,应该改为 lmdeploy_wrapper.py
- ModuleNotFoundError: No module named 'lagent.llms.lmdeploy_wrapper' HOT 7
- TypeError: string indices must be integers
- [Docs] A100算力加持!书生大模型实战营第3期全面升级,趣味闯关模式等你开启
- 能不能好好的维护文档
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lagent.