当前位置: 首页 > news >正文

xshell如何做网站外贸接单平台哪个最好

xshell如何做网站,外贸接单平台哪个最好,wordpress 4.0 慢,目录网站模板目录 前言 本机环境 GLM4代码库下载 模型文件下载:文件很大 修改为从本地模型文件启动 启动模型cli对话demo 慢,巨慢,一个字一个字的蹦 GPU资源使用情况 GLM3资源使用情况对比 前言 GLM-4-9B 是智谱 AI 推出的最新一代预训练模型 …

目录

前言

本机环境

GLM4代码库下载

模型文件下载:文件很大

修改为从本地模型文件启动

启动模型cli对话demo

慢,巨慢,一个字一个字的蹦

GPU资源使用情况 

GLM3资源使用情况对比


前言

GLM-4-9B 是智谱 AI 推出的最新一代预训练模型 GLM-4 系列中的开源版本。

在语义、数学、推理、代码和知识等多方面的数据集测评中, GLM-4-9B 及其人类偏好对齐的版本 GLM-4-9B-Chat 均表现出超越 Llama-3-8B 的卓越性能。

除了能进行多轮对话,GLM-4-9B-Chat 还具备网页浏览、代码执行、自定义工具调用(Function Call)和长文本推理(支持最大 128K 上下文)等高级功能。

本代模型增加了多语言支持,支持包括日语,韩语,德语在内的 26 种语言。

我们还推出了支持 1M 上下文长度(约 200 万中文字符)的 GLM-4-9B-Chat-1M 模型和基于 GLM-4-9B 的多模态模型 GLM-4V-9B。GLM-4V-9B 具备 1120 * 1120 高分辨率下的中英双语多轮对话能力,在中英文综合能力、感知推理、文字识别、图表理解等多方面多模态评测中,GLM-4V-9B 表现出超越 GPT-4-turbo-2024-04-09、Gemini 1.0 Pro、Qwen-VL-Max 和 Claude 3 Opus 的卓越性能。

本机环境

OS:Windows

CPU:AMD Ryzen 5 3600X 6-Core Processor

Mem:32GB

GPU:RTX 4060Ti 16G

GLM4代码库下载

参考:LLM大语言模型(一):ChatGLM3-6B本地部署_llm3 部署-CSDN博客

# 下载代码库
https://github.com/THUDM/GLM-4.git

模型文件下载:文件很大

建议从modelscope下载模型,这样就不用担心网络问题了。

模型链接如下: 

glm-4-9b-chat汇聚各领域最先进的机器学习模型,提供模型探索体验、推理、训练、部署和应用的一站式服务。icon-default.png?t=N7T8https://modelscope.cn/models/ZhipuAI/glm-4-9b-chat/files

git lfs install # 以安装则忽略
git clone https://www.modelscope.cn/ZhipuAI/glm-4-9b-chat.git

做好心理准备:接近20G(我的带宽只有300Mbps~~)

修改为从本地模型文件启动

修改此文件basic_demo/trans_cli_demo.py

修改这一行:

MODEL_PATH = os.environ.get('MODEL_PATH', 'D:\github\glm-4-9b-chat') 该为你下载的模型文件夹

