# InternLM-WQX **Repository Path**: internlm/InternLM-WQX ## Basic Information - **Project Name**: InternLM-WQX - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-09-05 - **Last Updated**: 2024-09-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
| InternLM2-WQX-VL-20B 🤗
internlm2-wqx-20b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm2-wqx-20b/summary) | 2024-06-04 |
| **InternLM2-WQX-VL-20B** | [🤗internlm2-wqx-vl-20b](https://huggingface.co/internlm/internlm2-wqx-vl-20b) | [
internlm2-wqx-vl-20b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm2-wqx-vl-20b/summary) | 2024-06-04 |
## MD5 Check
### LLM权重文件的md5值
```
md5sum ./*
5209adfd6ef7d1724848ff0372362568 ./model-00001-of-00004.safetensors
e37ee2eafecfed543d10dca75998204e ./model-00002-of-00004.safetensors
ea3da8035b0c2a31c369dd463adf9b52 ./model-00003-of-00004.safetensors
f1ff218f801c69fd4c12c534b64e1b60 ./model-00004-of-00004.safetensors
```
### MLLM权重文件的md5值
```
md5sum ./*
158657dbae9bc369d67cf4bfbdfaaf71 ./pytorch_model-00001-of-00005.bin
c21db8ac1315c10df768f6c3ae3f2825 ./pytorch_model-00002-of-00005.bin
ebc4b0b70e8e9f1adc0b728558d650fb ./pytorch_model-00003-of-00005.bin
eaa393a66dc632d0a6f0f7d815c439bb ./pytorch_model-00004-of-00005.bin
7e6e3237d99a7e8bd7ca9ba10747bfdb ./pytorch_model-00005-of-00005.bin
./clip_l_560_pro7b/*
97b05f40ee9826eda467489eed65f85c ./clip_l_560_pro7b/pytorch_model.bin
```
# Quick Start
### 快速调用**InternLM2-WQX-20B**语言模型
使用transformers 后端进行推理
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda"
tokenizer = AutoTokenizer.from_pretrained("internlm/internlm2-wqx-20b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
"internlm/internlm2-wqx-20b",
torch_dtype=torch.bfloat16,
trust_remote_code=True
).to(device).eval()
query = "已知圆柱和圆锥的底面半径相等,侧面积相等,且它们的高均为$ \\sqrt { 3 }$,则圆锥的体积为( ).\nA. $ 2 \\sqrt { 3 } \\pi$\nB. $ 3 \\sqrt { 3 } \\pi$\nC. $ 6 \\sqrt { 3 } \\pi$\nD. $ 9 \\sqrt { 3 } \\pi$"
inputs = tokenizer(query, return_tensors="pt")
inputs = inputs["input_ids"].to(device)
gen_kwargs = {"max_length": 1024, "do_sample": False}
outputs = model.generate(inputs, **gen_kwargs)
outputs = outputs[0].cpu().tolist()[len(inputs[0]) :]
response = tokenizer.decode(outputs, skip_special_tokens=True)
print(response)
```
使用vllm 后端进行推理:
```python
from vllm import LLM, SamplingParams
model_name = "internlm/internlm2-wqx-20b"
prompts = ["已知圆柱和圆锥的底面半径相等,侧面积相等,且它们的高均为$ \\sqrt { 3 }$,则圆锥的体积为( ).\nA. $ 2 \\sqrt { 3 } \\pi$\nB. $ 3 \\sqrt { 3 } \\pi$\nC. $ 6 \\sqrt { 3 } \\pi$\nD. $ 9 \\sqrt { 3 } \\pi$"]
sampling_params = SamplingParams(temperature=0.0, max_tokens=1024)
llm = LLM(
model=model_name,
trust_remote_code=True,
enforce_eager=True,
)
outputs = llm.generate(prompts, sampling_params)
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Prompt: {prompt!r}, \nGenerated text: {generated_text!r}")
```
### **InternLM2-WQX-20B**语言模型的 Web UI
使用transformers后端进行推理:
```
python web_ui_wqx.py -m internlm/internlm2-wqx-20b
```
### 快速调用**InternLM2-WQX-VL-20B**视觉语言模型
使用transformers后端进行推理:
```python
from PIL import Image
from io import BytesIO
import requests
from transformers import AutoModel, AutoTokenizer, AutoModelForCausalLM
import torch
from infer_wqx_vl import process_query_and_image, HD_transform
model_path = "internlm/internlm2-wqx-vl-20b"
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModel.from_pretrained(model_path, torch_dtype=torch.bfloat16, trust_remote_code=True).cuda().eval()
model.cuda().half()
model.tokenizer = tokenizer
image_url = "https://ks-1302698447.cos.ap-shanghai.myqcloud.com/img/phymerge.png"
query = "体育课上两位同学在室内羽毛球场进行羽毛球比赛,羽毛球在空中上升的运动轨迹如图中虚线所示,考虑空气阻力,羽毛球加速度方向示意图可能正确的是(\u3000\u3000) \nA: