pip install -q -U transformers trl accelerate peft bitsandbytes
from transformers import AutoModelForCausalLM, GenerationConfig, AutoTokenizer
import torch
import os

model_id = "gokaygokay/tiny_llama_chat_description_to_prompt"
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, load_in_8bit=False,
                                             device_map="auto",
                                             trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token = tokenizer.eos_token

def generate_response(user_input):

  prompt = f"<|im_start|>user\n{user_input}<|im_end|>\n<|im_start|>assistant:"

  inputs = tokenizer([prompt], return_tensors="pt")
  generation_config = GenerationConfig(penalty_alpha=0.6,do_sample = True,
      top_k=5,temperature=0.9,repetition_penalty=1.2,
      max_new_tokens=100,pad_token_id=tokenizer.eos_token_id
  )

  inputs = tokenizer(prompt, return_tensors="pt").to('cuda')

  outputs = model.generate(**inputs, generation_config=generation_config)
  print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Downloads last month
31
Safetensors
Model size
1.1B params
Tensor type
FP16
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Dataset used to train gokaygokay/tiny_llama_chat_description_to_prompt