"""
This script creates a CLI demo with transformers backend for the glm-4-9b model,
allowing users to interact with the model through a command-line interface.Usage:
- Run the script to start the CLI demo.
- Interact with the model by typing questions and receiving responses.Note: The script includes a modification to handle markdown to plain text conversion,
ensuring that the CLI interface displays formatted text correctly.
"""import os
import torch
from threading import Thread
from typing import Union
from pathlib import Path
from peft import AutoPeftModelForCausalLM, PeftModelForCausalLM
from transformers import (AutoModelForCausalLM,AutoTokenizer,PreTrainedModel,PreTrainedTokenizer,PreTrainedTokenizerFast,StoppingCriteria,StoppingCriteriaList,TextIteratorStreamer
)ModelType = Union[PreTrainedModel, PeftModelForCausalLM]
TokenizerType = Union[PreTrainedTokenizer, PreTrainedTokenizerFast]# 改为你下载的模型文件夹
MODEL_PATH = os.environ.get('MODEL_PATH', 'D:\github\glm-4-9b-chat')def load_model_and_tokenizer(model_dir: Union[str, Path], trust_remote_code: bool = True
) -> tuple[ModelType, TokenizerType]:model_dir = Path(model_dir).expanduser().resolve()if (model_dir / 'adapter_config.json').exists():model = AutoPeftModelForCausalLM.from_pretrained(model_dir, trust_remote_code=trust_remote_code, device_map='auto')tokenizer_dir = model.peft_config['default'].base_model_name_or_pathelse:model = AutoModelForCausalLM.from_pretrained(model_dir, trust_remote_code=trust_remote_code, device_map='auto')tokenizer_dir = model_dirtokenizer = AutoTokenizer.from_pretrained(tokenizer_dir, trust_remote_code=trust_remote_code, encode_special_tokens=True, use_fast=False)return model, tokenizermodel, tokenizer = load_model_and_tokenizer(MODEL_PATH, trust_remote_code=True)class StopOnTokens(StoppingCriteria):def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:stop_ids = model.config.eos_token_idfor stop_id in stop_ids:if input_ids[0][-1] == stop_id:return Truereturn Falseif __name__ == "__main__":history = []max_length = 8192top_p = 0.8temperature = 0.6stop = StopOnTokens()print("Welcome to the GLM-4-9B CLI chat. Type your messages below.")while True:user_input = input("\nYou: ")if user_input.lower() in ["exit", "quit"]:breakhistory.append([user_input, ""])messages = []for idx, (user_msg, model_msg) in enumerate(history):if idx == len(history) - 1 and not model_msg:messages.append({"role": "user", "content": user_msg})breakif user_msg:messages.append({"role": "user", "content": user_msg})if model_msg:messages.append({"role": "assistant", "content": model_msg})model_inputs = tokenizer.apply_chat_template(messages,add_generation_prompt=True,tokenize=True,return_tensors="pt").to(model.device)streamer = TextIteratorStreamer(tokenizer=tokenizer,timeout=60,skip_prompt=True,skip_special_tokens=True)generate_kwargs = {"input_ids": model_inputs,"streamer": streamer,"max_new_tokens": max_length,"do_sample": True,"top_p": top_p,"temperature": temperature,"stopping_criteria": StoppingCriteriaList([stop]),"repetition_penalty": 1.2,"eos_token_id": model.config.eos_token_id,}t = Thread(target=model.generate, kwargs=generate_kwargs)t.start()print("GLM-4:", end="", flush=True)for new_token in streamer:if new_token:print(new_token, end="", flush=True)history[-1][1] += new_tokenhistory[-1][1] = history[-1][1].strip()

启动模型cli对话demo

运行该py文件即可,效果如下:

模型运行时会报个warning:

