---
title: Qwen2-7B-Instruct-GGUF
canonical_url: "https://www.modelscope.cn/models/rubraAI/Qwen2-7B-Instruct-GGUF"
md_url: "https://www.modelscope.cn/models/rubraAI/Qwen2-7B-Instruct-GGUF.md"
repository: rubraAI/Qwen2-7B-Instruct-GGUF
last_updated: 2024-07-15
license: apache-2.0
pipeline_tag: text-generation
tasks:
  - text-generation
library_name:
  - gguf
language:
  - en
  - zh
downloads: 375
stars: 8
tags:
  - function-calling
  - tool-calling
  - agentic
  - rubra
  - conversational
  - "工具调用"
  - "量化"
  - "对话"
  - gguf
---

# Qwen2-7B-Instruct-GGUF

> Qwen2-7B-Instruct-GGUF - rubraAI 在 ModelScope 开源的模型。Original model: [rubraAI/Qwen2-7B-Instruct](https://www.modelscope.cn/models/rubraAI/Qwen2-7B-Instruct) The model is the result of further post-training…

rubraAI/Qwen2-7B-Instruct-GGUF 是 ModelScope 魔搭社区上的text-generation模型，采用 apache-2.0 许可。

- **Repository**: rubraAI/Qwen2-7B-Instruct-GGUF
- **License**: apache-2.0
- **Tasks**: text-generation
- **Tags**: function-calling, tool-calling, agentic, rubra, conversational, 工具调用, 量化, 对话, gguf
- **Downloads**: 375
- **Stars**: 8
- **Last updated**: 2024-07-15

Source: https://www.modelscope.cn/models/rubraAI/Qwen2-7B-Instruct-GGUF

---

# Qwen2 7B Instruct GGUF

原始模型: [rubraAI/Qwen2-7B-Instruct](https://www.modelscope.cn/models/rubraAI/Qwen2-7B-Instruct)。 本模型是它的gguf版本。

## 模型描述
该原始模型是在进一步微调 [Qwen/Qwen2-7B-Instruct](https://www.modelscope.cn/models/qwen/Qwen2-7B-Instruct) 的基础上得到的。它能够进行多轮复杂的工具调用。

## 训练

该模型在包含多样化工具的调用、聊天数据集和Instruct数据的专有数据集上进行了进一步post-training（freeze tuned和DPO）。

## 如何使用
### 1. 克隆仓库

```bash
git clone https://github.com/rubra-ai/tools.cpp.git
cd tools.cpp
```

### 2. 编译源代码

<div style={{ display: 'flex', gap: '20px' }}>
  <div style={{ flex: 1 }}>
    <h5>Mac M系列用户:</h5>
    <pre><code>make</code></pre>
  </div>
  <div style={{ flex: 1 }}>
    <h5>Nvidia GPU (CUDA) 用户:</h5>
    <pre><code>make LLAMA_CUDA=1</code></pre>
  </div>
</div>


### 3. 安装一个js辅助包来处理一些罕见的错误

:::info 
需要有 Node.js 和 npm 已安装。
:::

```bash
npm install jsonrepair --no-bin-links
```

* 如果以上命令遇到权限问题，请加上 `sudo`。

### 4. 下载模型

推荐fp16或者Q8。

### 5. 运行server服务器， 兼容openai格式

```bash
./llama-server -ngl 37 -m rubra-qwen2-7b-instruct.Q8_0.gguf --port 1234 --host 0.0.0.0 -c 8000 --chat-template chatml
```

### 6. 测试一下服务器是否正确运行了

```bash
curl localhost:1234/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tokenabc-123" \
  -d '{
    "model": "rubra-model",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "你好， 助手"
      }
    ]
  }'
```

应该能看到如下结果:
```
{"choices":[{"finish_reason":"stop","index":0,"message":{"content":"你好！请问有什么可以帮助你的吗？","role":"assistant"}}],"created":1721081429,"model":"rubra-model","object":"chat.completion","usage":{"completion_tokens":9,"prompt_tokens":25,"total_tokens":34},"id":"chatcmpl-3U6Wer5QjcVWc7VJF5lZtZEFvL4iNqAK"}
```

### 7. python工具调用例子

```python
# If openai is not installed, run `pip install openai`
from openai import OpenAI

client = OpenAI(api_key="xyz", base_url="http://localhost:1234/v1/")

tools = [
  {
    "type": "function",
    "function": {
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA",
          },
          "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
        },
        "required": ["location"],
      },
    }
  }
]

messages = [{"role": "user", "content": "今天上海啥天气?"}]
completion = client.chat.completions.create(
  model="rubra-model",
  messages=messages,
  tools=tools,
  tool_choice="auto"
)

print(completion)
```

输出如下：ai尝试使用工具get_current_weather来查询上海的天气。

```python
ChatCompletion(id='chatcmpl-i4xL9w1ti1hQq2aP9x79NmpZVQ3Gc47Q', choices=[Choice(finish_reason='tool_calls', index=0, logprobs=None, message=ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='8ababb09', function=Function(arguments='{"location":"Shanghai","unit":"celsius"}', name='get_current_weather'), type='function')]))], created=1721081535, model='rubra-model', object='chat.completion', system_fingerprint=None, usage=CompletionUsage(completion_tokens=32, prompt_tokens=223, total_tokens=255))
```

更多使用方法请参考 https://docs.rubra.ai/inference/llamacpp， 比如[test_llamacpp.ipynb](https://github.com/rubra-ai/tools.cpp/blob/010f4d282e86babe216af6e037ab10bf078415e7/test_llamacpp.ipynb) or [test_llamacpp_streaming.ipynb](https://github.com/rubra-ai/tools.cpp/blob/master/test_llamacpp_streaming.ipynb)。如有问题或建议，请在我们的Github仓库提交一个问题/issue：https://github.com/rubra-ai/rubra 

## 限制和偏见

虽然该模型在广泛的任务上表现良好，但它可能仍然会产生偏见或错误的输出。用户在使用该模型时应谨慎，并在敏感或高风险应用中保持批判性的判断。模型的输出受其训练数据的影响，可能包含固有的偏见。

## 道德考虑

用户应确保该模型的部署符合道德指南，并考虑所生成文本的潜在社会影响。我们强烈反对将该模型滥用于生成有害或误导性内容。

## 致谢

我们感谢Alibaba Cloud提供的基础模型。

## 联系方式

如果对此模型有任何问题或意见或建议，请联系 [rubra团队](mailto:rubra@acorn.io)。

## 引用信息

如果您使用了这项工作，请引用如下：

```
@misc {rubra_ai_2024,
	author       = { Sanjay Nadhavajhala and Yingbei Tong },
	title        = { Rubra-Qwen2-7B-Instruct },
	year         = 2024,
	url          = { https://huggingface.co/rubra-ai/Qwen2-7B-Instruct },
	doi          = { 10.57967/hf/2658 },
	publisher    = { Hugging Face }
}
```
