库名称:transformers
许可证:mit
基础模型:
- google/gemma-2b-it
流水线标签:text-generation
模型ID的模型卡
此模型融合了peft微调模型,是一个独立模型。
模型详情
模型描述
这是🤗 transformers模型的模型卡,已推送至Hub。此模型卡为自动生成。
- 开发者:[Liching]
- 资助方:[hobby]
- 模型类型:[text-generation]
- 语言(NLP):[En]
- 许可证:[MIT]
- 微调基础模型:[gemma-2b-it]
用途
gemma-2b-it无法用于工具调用,其响应方式类似于近期开发的Deepseek r1,这些限制在微调模型时已考虑在内。
偏见、风险与限制
由于模型仅微调了1个周期,因此容易产生偏见和错误。
如何开始使用模型
使用以下代码开始使用模型。
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from transformers import pipeline
import torch
model_id = "langdai/gemma-2-2b-it-tool-think"
model = AutoModelForCausalLM.from_pretrained(model_id,
device_map="cuda:0",
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model.eval()
generator = pipeline("text-generation", model= model, tokenizer= tokenizer)
prompt="""<bos><start_of_turn>human
You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags.You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions.Here are the available tools:<tools> [{'type': 'function', 'function': {'name': 'convert_currency', 'description': 'Convert from one currency to another', 'parameters': {'type': 'object', 'properties': {'amount': {'type': 'number', 'description': 'The amount to convert'}, 'from_currency': {'type': 'string', 'description': 'The currency to convert from'}, 'to_currency': {'type': 'string', 'description': 'The currency to convert to'}}, 'required': ['amount', 'from_currency', 'to_currency']}}}, {'type': 'function', 'function': {'name': 'calculate_distance', 'description': 'Calculate the distance between two locations', 'parameters': {'type': 'object', 'properties': {'start_location': {'type': 'string', 'description': 'The starting location'}, 'end_location': {'type': 'string', 'description': 'The ending location'}}, 'required': ['start_location', 'end_location']}}}] </tools>Use the following pydantic model json schema for each tool call you will make: {'title': 'FunctionCall', 'type': 'object', 'properties': {'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['arguments', 'name']}For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
<tool_call>
{tool_call}
</tool_call>Also, before making a call to a function take the time to plan the function to take. Make that thinking process between <think>{your thoughts}</think>
Hi, I need to convert 500 INR to Euros. Can you help me with that?<end_of_turn><eos>
<start_of_turn>model
<think>"""
output = generator([{"role": "user", "content": prompt}], max_new_tokens=512, return_full_text=False)[0]
print(output)
环境影响
碳排放量可使用机器学习影响计算器估算,详见Lacoste et al. (2019)。
- 硬件类型:[T4 24GPU]
- 使用时长:[4小时]