-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
output 生成内容为乱码 #2
Comments
这个是在linux环境下训练的吗?然后方便把运行命令,还有webui上的参数提供一下吗 |
运行环境是win10下的 wsl 环境:
具体配置为:
附件里有个 环境配置说明.txt
我把环境的配置流程都记录下来了大佬老师
--------------------------------------------------------------------
可能会出现这样的错误 是依赖库自身问题 在它的issus里有解决方案:
1、AttributeError: /root/anaconda3/envs/Chinese-Vicuna/lib/python3.9/site-packages/bitsandbytes/libbitsandbytes_cpu.so: undefined symbol: cget_col_row_stats
…------$ 解决方案在:bitsandbytes-foundation/bitsandbytes#156
2、AttributeError: module 'gradio' has no attribute 'components'
------$ pip install gradio==3.23.0 安装最新版本
--------------------------------------------------------------------
运行命令是:bash generate.sh
运行参数用附件截图了老师:output乱码和参数截图.png--------------------------------------------------------------------
基础模型是:git clone https://huggingface.co/decapoda-research/llama-7b-hf
LORA模型是:当前目录的 ./lora-Vicuna/checkpoint-4000
generate.sh 脚本内容是(也提交附件了大佬老师):
BASE_MODEL="/mnt/e/zllama-models/llama-7b-hf"LORA_PATH="./lora-Vicuna/checkpoint-4000"
cp ./config-sample/adapter_config.json $LORA_PATH
CUDA_VISIBLE_DEVICES=0 python generate.py \
--model_path $BASE_MODEL \
--lora_path $LORA_PATH
Original
From:"Facico"< ***@***.*** >;
Date:2023/3/23 20:01
To:"Facico/Chinese-Vicuna"< ***@***.*** >;
CC:"SandMist"< ***@***.*** >;"Author"< ***@***.*** >;
Subject:Re: [Facico/Chinese-Vicuna] output 生成内容为乱码 (Issue #2)
这个是在linux环境下训练的吗?然后方便把运行命令,还有webui上的参数提供一下吗
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
@ZenXir |
大佬老师,我刚按你说的方式, 在命令行和网页输出的是乱码,英文问答也是, Instruction: who are you pip环境参数是: pip list | grep transformerstransformers 4.28.0.dev0 pip list | grep tokenizerstokenizers 0.13.2 pip list | grep sentencepiecesentencepiece 0.1.97 系统环境是win11下的wsl,wsl里的环境创建过程是这样的: 在win11环境 使用wsl:http://events.jianshu.io/p/6479d450da2a
下载
运行
<<< conda initialize <<<
ubuntu安装gcc
升级系统内核
如果有安装CUDA 卸载老版本CUDA: 【https://blog.csdn.net/xian0710830114/article/details/124094603】 安装整个CUDA包,在下面这个链接选择对应的平台和系统,会给出安装命令: Installation Instructions: 安装pytorch:这个是对应当前机器显卡 4090 ,从官网 https://pytorch.org/ 对不同的conda python环境,在 D:\whl 目录下,安装对应的轮子 conda create -n Chinese-Vicuna python=3.9 #如果你已经用pip安装过不少软件,并且没有选择不缓存的话,可以用下面的命令来删除缓存 #Mac Os #Windows 配置环境:cd Chinese-Vicuna pip install datasets 安装transformers,直接从主干拉取 transformers pip install accelerate 安装peft,直接从主干拉取 peft pip install gradio #注意事项,解决运行问题:1、AttributeError: /root/anaconda3/envs/Chinese-Vicuna/lib/python3.9/site-packages/bitsandbytes/libbitsandbytes_cpu.so: undefined symbol: cget_col_row_stats 先确认用的cuda是哪个版本: import torch ------$ python /mnt/e/pytorch_test.py ------$ 问题解释在:bitsandbytes-foundation/bitsandbytes#156 2、AttributeError: module 'gradio' has no attribute 'components' |
@ZenXir import sys
import torch
from peft import PeftModel
import transformers
from transformers import LlamaTokenizer, LlamaForCausalLM
tokenizer = LlamaTokenizer.from_pretrained("decapoda-research/llama-7b-hf")
BASE_MODEL = "decapoda-research/llama-7b-hf"
model = LlamaForCausalLM.from_pretrained(
BASE_MODEL,
load_in_8bit=True,
torch_dtype=torch.float16,
device_map="auto",
)
model.eval()
inputs = "Hello, Where is the capital of the United States?" #"你好,美国的首都在哪里?"
input_ids = tokenizer(inputs, return_tensors="pt")['input_ids']
print(input_ids)
generation_output = model.generate(
input_ids=input_ids,
max_new_tokens=15,
)
print(generation_output)
print(tokenizer.decode(generation_output[0]))
model = PeftModel.from_pretrained(
model,
"./lora-alpaca/checkpoint-4000",
torch_dtype=torch.float16,
device_map={'': 0}
)
inputs = "你好,中国的首都在哪里?" #"你好,美国的首都在哪里?"
input_ids = tokenizer(inputs, return_tensors="pt")['input_ids']
print(input_ids)
generation_output = model.generate(
input_ids=input_ids,
max_new_tokens=15,
)
print(generation_output)
print(tokenizer.decode(generation_output[0])) 正常输出的话会输出下面内容
使用CUDA_VISIBLE_DEVICES=0 python simple_test.py来跑 |
/root/anaconda3/envs/Chinese-alpaca-lora/lib/python3.9/site-packages/transformers-4.28.0.dev0-py3.9.egg/transformers/generation/utils.py:1211: UserWarning: You have modified the pretrained model configuration to control generation. This is a deprecated strategy to control generation and will be removed soon, in a future version. Please use a generation configuration file (see https://huggingface.co/docs/transformers/main_classes/text_generation) Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): 上的面例子,英文问答正确,中文问答时,崩溃了大佬老师 checkpoint-xxx 里其实有 adapter_config.json 我正在找原因
|
可以正常运行大佬老师"/mnt/e/Chinese-Vicuna/lora-Vicuna/lora-alpaca/checkpoint-8000", 改成正确的: 我再检查下web的显示,感谢大佬老师 Hello, Where is the capital of the United States? 中国的首都是哪里? |
OK,这个其实是一个比较简单的例子,生成的时候没有加参数控制,在webui那里会有参数控制的 |
明白了 感谢大佬老师
Original
From:"Facico"< ***@***.*** >;
Date:2023/3/24 13:58
To:"Facico/Chinese-Vicuna"< ***@***.*** >;
CC:"SandMist"< ***@***.*** >;"State change"< ***@***.*** >;
Subject:Re: [Facico/Chinese-Vicuna] output 生成内容为乱码 (Issue #2)
OK,这个其实是一个比较简单的例子,生成的时候没有加参数控制,在webui那里会有参数控制的
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
tensor([[ 1, 15043, 29892, 6804, 338, 278, 7483, 310, 278, 3303, |
tensor([[ 1, 29871, 30919, 31076, 29892, 30275, 30356, 30210, 31688, 30769, |
@Facico 运行simple_test.py 使用7B模型返回正常,但13B返回如下,是不是说明13B文件下载有问题? tensor([[ 1, 29871, 30919, 31076, 29892, 30275, 30356, 30210, 31688, 30769, Instruction:你需要回�� |
大佬老师你好:
input:
中国的首都是哪儿?
output:
��������������������������������������������������������������������������������������������������������������������������������
正常运行起来后,通过chrome浏览器访问:http://127.0.0.1:7860
生成结果为乱码
改用360浏览器,结果均为乱码,
需要设置什么吗?
The text was updated successfully, but these errors were encountered: