模型:
AlexWortega/wortegaLM-1b
这是一款类似于GPTneo的模型,是在95GB的代码、Habra、Pikabu和新闻数据集(大约12亿个token)上从零开始训练的。它可以解决一些基本任务,但不适用于ZS FS,但非常适合作为学生项目的模型
from transformers import AutoTokenizer, AutoModelForCausalLM, tokenizer = AutoTokenizer.from_pretrained('AlexWortega/wortegaLM',padding_side='left') device = 'cuda' model = AutoModelForCausalLM.from_pretrained('AlexWortega/wortegaLM') model.resize_token_embeddings(len(tokenizer)) model.to(device) def generate_seqs(q,model, k=2): gen_kwargs = { "min_length": 20, "max_new_tokens": 100, "top_k": 50, "top_p": 0.7, "do_sample": True, "early_stopping": True, "no_repeat_ngram_size": 2, "eos_token_id": tokenizer.eos_token_id, "pad_token_id": tokenizer.eos_token_id, "use_cache": True, "repetition_penalty": 1.5, "length_penalty": 1.2, "num_beams": 4, "num_return_sequences": k } t = tokenizer.encode(q, add_special_tokens=False, return_tensors='pt').to(device) g = model.generate(t, **gen_kwargs) generated_sequences = tokenizer.batch_decode(g, skip_special_tokens=False) return generated_sequences