THUDM / GLM

GLM (General Language Model)
MIT License
3.12k stars 317 forks source link

使用glm-2b时候,跟随readme提供的例子,得到很糟糕的输出 #178

Open leekum2018 opened 1 year ago

leekum2018 commented 1 year ago

代码如下: from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("THUDM/glm-2b", trust_remote_code=True) model = AutoModelForSeq2SeqLM.from_pretrained("THUDM/glm-2b", trust_remote_code=True) model = model.half().cuda() model.eval()

inputs = tokenizer("Ng is an adjunct professor at [MASK] (formerly associate professor and Director of its Stanford AI Lab or SAIL ). Also a pioneer in online education, Ng co-founded Coursera and deeplearning.ai.", return_tensors="pt") inputs = tokenizer.build_inputs_for_generation(inputs, max_gen_length=512).to('cuda') outputs = model.generate(**inputs, max_length=512, eos_token_id=tokenizer.eop_token_id) print(tokenizer.decode(outputs[0].tolist()))

得到输出: Explicitly passing a revision is encouraged when loading a model with custom code to ensure no malicious code has been contributed in a newer revision. Explicitly passing a revision is encouraged when loading a configuration with custom code to ensure no malicious code has been contributed in a newer revision. Explicitly passing a revision is encouraged when loading a model with custom code to ensure no malicious code has been contributed in a newer revision. Some weights of the model checkpoint at THUDM/glm-2b were not used when initializing GLMForConditionalGeneration: ['dense.weight', 'out_proj.bias', 'out_proj.weight', 'dense.bias']

kolaen commented 1 year ago

同样的问题,请问解决了吗

Jxxiang99 commented 8 months ago

同问