英文

WortegaLM 109m

模型概述

这是一个使用95GB代码集进行从零开始训练的类似GPTneo的模型,包括Habra、Pikabu和新闻等数据(大约12亿个令牌)。它可以解决一些简单的任务,但不适用于复杂任务,但作为学生项目的模型非常理想。

快速入门





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