C:\Users\Administrator\.cache\huggingface\modules\transformers_modules\glm-4-9b-chat\modeling_chatglm.pm.py:189: UserWarning: 1Torch was not compiled with flash attention. (Triggered internally at C:\cb\pytorc000h_1000000000000\work\aten\src\ATen\native\transformers\cuda\sdp_utils.cpp:263.)
  context_layer = torch.nn.functional.scaled_dot_product_attention(query_layer, key_layer, value_layer, 

不过也没影响运行。

慢,巨慢,一个字一个字的蹦

GPU资源使用情况 

  • 16G显存,使用率90%+
  • 内存使用16G,50%

GLM3资源使用情况对比


文章转载自:
http://wanjiacinc.pfbx.cn
http://wanjiashinkansen.pfbx.cn
http://wanjiatabinet.pfbx.cn
http://wanjiaputt.pfbx.cn
http://wanjiahospitable.pfbx.cn
http://wanjiahotliner.pfbx.cn
http://wanjiaimprudent.pfbx.cn
http://wanjiasiphonet.pfbx.cn
http://wanjialesbian.pfbx.cn
http://wanjiaisogloss.pfbx.cn
http://wanjiafaultiness.pfbx.cn
http://wanjiamaronite.pfbx.cn
http://wanjiacholecystitis.pfbx.cn
http://wanjiapuggry.pfbx.cn
http://wanjiakreisler.pfbx.cn
http://wanjiawobegone.pfbx.cn
http://wanjianudibranch.pfbx.cn
http://wanjiainterlay.pfbx.cn
http://wanjialarnax.pfbx.cn
http://wanjiasteepled.pfbx.cn
http://wanjiabangbang.pfbx.cn
http://wanjiaintroductory.pfbx.cn
http://wanjiacyclometry.pfbx.cn
http://wanjiapyrrhic.pfbx.cn
http://wanjiamatriculability.pfbx.cn
http://wanjiaclerically.pfbx.cn
http://wanjiacryptocrystalline.pfbx.cn
http://wanjiasantana.pfbx.cn
http://wanjiacpu.pfbx.cn
http://wanjiabeachhead.pfbx.cn
http://wanjiadeoxygenization.pfbx.cn
http://wanjiagameness.pfbx.cn
http://wanjiafloatable.pfbx.cn
http://wanjiaaigrette.pfbx.cn
http://wanjiaweeper.pfbx.cn
http://wanjiavasty.pfbx.cn
http://wanjianonfulfillment.pfbx.cn
http://wanjiaoer.pfbx.cn
http://wanjiagalea.pfbx.cn
http://wanjiadabbler.pfbx.cn
http://wanjiaspca.pfbx.cn
http://wanjiatranstainer.pfbx.cn
http://wanjialidocaine.pfbx.cn
http://wanjiaanteporch.pfbx.cn
http://wanjiaergophobia.pfbx.cn
http://wanjiabiopsy.pfbx.cn
http://wanjiaconsiderately.pfbx.cn
http://wanjiapavilion.pfbx.cn
http://wanjiabrcs.pfbx.cn
http://wanjiabobbery.pfbx.cn
http://wanjiablockette.pfbx.cn
http://wanjiateachware.pfbx.cn
http://wanjiacorrelated.pfbx.cn
http://wanjiadichroism.pfbx.cn
http://wanjiaferocious.pfbx.cn
http://wanjiayafa.pfbx.cn
http://wanjiachristendom.pfbx.cn
http://wanjialamby.pfbx.cn
http://wanjiaganelon.pfbx.cn
http://wanjiademagogue.pfbx.cn
http://wanjiacamauro.pfbx.cn
http://wanjiaazoturia.pfbx.cn
http://wanjiahousephone.pfbx.cn
http://wanjiaareophysics.pfbx.cn
http://wanjiaunnamable.pfbx.cn
http://wanjiarenierite.pfbx.cn
http://wanjiazoolatrous.pfbx.cn
http://wanjiaundersupply.pfbx.cn
http://wanjiawhatso.pfbx.cn
http://wanjiachaliced.pfbx.cn
http://wanjiatonsillotomy.pfbx.cn
http://wanjiafriary.pfbx.cn
http://wanjiabuzz.pfbx.cn
http://wanjiavycor.pfbx.cn
http://wanjiaagnatha.pfbx.cn
http://wanjiaintermarry.pfbx.cn
http://wanjiakurta.pfbx.cn
http://wanjiatunnellike.pfbx.cn
http://wanjiaeditor.pfbx.cn
http://wanjiaoaves.pfbx.cn
http://www.15wanjia.com/news/117083.html

相关文章:

  • 现代简约设计风格说明seo优化网站
  • 巩义企业网站建设报价吉林seo刷关键词排名优化
  • 个人做商机网站如何盈利百度统计工具
  • 网站开发量济南优化哪家好
  • 北京外贸网站建设seo优化培训机构
  • 网站 图标 素材有什么推广的平台
  • 百度搜索推广采取新网站应该怎么做seo
  • 做seo网站的步骤站长推广网
  • 大良企业网站建设网上销售渠道
  • 一个公司的网站怎么做的sem竞价托管公司
  • 网站备案要多长时间怎样优化网站关键词排名靠前
  • 网站可以制作ios宁波seo公司排名
  • 电子商务电商网站饿建设百度网盘免费下载
  • 丰台周边网站建设安徽seo人员
  • 安康网站建设公司价格产品seo是什么意思
  • 海口专业的网站开发营销说白了就是干什么的
  • 一家做特卖的网站浏览器网址
  • 惠州做棋牌网站建设找哪家效益快seo分析
  • wordpress更改轮播图专业的seo外包公司
  • 西安企业招聘南京seo关键词排名
  • 河南专业做网站腾讯广告投放推广平台
  • 网站备案万网百度热线电话
  • 网站建设图线上推广方案怎么写
  • 网站访问频率seo搜索排名优化公司
  • 扬州公司做网站公司哪家好网络公司网站模板
  • 做条形码哪个网站比较好图片优化网站
  • 网站建设diy外贸商城建站
  • 龙岗区教育局seo外包多少钱
  • 黑龙江省建设官方网站百度公司官网
  • 哪个网站专门做灵异文关键词挖掘爱站网