---
title: AMchat
canonical_url: "https://www.modelscope.cn/models/yondong/AMchat"
md_url: "https://www.modelscope.cn/models/yondong/AMchat.md"
repository: yondong/AMchat
chinese_name: "AMchat-7B (高等数学大模型)"
last_updated: 2024-03-14
license: "Apache License 2.0"
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - internlm2
architectures:
  - InternLM2ForCausalLM
library_name:
  - pytorch
frameworks:
  - pytorch
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 257
stars: 7
---

# AMchat

> AMchat - yondong 在 ModelScope 开源的模型。AM (Advanced Mathematics) chat 高等数学大模型。一个集成数学知识和高等数学习题及其解答的大语言模型。

yondong/AMchat 是 ModelScope 魔搭社区上的text-generation模型，采用 Apache License 2.0 许可，可用 deploy_task text/emb、lmdeploy 0.9.1、lmdeploy_turbomind 0.9.1 部署。

- **Repository**: yondong/AMchat
- **License**: Apache License 2.0
- **Tasks**: text-generation
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, sglang 0.5.2, vllm 0.9.2
- **Downloads**: 257
- **Stars**: 7
- **Last updated**: 2024-03-14

Source: https://www.modelscope.cn/models/yondong/AMchat

---

<p align="center">
    <img src="logo.png" width="200"/>
<p>

<p align="center">
    <b><font size="6">AMchat</font></b> 
<p>

<div align="center">

[💻Github Repo](https://github.com/AXYZdong/AMchat)

</div>

AM (Advanced Mathematics) Chat is a large-scale language model that integrates mathematical knowledge, advanced mathematics problems, and their solutions. This model utilizes a dataset that combines Math and advanced mathematics problems with their analyses. It is based on the InternLM2-Math-7B model and has been fine-tuned with xtuner, specifically designed to solve advanced mathematics problems.

If you find this project helpful, feel free to ⭐ Star it and help more people discover it!

### Import from Transformers
To load the AMchat model using Transformers, use the following code:
```python
from modelscope import snapshot_download, AutoTokenizer, AutoModelForCausalLM
import torch

model_dir = snapshot_download("Shanghai_AI_Laboratory/internlm2-math-7b")
tokenizer = AutoTokenizer.from_pretrained(model_dir, device_map="auto", trust_remote_code=True)

# Set `torch_dtype=torch.float16` to load model in float16, otherwise it will be loaded as float32 and might cause OOM Error.
model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto",  trust_remote_code=True, torch_dtype=torch.float16)
model = model.eval()
response, history = model.chat(tokenizer, "1+1=", history=[], meta_instruction="")
print(response)
```


AM (Advanced Mathematics) chat 是一个集成了数学知识和高等数学习题及其解答的大语言模型。该模型使用 Math 和高等数学习题及其解析融合的数据集，基于 InternLM2-Math-7B 模型，通过 xtuner 微调，专门设计用于解答高等数学问题。

如果你觉得这个项目对你有帮助，欢迎 ⭐ Star，让更多的人发现它！

### 通过 Transformers 加载
通过以下的代码加载 AMchat  模型

```python
from modelscope import snapshot_download, AutoTokenizer, AutoModelForCausalLM
import torch

model_dir = snapshot_download("Shanghai_AI_Laboratory/internlm2-math-7b")
tokenizer = AutoTokenizer.from_pretrained(model_dir, device_map="auto", trust_remote_code=True)

# `torch_dtype=torch.float16` 可以令模型以 float16 精度加载，否则 transformers 会将模型加载为 float32，导致显存不足
model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto",  trust_remote_code=True, torch_dtype=torch.float16)
model = model.eval()
response, history = model.chat(tokenizer, "1+1=", history=[], meta_instruction="")
print(response)
```
